OGS
MeshGeoToolsLib Namespace Reference

Classes

class  BoundaryElementsAlongPolyline
 
class  BoundaryElementsAtPoint
 This class collects point elements located at a given point elements. More...
 
class  BoundaryElementsOnSurface
 
class  BoundaryElementsSearcher
 
class  GeoMapper
 A set of tools for mapping the elevation of geometric objects. More...
 
class  HeuristicSearchLength
 
class  MeshNodesAlongPolyline
 
class  MeshNodesAlongSurface
 
class  MeshNodeSearcher
 
class  MeshNodesOnPoint
 
class  SearchLength
 

Enumerations

enum class  SearchAllNodes : bool { Yes = true , No = false }
 

Functions

std::unique_ptr< MeshLib::MeshappendLinesAlongPolylines (const MeshLib::Mesh &mesh, const GeoLib::PolylineVec &ply_vec)
 
template<typename CacheType , typename GeometryType >
std::vector< MeshLib::Element * > const & getBoundaryElements (std::vector< CacheType * > &cached_elements, std::function< GeometryType(CacheType const &)> getCachedItem, GeometryType const &item, MeshLib::Mesh const &mesh, MeshNodeSearcher const &mesh_node_searcher, bool const multiple_nodes_allowed)
 
std::string meshNameFromGeometry (std::string const &geometrical_set_name, std::string const &geometry_name)
 
template<typename GeometryVec >
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeometries (std::vector< GeometryVec * > const &geometries, MeshGeoToolsLib::BoundaryElementsSearcher &boundary_element_searcher, bool const multiple_nodes_allowed)
 
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeoObjects (GeoLib::GEOObjects const &geo_objects, MeshLib::Mesh const &mesh, std::unique_ptr< SearchLength > search_length_algorithm, bool const multiple_nodes_allowed)
 
std::unique_ptr< MeshGeoToolsLib::SearchLengthcreateSearchLengthAlgorithm (BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)
 
static MeshLib::Element const * findElementContainingPointXY (std::vector< MeshLib::Element const * > const &elements, MathLib::Point3d const &p)
 
static std::vector< MathLib::Point3dcomputeElementSegmentIntersections (MeshLib::Element const &elem, GeoLib::LineSegment const &segment)
 
static std::vector< GeoLib::LineSegmentcreateSubSegmentsForElement (std::vector< MathLib::Point3d > const &intersections, MeshLib::Element const *const beg_elem, MeshLib::Element const *const end_elem, MathLib::Point3d const &beg_pnt, MathLib::Point3d const &end_pnt, MeshLib::Element const *const elem)
 
static std::vector< GeoLib::LineSegmentmapLineSegment (GeoLib::LineSegment const &segment, std::vector< MeshLib::Element const * > const &surface_elements, MeshLib::Element const *const beg_elem, MeshLib::Element const *const end_elem)
 
static void mapPointOnSurfaceElement (MeshLib::Element const &elem, MathLib::Point3d &q)
 
static std::vector< MeshLib::Element const * > getCandidateElementsForLineSegmentIntersection (MeshLib::MeshElementGrid const &mesh_element_grid, GeoLib::LineSegment const &segment)
 
static bool snapPointToElementNode (MathLib::Point3d &p, MeshLib::Element const &elem, double rel_eps)
 
static void insertSubSegments (GeoLib::Polyline &ply, GeoLib::PointVec &points, GeoLib::Polyline::SegmentIterator &segment_it, std::vector< GeoLib::LineSegment > const &sub_segments)
 
static void mapPolylineOnSurfaceMesh (GeoLib::Polyline &ply, GeoLib::PointVec &orig_points, MeshLib::MeshElementGrid const &mesh_element_grid)
 
void identifySubdomainMesh (MeshLib::Mesh &subdomain_mesh, MeshLib::Mesh const &bulk_mesh, MeshNodeSearcher const &mesh_node_searcher, bool const force_overwrite=false)
 
std::vector< bool > markNodesOutSideOfPolygon (std::vector< MeshLib::Node * > const &nodes, GeoLib::Polygon const &polygon)
 
template<typename PT >
void resetMeshElementProperty (MeshLib::Mesh &mesh, GeoLib::Polygon const &polygon, std::string const &property_name, PT new_property_value, int restrict_to_material_id, bool const any_of)
 
template<typename CacheType , typename GeometryType >
std::vector< std::size_t > const & getMeshNodeIDs (std::vector< CacheType * > &cached_elements, std::function< GeometryType(CacheType const &)> getCachedItem, GeometryType const &item, MeshLib::Mesh const &mesh, GeoLib::Grid< MeshLib::Node > const &mesh_grid, double const search_length, SearchAllNodes const search_all_nodes)
 

Enumeration Type Documentation

◆ SearchAllNodes

enum class MeshGeoToolsLib::SearchAllNodes : bool
strong
Enumerator
Yes 
No 

Definition at line 13 of file SearchAllNodes.h.

Function Documentation

◆ appendLinesAlongPolylines()

std::unique_ptr< MeshLib::Mesh > MeshGeoToolsLib::appendLinesAlongPolylines ( const MeshLib::Mesh & mesh,
const GeoLib::PolylineVec & ply_vec )

Add line elements to a copy of a given mesh

The function creates line elements from nodes located along user-provided polylines. New elements will have a distinct material ID for each polyline.

Remarks
The function allows creation of duplicated line elements.
Line elements may not be placed along edges of existing elements.
Parameters
meshoriginal mesh
ply_vecpolyline vector whose nodes are used to create line elements
Returns
a new mesh which is copied from a given mesh and additionally includes line elements

Definition at line 25 of file AppendLinesAlongPolyline.cpp.

27{
28 // copy existing nodes and elements
29 std::vector<MeshLib::Node*> vec_new_nodes =
31 std::vector<MeshLib::Element*> vec_new_eles =
32 MeshLib::copyElementVector(mesh.getElements(), vec_new_nodes);
33
34 auto const material_ids = materialIDs(mesh);
35 int const max_matID =
36 material_ids
37 ? *(std::max_element(begin(*material_ids), end(*material_ids)))
38 : 0;
39
40 auto const edgeLengths = minMaxEdgeLength(mesh.getElements());
41 double const min_edge = edgeLengths.first;
42
43 std::vector<int> new_mat_ids;
44 const std::size_t n_ply(ply_vec.size());
45 // for each polyline
46 for (std::size_t k(0); k < n_ply; k++)
47 {
48 auto const* const ply = ply_vec.getVector()[k];
49
50 // search nodes on the polyline
52 mesh, *ply, min_edge * 0.5, MeshGeoToolsLib::SearchAllNodes::Yes);
53 auto& vec_nodes_on_ply = mshNodesAlongPoly.getNodeIDs();
54 if (vec_nodes_on_ply.empty())
55 {
56 std::string ply_name;
57 ply_vec.getNameOfElementByID(k, ply_name);
58 INFO("No nodes found on polyline {:s}", ply_name);
59 continue;
60 }
61
62 // add line elements
63 for (std::size_t i = 0; i < vec_nodes_on_ply.size() - 1; i++)
64 {
65 std::array<MeshLib::Node*, 2> element_nodes;
66 element_nodes[0] = vec_new_nodes[vec_nodes_on_ply[i]];
67 element_nodes[1] = vec_new_nodes[vec_nodes_on_ply[i + 1]];
68 vec_new_eles.push_back(
69 new MeshLib::Line(element_nodes, vec_new_eles.size()));
70 new_mat_ids.push_back(max_matID + k + 1);
71 }
72 }
73
74 // generate a mesh
75 const std::string name = mesh.getName() + "_with_lines";
76 auto new_mesh =
77 std::make_unique<MeshLib::Mesh>(name, vec_new_nodes, vec_new_eles,
78 true /* compute_element_neighbors */);
79 auto new_material_ids =
80 new_mesh->getProperties().createNewPropertyVector<int>(
81 "MaterialIDs", MeshLib::MeshItemType::Cell);
82 if (!new_material_ids)
83 {
84 OGS_FATAL("Could not create MaterialIDs cell vector in new mesh.");
85 }
86 new_material_ids->reserve(new_mesh->getNumberOfElements());
87 if (material_ids != nullptr)
88 {
89 std::copy(begin(*material_ids), end(*material_ids),
90 std::back_inserter(*new_material_ids));
91 }
92 else
93 {
94 new_material_ids->resize(mesh.getNumberOfElements());
95 }
96 std::copy(begin(new_mat_ids), end(new_mat_ids),
97 std::back_inserter(*new_material_ids));
98 return new_mesh;
99}
#define OGS_FATAL(...)
Definition Error.h:26
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
std::size_t size() const
std::vector< T * > const & getVector() const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:103
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
std::vector< Node * > copyNodeVector(const std::vector< Node * > &nodes)
Creates a deep copy of a Node vector.
std::vector< Element * > copyElementVector(std::vector< Element * > const &elements, std::vector< Node * > const &new_nodes, std::vector< std::size_t > const *const node_id_map)

References MeshLib::Cell, MeshLib::copyElementVector(), MeshLib::copyNodeVector(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getName(), GeoLib::TemplateVec< T >::getNameOfElementByID(), MeshGeoToolsLib::MeshNodesAlongPolyline::getNodeIDs(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfElements(), GeoLib::TemplateVec< T >::getVector(), INFO(), OGS_FATAL, GeoLib::TemplateVec< T >::size(), and Yes.

Referenced by main().

◆ computeElementSegmentIntersections()

static std::vector< MathLib::Point3d > MeshGeoToolsLib::computeElementSegmentIntersections ( MeshLib::Element const & elem,
GeoLib::LineSegment const & segment )
static

Definition at line 296 of file GeoMapper.cpp.

298{
299 std::vector<MathLib::Point3d> element_intersections;
300 for (std::size_t k(0); k < elem.getNumberOfEdges(); ++k)
301 {
302 auto const edge =
303 std::unique_ptr<MeshLib::Element const>(elem.getEdge(k));
304 GeoLib::LineSegment elem_segment{
305 new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
306 const_cast<MeshLib::Node*>(edge->getNode(0))),
307 0),
308 new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
309 const_cast<MeshLib::Node*>(edge->getNode(1))),
310 0),
311 true};
312 std::vector<MathLib::Point3d> const intersections(
313 GeoLib::lineSegmentIntersect2d(segment, elem_segment));
314 element_intersections.insert(end(element_intersections),
315 begin(intersections), end(intersections));
316 }
317 return element_intersections;
318}
std::vector< MathLib::Point3d > lineSegmentIntersect2d(GeoLib::LineSegment const &ab, GeoLib::LineSegment const &cd)

References computeElementSegmentIntersections(), MeshLib::Element::getEdge(), MeshLib::Element::getNumberOfEdges(), and GeoLib::lineSegmentIntersect2d().

Referenced by computeElementSegmentIntersections(), and mapLineSegment().

◆ constructAdditionalMeshesFromGeometries()

template<typename GeometryVec >
std::vector< std::unique_ptr< MeshLib::Mesh > > MeshGeoToolsLib::constructAdditionalMeshesFromGeometries ( std::vector< GeometryVec * > const & geometries,
MeshGeoToolsLib::BoundaryElementsSearcher & boundary_element_searcher,
bool const multiple_nodes_allowed )

Definition at line 38 of file ConstructMeshesFromGeometries.cpp.

42{
43 std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
44
45#ifdef USE_PETSC
46 // The subdomain_mesh is not yet a NodePartitionedMesh.
47 // The bulk_mesh, which is a NodePartitionedMesh, is needed to construct the
48 // subdomain NodePartitionedMesh.
49 auto const* bulk_mesh = dynamic_cast<MeshLib::NodePartitionedMesh const*>(
50 &boundary_element_searcher.mesh);
51#endif
52 for (GeometryVec* const geometry_vec : geometries)
53 {
54 // Each geometry_vec has a name, this is the first part of the full
55 // name.
56 auto const& vec_name = geometry_vec->getName();
57
58 auto const& vec_data = geometry_vec->getVector();
59
60 auto const vec_size = geometry_vec->size();
61 for (std::size_t i = 0; i < vec_size; ++i)
62 {
63 // Each geometry has a name, this is the second part of the full
64 // name.
65 std::string geometry_name;
66 bool const is_geometry_named =
67 geometry_vec->getNameOfElementByID(i, geometry_name);
68 if (!is_geometry_named)
69 {
70 continue;
71 }
72
73 auto const& geometry = *vec_data[i];
74
75 DBUG("Creating mesh from geometry {:s} {:s}.", vec_name,
76 geometry_name);
77
78 auto subdomain_mesh = createMeshFromElementSelection(
79 meshNameFromGeometry(vec_name, geometry_name),
81 boundary_element_searcher.getBoundaryElements(
82 geometry, multiple_nodes_allowed)));
83
84#ifdef USE_PETSC
85 additional_meshes.push_back(
87 bulk_mesh, subdomain_mesh.get()));
88#else
89 // Nothing special to be done in the serial case.
90 additional_meshes.emplace_back(std::move(subdomain_mesh));
91#endif
92 }
93 }
94 return additional_meshes;
95}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
std::vector< MeshLib::Element * > const & getBoundaryElements(GeoLib::GeoObject const &geoObj, bool const multiple_nodes_allowed)
std::vector< Element * > cloneElements(std::vector< Element * > const &elements)
Clones a vector of elements using the Element::clone() function.
std::unique_ptr< NodePartitionedMesh > transformMeshToNodePartitionedMesh(NodePartitionedMesh const *const bulk_mesh, Mesh const *const subdomain_mesh)

References MeshLib::cloneElements(), DBUG(), MeshGeoToolsLib::BoundaryElementsSearcher::getBoundaryElements(), MeshLib::Mesh::getName(), MeshGeoToolsLib::BoundaryElementsSearcher::mesh, meshNameFromGeometry(), and MeshLib::transformMeshToNodePartitionedMesh().

Referenced by constructAdditionalMeshesFromGeoObjects().

◆ constructAdditionalMeshesFromGeoObjects()

std::vector< std::unique_ptr< MeshLib::Mesh > > MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects ( GeoLib::GEOObjects const & geo_objects,
MeshLib::Mesh const & mesh,
std::unique_ptr< SearchLength > search_length_algorithm,
bool const multiple_nodes_allowed )

For each named geometry in the give geo_objects (defined on the given mesh) constructs a mesh corresponding to the geometry with mappings to the bulk mesh elements and nodes.

Definition at line 98 of file ConstructMeshesFromGeometries.cpp.

103{
104 std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
105
106 auto const& mesh_node_searcher =
108 mesh, std::move(search_length_algorithm));
109
110 MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(
111 mesh, mesh_node_searcher);
112
113 //
114 // Points
115 //
116 {
117 auto point_meshes = constructAdditionalMeshesFromGeometries(
118 geo_objects.getPoints(), boundary_element_searcher,
119 multiple_nodes_allowed);
120 std::move(begin(point_meshes), end(point_meshes),
121 std::back_inserter(additional_meshes));
122 }
123
124 //
125 // Polylines
126 //
127 {
128 auto polyline_meshes = constructAdditionalMeshesFromGeometries(
129 geo_objects.getPolylines(), boundary_element_searcher,
130 multiple_nodes_allowed);
131 std::move(begin(polyline_meshes), end(polyline_meshes),
132 std::back_inserter(additional_meshes));
133 }
134
135 // Surfaces
136 {
137 auto surface_meshes = constructAdditionalMeshesFromGeometries(
138 geo_objects.getSurfaces(), boundary_element_searcher,
139 multiple_nodes_allowed);
140 std::move(begin(surface_meshes), end(surface_meshes),
141 std::back_inserter(additional_meshes));
142 }
143
144 // Set axial symmetry for the additional meshes to the same value as the
145 // "bulk" mesh.
146 std::for_each(begin(additional_meshes), end(additional_meshes),
147 [axial_symmetry = mesh.isAxiallySymmetric()](auto& m)
148 { m->setAxiallySymmetric(axial_symmetry); });
149 return additional_meshes;
150}
static MeshNodeSearcher const & getMeshNodeSearcher(MeshLib::Mesh const &mesh, std::unique_ptr< MeshGeoToolsLib::SearchLength > &&search_length_algorithm)
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeometries(std::vector< GeometryVec * > const &geometries, MeshGeoToolsLib::BoundaryElementsSearcher &boundary_element_searcher, bool const multiple_nodes_allowed)

References constructAdditionalMeshesFromGeometries(), MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher(), GeoLib::GEOObjects::getPoints(), GeoLib::GEOObjects::getPolylines(), GeoLib::GEOObjects::getSurfaces(), and MeshLib::Mesh::isAxiallySymmetric().

Referenced by anonymous_namespace{ProjectData.cpp}::readMeshes().

◆ createSearchLengthAlgorithm()

std::unique_ptr< MeshGeoToolsLib::SearchLength > MeshGeoToolsLib::createSearchLengthAlgorithm ( BaseLib::ConfigTree const & external_config,
MeshLib::Mesh const & mesh )

Creates a search length algorithm from the given config.

In case, that there is no tag for the search length algorithm found in the config, the default SearchLength algorithm is returned.

Input File Parameter
prj__search_length_algorithm
Input File Parameter
prj__search_length_algorithm__type
Input File Parameter
prj__search_length_algorithm__fixed
Input File Parameter
prj__search_length_algorithm__fixed__value
Input File Parameter
prj__search_length_algorithm__heuristic

Definition at line 19 of file CreateSearchLength.cpp.

21{
22 std::optional<BaseLib::ConfigTree> config =
24 external_config.getConfigSubtreeOptional("search_length_algorithm");
25
26 if (!config)
27 {
28 return std::make_unique<MeshGeoToolsLib::SearchLength>();
29 }
30
32 std::string const type = config->getConfigParameter<std::string>("type");
33
35 if (type == "fixed")
36 {
38 auto const length = config->getConfigParameter<double>("value");
39 return std::make_unique<MeshGeoToolsLib::SearchLength>(length);
40 }
41 if (type == "heuristic")
42 {
44 return std::make_unique<HeuristicSearchLength>(mesh);
45 }
46 OGS_FATAL("Unknown search length algorithm type '{:s}'.", type);
47}

References BaseLib::ConfigTree::getConfigSubtreeOptional(), and OGS_FATAL.

Referenced by anonymous_namespace{ProjectData.cpp}::readMeshes().

◆ createSubSegmentsForElement()

static std::vector< GeoLib::LineSegment > MeshGeoToolsLib::createSubSegmentsForElement ( std::vector< MathLib::Point3d > const & intersections,
MeshLib::Element const *const beg_elem,
MeshLib::Element const *const end_elem,
MathLib::Point3d const & beg_pnt,
MathLib::Point3d const & end_pnt,
MeshLib::Element const *const elem )
static

