OGS
MeshGeoToolsLib::BoundaryElementsAtPoint Class Referencefinal

Detailed Description

This class collects point elements located at a given point elements.

Definition at line 30 of file BoundaryElementsAtPoint.h.

#include <BoundaryElementsAtPoint.h>

Collaboration diagram for MeshGeoToolsLib::BoundaryElementsAtPoint:
[legend]

Public Member Functions

 BoundaryElementsAtPoint (MeshLib::Mesh const &mesh, MeshNodeSearcher const &mshNodeSearcher, GeoLib::Point const &point, const bool multiple_nodes_allowed)
 
 ~BoundaryElementsAtPoint ()
 
GeoLib::Point const & getPoint () const
 
std::vector< MeshLib::Element * > const & getBoundaryElements () const
 Return the vector of boundary elements (i.e. points).
 

Private Attributes

GeoLib::Point const & _point
 
std::vector< MeshLib::Element * > _boundary_elements
 

Constructor & Destructor Documentation

◆ BoundaryElementsAtPoint()

MeshGeoToolsLib::BoundaryElementsAtPoint::BoundaryElementsAtPoint ( MeshLib::Mesh const & mesh,
MeshNodeSearcher const & mshNodeSearcher,
GeoLib::Point const & point,
const bool multiple_nodes_allowed )

Constructor

Parameters
mesha mesh object
mshNodeSearchera MeshNodeSearcher object which is internally used to search mesh nodes
pointa point object where edges are searched
multiple_nodes_allowedAllows to find multiple nodes within the search radius, the nearest node is returned (as point element). This enables to specify larger search radius to find possible other geometries that don't match exactly to the mesh.

Definition at line 26 of file BoundaryElementsAtPoint.cpp.

29 : _point(point)
30{
31 auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point);
32
33#ifdef USE_PETSC
34 std::size_t const number_of_found_nodes_at_rank = node_ids.size();
35 std::size_t number_of_total_found_nodes = 0;
36
37 MPI_Allreduce(&number_of_found_nodes_at_rank, &number_of_total_found_nodes,
38 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
39
40 if (number_of_total_found_nodes == 0)
41 {
43 "BoundaryElementsAtPoint: the mesh node searcher was unable to "
44 "locate the point ({:f}, {:f}, {:f}) in the mesh.",
45 _point[0], _point[1], _point[2]);
46 }
47
48 if (number_of_found_nodes_at_rank == 0)
49 {
50 return;
51 }
52#else
53 if (node_ids.empty())
54 {
56 "BoundaryElementsAtPoint: the mesh node searcher was unable to "
57 "locate the point ({:f}, {:f}, {:f}) in the mesh.",
58 _point[0], _point[1], _point[2]);
59 }
60#endif
61
62 if (node_ids.size() == 1)
63 {
64 std::array<MeshLib::Node*, 1> const nodes = {
65 {const_cast<MeshLib::Node*>(mesh.getNode(node_ids[0]))}};
66
67 _boundary_elements.push_back(new MeshLib::Point{nodes, node_ids[0]});
68 return;
69 }
70
71 auto& mesh_nodes =
72 const_cast<std::vector<MeshLib::Node*>&>(mesh.getNodes());
73 std::size_t const nearest_node_id =
74 *std::min_element(node_ids.begin(), node_ids.end(),
75 [&mesh_nodes, &point](auto id0, auto id1)
76 {
77 return MathLib::sqrDist(*mesh_nodes[id0], point) <
78 MathLib::sqrDist(*mesh_nodes[id1], point);
79 });
80
81 if (!multiple_nodes_allowed)
82 {
84 "BoundaryElementsAtPoint: the mesh node searcher found {:d} points "
85 "near the requested point ({:f}, {:f}, {:f}) in the mesh, while "
86 "exactly one is expected. Node (id={:d}) ({:f}, {:f}, {:f}) has "
87 "distance {:f}.",
88 node_ids.size(), _point[0], _point[1], _point[2],
89 mesh_nodes[nearest_node_id]->getID(),
90 (*mesh_nodes[nearest_node_id])[0],
91 (*mesh_nodes[nearest_node_id])[1],
92 (*mesh_nodes[nearest_node_id])[2],
93 MathLib::sqrDist(*mesh_nodes[nearest_node_id], point));
94 }
95 WARN(
96 "BoundaryElementsAtPoint: the mesh node searcher found {:d} points "
97 "near the requested point ({:f}, {:f}, {:f}) in the mesh, while "
98 "exactly one is expected. Node (id={:d}) ({:f}, {:f}, {:f}) has "
99 "distance {:f}.",
100 node_ids.size(), _point[0], _point[1], _point[2],
101 mesh_nodes[nearest_node_id]->getID(), (*mesh_nodes[nearest_node_id])[0],
102 (*mesh_nodes[nearest_node_id])[1], (*mesh_nodes[nearest_node_id])[2],
103 MathLib::sqrDist(*mesh_nodes[nearest_node_id], point));
104
105 std::array<MeshLib::Node*, 1> const nodes = {
106 {const_cast<MeshLib::Node*>(mesh.getNode(nearest_node_id))}};
107
108 _boundary_elements.push_back(new MeshLib::Point{nodes, nearest_node_id});
109}
#define OGS_FATAL(...)
Definition Error.h:26
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
std::size_t getID() const
std::vector< MeshLib::Element * > _boundary_elements
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:26

References _boundary_elements, _point, MathLib::Point3dWithID::getID(), MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeIDs(), MeshLib::Mesh::getNode(), MeshLib::Mesh::getNodes(), OGS_FATAL, MathLib::sqrDist(), and WARN().

◆ ~BoundaryElementsAtPoint()

MeshGeoToolsLib::BoundaryElementsAtPoint::~BoundaryElementsAtPoint ( )

Definition at line 111 of file BoundaryElementsAtPoint.cpp.

112{
113 for (auto p : _boundary_elements)
114 {
115 delete p;
116 }
117}

References _boundary_elements.

Member Function Documentation

◆ getBoundaryElements()

std::vector< MeshLib::Element * > const & MeshGeoToolsLib::BoundaryElementsAtPoint::getBoundaryElements ( ) const
inline

Return the vector of boundary elements (i.e. points).

Definition at line 55 of file BoundaryElementsAtPoint.h.

56 {
57 return _boundary_elements;
58 }

References _boundary_elements.

◆ getPoint()

GeoLib::Point const & MeshGeoToolsLib::BoundaryElementsAtPoint::getPoint ( ) const
inline

Definition at line 49 of file BoundaryElementsAtPoint.h.

50 {
51 return _point;
52 }

References _point.

Referenced by MeshGeoToolsLib::BoundaryElementsSearcher::getBoundaryElements().

Member Data Documentation

◆ _boundary_elements

std::vector<MeshLib::Element*> MeshGeoToolsLib::BoundaryElementsAtPoint::_boundary_elements
private

◆ _point

GeoLib::Point const& MeshGeoToolsLib::BoundaryElementsAtPoint::_point
private

Definition at line 61 of file BoundaryElementsAtPoint.h.

Referenced by BoundaryElementsAtPoint(), and getPoint().


The documentation for this class was generated from the following files: