diff --git a/MeshGeoToolsLib/MeshNodeSearcher.cpp b/MeshGeoToolsLib/MeshNodeSearcher.cpp index fc19986e196685be6153ee6a05ef6cee49144eb6..7d7e5f551d8fc393374216bf771f543ba58d2de1 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.cpp +++ b/MeshGeoToolsLib/MeshNodeSearcher.cpp @@ -76,6 +76,41 @@ std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs( return vec_nodes; } +std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs( + std::vector<MathLib::Point3dWithID*> const& points) const +{ + double const epsilon_radius = _search_length_algorithm->getSearchLength(); + + std::vector<std::size_t> node_ids; + node_ids.reserve(points.size()); + + for (auto const* const p_ptr : points) + { + auto const& p = *p_ptr; + std::vector<std::size_t> const ids = + _mesh_grid.getPointsInEpsilonEnvironment(p, epsilon_radius); + if (ids.empty()) + { + OGS_FATAL( + "No nodes could be found in the mesh for point %d : (%g, %g, " + "%g) in %g epsilon radius in the mesh '%s'", + p.getID(), p[0], p[1], p[2], epsilon_radius, + _mesh.getName().c_str()); + } + if (ids.size() != 1) + { + OGS_FATAL( + "Found %d nodes in the mesh for point %d : (%g, %g, %g) in %g " + "epsilon radius in the mesh '%s'. Expected to find exactly one " + "node.", + ids.size(), p.getID(), p[0], p[1], p[2], epsilon_radius, + _mesh.getName().c_str()); + } + node_ids.push_back(ids.front()); + } + return node_ids; +} + std::vector<std::size_t> const& MeshNodeSearcher::getMeshNodeIDsForPoint( GeoLib::Point const& pnt) const { diff --git a/MeshGeoToolsLib/MeshNodeSearcher.h b/MeshGeoToolsLib/MeshNodeSearcher.h index df70806611b6ab7f298ee66df7a5c921f0757f19..26d3ddc9e97e930c2c1b5720a5eef4a451589031 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.h +++ b/MeshGeoToolsLib/MeshNodeSearcher.h @@ -76,6 +76,14 @@ public: std::vector<std::size_t> getMeshNodeIDs( GeoLib::GeoObject const& geoObj) const; + /** + * Finds unique mesh nodes of each of the input points. + * + * \return a vector of mesh node ids. + */ + std::vector<std::size_t> getMeshNodeIDs( + std::vector<MathLib::Point3dWithID*> const& points) const; + /** * Searches for the node nearest by the given point. If there are two nodes * with the same distance the id of the one that was first found will be