Definition at line 320 of file GeoMapper.cpp.

325{
326 std::vector<GeoLib::LineSegment> sub_segments;
327 if (intersections.size() > 2)
328 {
329 std::stringstream out;
330 out << "element with id " << elem->getID() << " and seg "
331 << " intersecting at more than two edges\n";
332 for (std::size_t k(0); k < intersections.size(); ++k)
333 {
334 out << k << " " << intersections[k] << "\n";
335 }
336 out << "Could not map segment on element. Aborting.\n";
337 OGS_FATAL("{:s}", out.str());
338 }
339
340 if (intersections.size() == 1 && elem == beg_elem)
341 {
342 // The line segment intersects the element that contains the begin
343 // point of the line segment. Here the first sub line segment is
344 // added.
345 if (MathLib::sqrDist(beg_pnt, intersections[0]) >
346 std::numeric_limits<double>::epsilon())
347 {
348 sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0},
349 new GeoLib::Point{intersections[0], 0},
350 true);
351 }
352 }
353
354 if (intersections.size() == 1 && elem == end_elem)
355 {
356 // The line segment intersects the element that contains the end
357 // point of the line segment. Here the last sub line segment is
358 // added.
359 if (MathLib::sqrDist(end_pnt, intersections[0]) >
360 std::numeric_limits<double>::epsilon())
361 {
362 sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0},
363 new GeoLib::Point{end_pnt, 0}, true);
364 }
365 }
366
367 if (intersections.size() == 1 && (elem != beg_elem && elem != end_elem))
368 {
369 // Since the line segment enters and leaves the element in the same
370 // point there isn't any need to insert a new sub line segment.
371 return sub_segments;
372 }
373
374 // create sub segment for the current element
375 if (intersections.size() == 2)
376 {
377 sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0},
378 new GeoLib::Point{intersections[1], 0}, true);
379 }
380 return sub_segments;
381}
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:26

References createSubSegmentsForElement(), MeshLib::Element::getID(), OGS_FATAL, and MathLib::sqrDist().

Referenced by createSubSegmentsForElement(), and mapLineSegment().

◆ findElementContainingPointXY()

static MeshLib::Element const * MeshGeoToolsLib::findElementContainingPointXY ( std::vector< MeshLib::Element const * > const & elements,
MathLib::Point3d const & p )
static

Find the 2d-element within the elements that contains the given point p.

The algorithm projects every element of the elements vector and the point p orthogonal to the \(x\)- \(y\) plane. In the \(x\)- \(y\) plane it is checked if the projected point is in the projected element.

Definition at line 261 of file GeoMapper.cpp.

264{
265 for (auto const elem : elements)
266 {
267 std::unique_ptr<MeshLib::Element> elem_2d(elem->clone());
268 // reset/copy the nodes
269 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
270 {
271 elem_2d->setNode(k, new MeshLib::Node(*elem_2d->getNode(k)));
272 }
273 // project to xy
274 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
275 {
276 (*const_cast<MeshLib::Node*>(elem_2d->getNode(k)))[2] = 0.0;
277 }
278 if (elem_2d->isPntInElement(MathLib::Point3d{{{p[0], p[1], 0.0}}}))
279 {
280 // clean up the copied nodes
281 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
282 {
283 delete elem_2d->getNode(k);
284 }
285 return elem;
286 }
287 // clean up the copied nodes
288 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
289 {
290 delete elem_2d->getNode(k);
291 }
292 }
293 return nullptr;
294}

Referenced by mapPolylineOnSurfaceMesh().

◆ getBoundaryElements()

template<typename CacheType , typename GeometryType >
std::vector< MeshLib::Element * > const & MeshGeoToolsLib::getBoundaryElements ( std::vector< CacheType * > & cached_elements,
std::function< GeometryType(CacheType const &)> getCachedItem,
GeometryType const & item,
MeshLib::Mesh const & mesh,
MeshNodeSearcher const & mesh_node_searcher,
bool const multiple_nodes_allowed )

Definition at line 49 of file BoundaryElementsSearcher.cpp.

55{
56 if (auto const it = find_if(cbegin(cached_elements), cend(cached_elements),
57 [&](auto const& element)
58 { return getCachedItem(*element) == item; });
59 it != cend(cached_elements))
60 {
61 return (*it)->getBoundaryElements();
62 }
63 // create new boundary elements
64 if constexpr (std::is_convertible<GeometryType, GeoLib::Point>::value)
65 {
66 cached_elements.push_back(new CacheType(mesh, mesh_node_searcher, item,
67 multiple_nodes_allowed));
68 }
69 else
70 {
71 cached_elements.push_back(
72 new CacheType(mesh, mesh_node_searcher, item));
73 }
74 return cached_elements.back()->getBoundaryElements();
75}

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

◆ getCandidateElementsForLineSegmentIntersection()

static std::vector< MeshLib::Element const * > MeshGeoToolsLib::getCandidateElementsForLineSegmentIntersection ( MeshLib::MeshElementGrid const & mesh_element_grid,
GeoLib::LineSegment const & segment )
static

Definition at line 466 of file GeoMapper.cpp.

469{
470 GeoLib::LineSegment seg_deep_copy(
471 new GeoLib::Point(segment.getBeginPoint()),
472 new GeoLib::Point(segment.getEndPoint()), true);
473 // modify z coordinates such that all surface elements around the line
474 // segment are found
475 seg_deep_copy.getBeginPoint()[2] = mesh_element_grid.getMinPoint()[2];
476 seg_deep_copy.getEndPoint()[2] = mesh_element_grid.getMaxPoint()[2];
477 std::array<MathLib::Point3d, 2> const pnts{
478 {seg_deep_copy.getBeginPoint(), seg_deep_copy.getEndPoint()}};
479 GeoLib::AABB aabb(pnts.cbegin(), pnts.cend());
480
481 // TODO TF: remove after getElementsInVolume interface change
482 auto convert_to_Point3d = [](Eigen::Vector3d const& v) {
483 return MathLib::Point3d{std::array{v[0], v[1], v[2]}};
484 };
485
486 auto const min = convert_to_Point3d(aabb.getMinPoint());
487 auto const max = convert_to_Point3d(aabb.getMaxPoint());
488 auto candidate_elements = mesh_element_grid.getElementsInVolume(min, max);
489
490 // make candidate elements unique
491 BaseLib::makeVectorUnique(candidate_elements);
492
493 return candidate_elements;
494}
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition AABB.h:56
void makeVectorUnique(std::vector< T > &v)
Definition Algorithm.h:175

References GeoLib::LineSegment::getBeginPoint(), getCandidateElementsForLineSegmentIntersection(), MeshLib::MeshElementGrid::getElementsInVolume(), GeoLib::LineSegment::getEndPoint(), GeoLib::AABB::getMaxPoint(), MeshLib::MeshElementGrid::getMaxPoint(), GeoLib::AABB::getMinPoint(), MeshLib::MeshElementGrid::getMinPoint(), and BaseLib::makeVectorUnique().

Referenced by getCandidateElementsForLineSegmentIntersection(), and mapPolylineOnSurfaceMesh().

◆ getMeshNodeIDs()

template<typename CacheType , typename GeometryType >
std::vector< std::size_t > const & MeshGeoToolsLib::getMeshNodeIDs ( std::vector< CacheType * > & cached_elements,
std::function< GeometryType(CacheType const &)> getCachedItem,
GeometryType const & item,
MeshLib::Mesh const & mesh,
GeoLib::Grid< MeshLib::Node > const & mesh_grid,
double const search_length,
SearchAllNodes const search_all_nodes )

Definition at line 64 of file MeshNodeSearcher.cpp.

70{
71 if (auto const it = find_if(cbegin(cached_elements), cend(cached_elements),
72 [&](auto const& element)
73 { return getCachedItem(*element) == item; });
74 it != cend(cached_elements))
75 {
76 return (*it)->getNodeIDs();
77 }
78 // search IDs for geometry object
79 if constexpr (std::is_convertible<GeometryType, GeoLib::Point>::value)
80 {
81 cached_elements.push_back(new CacheType(
82 mesh, mesh_grid, item, search_length, search_all_nodes));
83 }
84 else
85 {
86 cached_elements.push_back(
87 new CacheType(mesh, item, search_length, search_all_nodes));
88 }
89 return cached_elements.back()->getNodeIDs();
90}

Referenced by MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeIDs().

◆ identifySubdomainMesh()

void MeshGeoToolsLib::identifySubdomainMesh ( MeshLib::Mesh & subdomain_mesh,
MeshLib::Mesh const & bulk_mesh,
MeshNodeSearcher const & mesh_node_searcher,
bool const force_overwrite = false )

Geometrically finds nodes and elements of the subdomain mesh in the bulk mesh, and updates or verifies the corresponding bulk_node_ids and bulk_element_ids properties.

In case of unexpected results OGS_FATAL is called.

Definition at line 192 of file IdentifySubdomainMesh.cpp.

196{
197 BaseLib::RunTime time;
198 time.start();
199 auto const& bulk_node_ids =
200 identifySubdomainMeshNodes(subdomain_mesh, mesh_node_searcher);
201 INFO("identifySubdomainMesh(): identifySubdomainMeshNodes took {:g} s",
202 time.elapsed());
203
206 bulk_node_ids, MeshLib::MeshItemType::Node, force_overwrite);
207
208 time.start();
209 auto const& bulk_element_ids =
210 identifySubdomainMeshElements(subdomain_mesh, bulk_mesh);
211 INFO("identifySubdomainMesh(): identifySubdomainMeshElements took {:g} s",
212 time.elapsed());
213
214 // The bulk_element_ids could be of two types: one element per entry---this
215 // is the expected case for the boundary meshes; multiple elements per
216 // entry---this happens if the subdomain mesh lies inside the bulk mesh and
217 // has lower dimension.
218 // First find out the type, then add/check the CellData or FieldData.
219 if (all_of(begin(bulk_element_ids), end(bulk_element_ids),
220 [](std::vector<std::size_t> const& v) { return v.size() == 1; }))
221 {
222 // All vectors are of size 1, so the data can be flattened and
223 // stored in CellData or compared to existing CellData.
224 std::vector<std::size_t> unique_bulk_element_ids;
225 unique_bulk_element_ids.reserve(bulk_element_ids.size());
226 transform(begin(bulk_element_ids), end(bulk_element_ids),
227 back_inserter(unique_bulk_element_ids),
228 [](std::vector<std::size_t> const& v) { return v[0]; });
229
231 subdomain_mesh,
233 unique_bulk_element_ids, MeshLib::MeshItemType::Cell,
234 force_overwrite);
235 }
236 else
237 {
238 // Some of the boundary elements are connected to multiple bulk
239 // elements; Store the array in FieldData with additional CellData array
240 // for the number of elements, which also provides the offsets.
241 std::vector<std::size_t> flat_bulk_element_ids;
242 flat_bulk_element_ids.reserve(2 * bulk_element_ids.size()); // Guess.
243 std::vector<std::size_t> number_of_bulk_element_ids;
244 number_of_bulk_element_ids.reserve(bulk_element_ids.size());
245
246 for (std::vector<std::size_t> const& v : bulk_element_ids)
247 {
248 number_of_bulk_element_ids.push_back(v.size());
249 flat_bulk_element_ids.insert(end(flat_bulk_element_ids), begin(v),
250 end(v));
251 }
252
254 subdomain_mesh, "number_bulk_elements", number_of_bulk_element_ids,
255 MeshLib::MeshItemType::Cell, force_overwrite);
257 subdomain_mesh,
259 flat_bulk_element_ids, MeshLib::MeshItemType::IntegrationPoint,
260 force_overwrite);
261 }
262}
Count the running time.
Definition RunTime.h:29
double elapsed() const
Get the elapsed time in seconds.
Definition RunTime.h:42
void start()
Start the timer.
Definition RunTime.h:32
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
Definition Properties.h:188
std::vector< std::size_t > identifySubdomainMeshNodes(MeshLib::Mesh const &subdomain_mesh, MeshGeoToolsLib::MeshNodeSearcher const &mesh_node_searcher)
void updateOrCheckExistingSubdomainProperty(MeshLib::Mesh &mesh, std::string_view property_name, std::vector< std::size_t > const &values, MeshLib::MeshItemType const mesh_item_type, bool const force_overwrite)
Updates or checks the existing mesh's property with the given values.
std::vector< std::vector< std::size_t > > identifySubdomainMeshElements(MeshLib::Mesh const &subdomain_mesh, MeshLib::Mesh const &bulk_mesh)

References MeshLib::Cell, BaseLib::RunTime::elapsed(), MeshLib::getBulkIDString(), INFO(), MeshLib::IntegrationPoint, MeshLib::Node, and BaseLib::RunTime::start().

◆ insertSubSegments()

static void MeshGeoToolsLib::insertSubSegments ( GeoLib::Polyline & ply,
GeoLib::PointVec & points,
GeoLib::Polyline::SegmentIterator & segment_it,
std::vector< GeoLib::LineSegment > const & sub_segments )
static

Definition at line 525 of file GeoMapper.cpp.

529{
530 std::size_t const j(segment_it.getSegmentNumber());
531 std::size_t new_pnts_cnt(0);
532 for (auto const& segment : sub_segments)
533 {
534 auto const begin_id(points.push_back(
535 new GeoLib::Point(segment.getBeginPoint(), points.size())));
536 if (ply.insertPoint(j + new_pnts_cnt + 1, begin_id))
537 {
538 new_pnts_cnt++;
539 }
540 auto const end_id(points.push_back(
541 new GeoLib::Point(segment.getEndPoint(), points.size())));
542 if (ply.insertPoint(j + new_pnts_cnt + 1, end_id))
543 {
544 new_pnts_cnt++;
545 }
546 }
547 segment_it += new_pnts_cnt;
548}
std::size_t push_back(Point *pnt)
Definition PointVec.cpp:133
std::size_t getSegmentNumber() const
Definition Polyline.cpp:387
virtual bool insertPoint(std::size_t pos, std::size_t pnt_id)
Definition Polyline.cpp:55

References GeoLib::Polyline::SegmentIterator::getSegmentNumber(), GeoLib::Polyline::insertPoint(), insertSubSegments(), GeoLib::PointVec::push_back(), and GeoLib::TemplateVec< T >::size().

Referenced by insertSubSegments(), and mapPolylineOnSurfaceMesh().

◆ mapLineSegment()

static std::vector< GeoLib::LineSegment > MeshGeoToolsLib::mapLineSegment ( GeoLib::LineSegment const & segment,
std::vector< MeshLib::Element const * > const & surface_elements,
MeshLib::Element const *const beg_elem,
MeshLib::Element const *const end_elem )
static

Definition at line 383 of file GeoMapper.cpp.

388{
389 std::vector<GeoLib::LineSegment> sub_segments;
390 MathLib::Point3d const& beg_pnt(segment.getBeginPoint());
391 MathLib::Point3d const& end_pnt(segment.getEndPoint());
392
393 for (auto const elem : surface_elements)
394 {
395 // compute element-segment-intersections (2d in x-y-plane)
396 std::vector<MathLib::Point3d> element_intersections(
397 computeElementSegmentIntersections(*elem, segment));
398 if (element_intersections.empty())
399 {
400 continue;
401 }
402
403 BaseLib::makeVectorUnique(element_intersections);
404
405 std::vector<GeoLib::LineSegment> sub_seg_elem(
406 createSubSegmentsForElement(element_intersections, beg_elem,
407 end_elem, beg_pnt, end_pnt, elem));
408 sub_segments.insert(sub_segments.end(), sub_seg_elem.begin(),
409 sub_seg_elem.end());
410 }
411
412 // beg_elem == nullptr means there isn't any element corresponding to the
413 // beg_pnt and as a consequence the above algorithm doesn't insert a sub
414 // segment
415 if (beg_elem == nullptr)
416 {
417 auto min_dist_segment = std::min_element(
418 sub_segments.begin(), sub_segments.end(),
419 [&beg_pnt](GeoLib::LineSegment const& seg0,
420 GeoLib::LineSegment const& seg1)
421 {
422 // min dist for segment 0
423 const double d0(
424 std::min(MathLib::sqrDist(beg_pnt, seg0.getBeginPoint()),
425 MathLib::sqrDist(beg_pnt, seg0.getEndPoint())));
426 // min dist for segment 1
427 const double d1(
428 std::min(MathLib::sqrDist(beg_pnt, seg1.getBeginPoint()),
429 MathLib::sqrDist(beg_pnt, seg1.getEndPoint())));
430 return d0 < d1;
431 });
432 GeoLib::Point* pnt{
433 MathLib::sqrDist(beg_pnt, min_dist_segment->getBeginPoint()) <
434 MathLib::sqrDist(beg_pnt, min_dist_segment->getEndPoint())
435 ? new GeoLib::Point{min_dist_segment->getBeginPoint()}
436 : new GeoLib::Point{min_dist_segment->getEndPoint()}};
437 sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0}, pnt, true);
438 }
439 // sort all sub segments for the given segment (beg_pnt, end_pnt)
440 GeoLib::sortSegments(beg_pnt, sub_segments);
441
442 sub_segments.erase(std::unique(sub_segments.begin(), sub_segments.end()),
443 sub_segments.end());
444
445 return sub_segments;
446}
void sortSegments(MathLib::Point3d const &seg_beg_pnt, std::vector< GeoLib::LineSegment > &sub_segments)
static std::vector< MathLib::Point3d > computeElementSegmentIntersections(MeshLib::Element const &elem, GeoLib::LineSegment const &segment)

References computeElementSegmentIntersections(), createSubSegmentsForElement(), GeoLib::LineSegment::getBeginPoint(), GeoLib::LineSegment::getEndPoint(), BaseLib::makeVectorUnique(), mapLineSegment(), GeoLib::sortSegments(), and MathLib::sqrDist().

Referenced by mapLineSegment(), and mapPolylineOnSurfaceMesh().

◆ mapPointOnSurfaceElement()

static void MeshGeoToolsLib::mapPointOnSurfaceElement ( MeshLib::Element const & elem,
MathLib::Point3d & q )
static

Definition at line 448 of file GeoMapper.cpp.

450{
451 // create plane equation: n*p = d
452 auto const& p = elem.getNode(0)->asEigenVector3d();
453 Eigen::Vector3d const n(MeshLib::FaceRule::getSurfaceNormal(elem));
454 if (n[2] == 0.0)
455 { // vertical plane, z coordinate is arbitrary
456 q[2] = p[2];
457 }
458 else
459 {
460 double const d(n.dot(p));
461 q[2] = (d - n[0] * q[0] - n[1] * q[1]) / n[2];
462 }
463}
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:40

References MathLib::Point3d::asEigenVector3d(), MeshLib::Element::getNode(), MeshLib::FaceRule::getSurfaceNormal(), and mapPointOnSurfaceElement().

Referenced by mapPointOnSurfaceElement(), and mapPolylineOnSurfaceMesh().

◆ mapPolylineOnSurfaceMesh()

static void MeshGeoToolsLib::mapPolylineOnSurfaceMesh ( GeoLib::Polyline & ply,
GeoLib::PointVec & orig_points,
MeshLib::MeshElementGrid const & mesh_element_grid )
static

Definition at line 550 of file GeoMapper.cpp.

554{
555 // for each segment ...
556 for (auto segment_it(ply.begin()); segment_it != ply.end(); ++segment_it)
557 {
559 mesh_element_grid, *segment_it));
560
561 auto mapPoint = [&candidate_elements](MathLib::Point3d& p)
562 {
563 auto const* elem(
564 findElementContainingPointXY(candidate_elements, p));
565 if (elem)
566 {
567 if (!snapPointToElementNode(p, *elem, 1e-3))
568 {
569 mapPointOnSurfaceElement(*elem, p);
570 }
571 }
572 return elem;
573 };
574
575 // map segment begin and end point
576 auto const* beg_elem(mapPoint((*segment_it).getBeginPoint()));
577 auto const* end_elem(mapPoint((*segment_it).getEndPoint()));
578
579 // Since the mapping of the segment begin and end points the coordinates
580 // changed. The internal data structures of PointVec are possibly
581 // invalid and hence it is necessary to re-create them.
582 orig_points.resetInternalDataStructures();
583
584 if (beg_elem == end_elem)
585 {
586 // TODO: handle cases: beg_elem == end_elem == nullptr
587 // There are further checks necessary to determine which case we are
588 // in:
589 // 1. beg_elem == end_elem and the segment intersects elements
590 // 2. beg_elem == end_elem and the segment does not intersect any
591 // element, i.e., the segment is located outside of the mesh area
592 //
593 // Case 1 needs additional work.
594 continue;
595 }
596
597 // map the line segment (and if necessary for the mapping partition it)
598 std::vector<GeoLib::LineSegment> sub_segments(mapLineSegment(
599 *segment_it, candidate_elements, beg_elem, end_elem));
600
601 if (sub_segments.empty())
602 {
603 continue;
604 }
605
606 // The case sub_segment.size() == 1 is already handled above.
607
608 if (sub_segments.size() > 1)
609 {
610 insertSubSegments(ply, orig_points, segment_it, sub_segments);
611 }
612 }
613}
void resetInternalDataStructures()
Definition PointVec.cpp:259
SegmentIterator begin() const
Definition Polyline.h:188
SegmentIterator end() const
Definition Polyline.h:190
static bool snapPointToElementNode(MathLib::Point3d &p, MeshLib::Element const &elem, double rel_eps)
static void insertSubSegments(GeoLib::Polyline &ply, GeoLib::PointVec &points, GeoLib::Polyline::SegmentIterator &segment_it, std::vector< GeoLib::LineSegment > const &sub_segments)
static void mapPointOnSurfaceElement(MeshLib::Element const &elem, MathLib::Point3d &q)
static std::vector< MeshLib::Element const * > getCandidateElementsForLineSegmentIntersection(MeshLib::MeshElementGrid const &mesh_element_grid, GeoLib::LineSegment const &segment)
static MeshLib::Element const * findElementContainingPointXY(std::vector< MeshLib::Element const * > const &elements, MathLib::Point3d const &p)
static std::vector< GeoLib::LineSegment > mapLineSegment(GeoLib::LineSegment const &segment, std::vector< MeshLib::Element const * > const &surface_elements, MeshLib::Element const *const beg_elem, MeshLib::Element const *const end_elem)

References GeoLib::Polyline::begin(), GeoLib::Polyline::end(), findElementContainingPointXY(), getCandidateElementsForLineSegmentIntersection(), insertSubSegments(), mapLineSegment(), mapPointOnSurfaceElement(), mapPolylineOnSurfaceMesh(), GeoLib::PointVec::resetInternalDataStructures(), and snapPointToElementNode().

Referenced by MeshGeoToolsLib::GeoMapper::advancedMapOnMesh(), and mapPolylineOnSurfaceMesh().

◆ markNodesOutSideOfPolygon()

std::vector< bool > MeshGeoToolsLib::markNodesOutSideOfPolygon ( std::vector< MeshLib::Node * > const & nodes,
GeoLib::Polygon const & polygon )

Definition at line 23 of file MarkNodesOutsideOfPolygon.h.

25{
26 // *** rotate polygon points to xy-plane
27 auto [rotated_polygon_points, normal] =
29
30 // *** rotate mesh nodes to xy-plane
31 // 1 copy all mesh nodes to GeoLib::Points
32 std::vector<GeoLib::Point*> rotated_nodes;
33 for (auto node : nodes)
34 {
35 rotated_nodes.push_back(new GeoLib::Point(*node, node->getID()));
36 }
37 // 2 rotate the Points
38 Eigen::Matrix3d const rot_mat = GeoLib::computeRotationMatrixToXY(normal);
39 GeoLib::rotatePoints(rot_mat, rotated_nodes);
40 // 3 set z coord to zero
41 std::for_each(rotated_nodes.begin(), rotated_nodes.end(),
42 [](GeoLib::Point* p) { (*p)[2] = 0.0; });
43
44 std::vector<bool> outside(rotated_nodes.size(), true);
45 // *** mark rotated nodes inside rotated polygon
46 {
47 // create new polygon using the rotated points
48 GeoLib::Polyline rotated_polyline(rotated_polygon_points);
49 for (std::size_t k(0); k < polygon.getNumberOfPoints(); k++)
50 {
51 rotated_polyline.addPoint(k);
52 }
53 rotated_polyline.addPoint(0);
54 GeoLib::Polygon const rotated_polygon(rotated_polyline);
55
56 for (std::size_t k(0); k < rotated_nodes.size(); k++)
57 {
58 if (rotated_polygon.isPntInPolygon(*(rotated_nodes[k])))
59 {
60 outside[k] = false;
61 }
62 }
63 }
64
65 for (auto& rotated_node : rotated_nodes)
66 {
67 delete rotated_node;
68 }
69
70 for (auto& rot_polygon_pnt : rotated_polygon_points)
71 {
72 delete rot_polygon_pnt;
73 }
74
75 return outside;
76}
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:40
void rotatePoints(Eigen::Matrix3d const &rot_mat, InputIterator pnts_begin, InputIterator pnts_end)
std::tuple< std::vector< GeoLib::Point * >, Eigen::Vector3d > rotatePolygonPointsToXY(GeoLib::Polygon const &polygon_in)
Eigen::Matrix3d computeRotationMatrixToXY(Eigen::Vector3d const &n)

References GeoLib::Polyline::addPoint(), GeoLib::computeRotationMatrixToXY(), GeoLib::Polyline::getNumberOfPoints(), GeoLib::Polygon::isPntInPolygon(), GeoLib::rotatePoints(), and GeoLib::rotatePolygonPointsToXY().

Referenced by resetMeshElementProperty().

◆ meshNameFromGeometry()

std::string MeshGeoToolsLib::meshNameFromGeometry ( std::string const & geometrical_set_name,
std::string const & geometry_name )

Definition at line 30 of file ConstructMeshesFromGeometries.cpp.

32{
33 return geometrical_set_name + "_" + geometry_name;
34}

Referenced by constructAdditionalMeshesFromGeometries(), and anonymous_namespace{ProcessVariable.cpp}::findMeshInConfig().

◆ resetMeshElementProperty()

template<typename PT >
void MeshGeoToolsLib::resetMeshElementProperty ( MeshLib::Mesh & mesh,
GeoLib::Polygon const & polygon,
std::string const & property_name,
PT new_property_value,
int restrict_to_material_id,
bool const any_of )

Definition at line 30 of file ResetMeshElementProperty.h.

36{
37 auto* const pv = MeshLib::getOrCreateMeshProperty<PT>(
38 mesh, property_name, MeshLib::MeshItemType::Cell, 1);
39
40 if (pv->getMeshItemType() != MeshLib::MeshItemType::Cell)
41 {
42 ERR("Values of the PropertyVector are not assigned to cells.");
43 return;
44 }
45
46 auto const outside = markNodesOutSideOfPolygon(mesh.getNodes(), polygon);
47
48 auto is_node_outside = [&outside](auto const* node_ptr)
49 { return outside[node_ptr->getID()]; };
50
51 auto const* material_ids =
52 mesh.getProperties().getPropertyVector<int>("MaterialIDs");
53
54 if (restrict_to_material_id != -1 && !material_ids)
55 {
57 "Restriction of resetting a property in a polygonal region "
58 "requires that a MaterialIDs data array is available in the "
59 "mesh.");
60 }
61
62 auto has_element_required_material_id = [&](int const element_id)
63 {
64 return restrict_to_material_id == -1 ||
65 (*material_ids)[element_id] == restrict_to_material_id;
66 };
67
68 using func =
69 std::function<bool(MeshLib::Node* const*, MeshLib::Node* const*,
70 decltype(is_node_outside))>;
71 auto is_element_outside =
72 any_of ? (func)(std::all_of<MeshLib::Node* const*,
73 decltype(is_node_outside)>)
74 : (func)(std::any_of<MeshLib::Node* const*,
75 decltype(is_node_outside)>);
76
77 for (std::size_t j(0); j < mesh.getElements().size(); ++j)
78 {
79 MeshLib::Element const* const elem(mesh.getElements()[j]);
80 if (is_element_outside(elem->getNodes(),
81 elem->getNodes() + elem->getNumberOfNodes(),
82 is_node_outside))
83 {
84 continue;
85 }
86 if (has_element_required_material_id(elem->getID()))
87 {
88 (*pv)[j] = new_property_value;
89 }
90 }
91}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
Properties & getProperties()
Definition Mesh.h:134
PropertyVector< T > const * getPropertyVector(std::string_view name) const
constexpr bool any_of(List const &values)
Checks if any of the elements in the given list is true.
Definition Algorithm.h:276
constexpr int size(int const displacement_dim)
Vectorized tensor size for given displacement dimension.

References MeshLib::Cell, ERR(), MeshLib::Mesh::getElements(), MeshLib::Element::getID(), MeshLib::Mesh::getNodes(), MeshLib::Element::getNodes(), MeshLib::Element::getNumberOfNodes(), MeshLib::Mesh::getProperties(), MeshLib::Properties::getPropertyVector(), markNodesOutSideOfPolygon(), and OGS_FATAL.

Referenced by main().

◆ snapPointToElementNode()

static bool MeshGeoToolsLib::snapPointToElementNode ( MathLib::Point3d & p,
MeshLib::Element const & elem,
double rel_eps )
static

Definition at line 496 of file GeoMapper.cpp.

498{
499 // values will be initialized within computeSqrNodeDistanceRange
500 auto const [sqr_min, sqr_max] = MeshLib::computeSqrNodeDistanceRange(elem);
501
502 double const sqr_eps(rel_eps * rel_eps * sqr_min);
503 for (std::size_t k(0); k < elem.getNumberOfNodes(); ++k)
504 {
505 auto const& node(*elem.getNode(k));
506 double const sqr_dist_2d(MathLib::sqrDist2d(p, node));
507 if (sqr_dist_2d < sqr_eps)
508 {
509#ifdef DEBUG_GEOMAPPER
510 std::stringstream out;
511 out.precision(std::numeric_limits<double>::digits10);
512 out << "Segment point snapped from " << p;
513#endif
514 p = node;
515#ifdef DEBUG_GEOMAPPER
516 out << "to " << p;
517 DBUG("{:s}", out.str());
518#endif
519 return true;
520 }
521 }
522 return false;
523}
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.h:122
std::pair< double, double > computeSqrNodeDistanceRange(MeshLib::Element const &element, bool const check_allnodes)
Compute the minimum and maximum node distances for this element.
Definition Element.cpp:136

References MeshLib::computeSqrNodeDistanceRange(), DBUG(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfNodes(), snapPointToElementNode(), and MathLib::sqrDist2d().

Referenced by mapPolylineOnSurfaceMesh(), and snapPointToElementNode().