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 8 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 23 of file AppendLinesAlongPolyline.cpp.

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

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

Definition at line 285 of file GeoMapper.cpp.

287{
288 std::vector<MathLib::Point3d> element_intersections;
289 for (std::size_t k(0); k < elem.getNumberOfEdges(); ++k)
290 {
291 auto const edge =
292 std::unique_ptr<MeshLib::Element const>(elem.getEdge(k));
293 GeoLib::LineSegment elem_segment{
294 new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
295 const_cast<MeshLib::Node*>(edge->getNode(0))),
296 0),
297 new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
298 const_cast<MeshLib::Node*>(edge->getNode(1))),
299 0),
300 true};
301 std::vector<MathLib::Point3d> const intersections(
302 GeoLib::lineSegmentIntersect2d(segment, elem_segment));
303 element_intersections.insert(end(element_intersections),
304 begin(intersections), end(intersections));
305 }
306 return element_intersections;
307}
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 32 of file ConstructMeshesFromGeometries.cpp.

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

97{
98 std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
99
100 auto const& mesh_node_searcher =
102 mesh, std::move(search_length_algorithm));
103
104 MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(
105 mesh, mesh_node_searcher);
106
107 //
108 // Points
109 //
110 {
111 auto point_meshes = constructAdditionalMeshesFromGeometries(
112 geo_objects.getPoints(), boundary_element_searcher,
113 multiple_nodes_allowed);
114 std::move(begin(point_meshes), end(point_meshes),
115 std::back_inserter(additional_meshes));
116 }
117
118 //
119 // Polylines
120 //
121 {
122 auto polyline_meshes = constructAdditionalMeshesFromGeometries(
123 geo_objects.getPolylines(), boundary_element_searcher,
124 multiple_nodes_allowed);
125 std::move(begin(polyline_meshes), end(polyline_meshes),
126 std::back_inserter(additional_meshes));
127 }
128
129 // Surfaces
130 {
131 auto surface_meshes = constructAdditionalMeshesFromGeometries(
132 geo_objects.getSurfaces(), boundary_element_searcher,
133 multiple_nodes_allowed);
134 std::move(begin(surface_meshes), end(surface_meshes),
135 std::back_inserter(additional_meshes));
136 }
137
138 // Set axial symmetry for the additional meshes to the same value as the
139 // "bulk" mesh.
140 std::for_each(begin(additional_meshes), end(additional_meshes),
141 [axial_symmetry = mesh.isAxiallySymmetric()](auto& m)
142 { m->setAxiallySymmetric(axial_symmetry); });
143 return additional_meshes;
144}
static OGS_NO_DANGLING 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 13 of file CreateSearchLength.cpp.

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

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

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

◆ createSubSegmentsForElement()

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 309 of file GeoMapper.cpp.

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

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

Referenced by createSubSegmentsForElement(), and mapLineSegment().

◆ findElementContainingPointXY()

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 250 of file GeoMapper.cpp.

253{
254 for (auto const elem : elements)
255 {
256 std::unique_ptr<MeshLib::Element> elem_2d(elem->clone());
257 // reset/copy the nodes
258 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
259 {
260 elem_2d->setNode(k, new MeshLib::Node(*elem_2d->getNode(k)));
261 }
262 // project to xy
263 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
264 {
265 (*const_cast<MeshLib::Node*>(elem_2d->getNode(k)))[2] = 0.0;
266 }
267 if (elem_2d->isPntInElement(MathLib::Point3d{{{p[0], p[1], 0.0}}}))
268 {
269 // clean up the copied nodes
270 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
271 {
272 delete elem_2d->getNode(k);
273 }
274 return elem;
275 }
276 // clean up the copied nodes
277 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
278 {
279 delete elem_2d->getNode(k);
280 }
281 }
282 return nullptr;
283}

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 43 of file BoundaryElementsSearcher.cpp.

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

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

◆ getCandidateElementsForLineSegmentIntersection()

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

Definition at line 455 of file GeoMapper.cpp.

458{
459 GeoLib::LineSegment seg_deep_copy(
460 new GeoLib::Point(segment.getBeginPoint()),
461 new GeoLib::Point(segment.getEndPoint()), true);
462 // modify z coordinates such that all surface elements around the line
463 // segment are found
464 seg_deep_copy.getBeginPoint()[2] = mesh_element_grid.getMinPoint()[2];
465 seg_deep_copy.getEndPoint()[2] = mesh_element_grid.getMaxPoint()[2];
466 std::array<MathLib::Point3d, 2> const pnts{
467 {seg_deep_copy.getBeginPoint(), seg_deep_copy.getEndPoint()}};
468 GeoLib::AABB aabb(pnts.cbegin(), pnts.cend());
469
470 // TODO TF: remove after getElementsInVolume interface change
471 auto convert_to_Point3d = [](Eigen::Vector3d const& v) {
472 return MathLib::Point3d{std::array{v[0], v[1], v[2]}};
473 };
474
475 auto const min = convert_to_Point3d(aabb.getMinPoint());
476 auto const max = convert_to_Point3d(aabb.getMaxPoint());
477 auto candidate_elements = mesh_element_grid.getElementsInVolume(min, max);
478
479 // make candidate elements unique
480 BaseLib::makeVectorUnique(candidate_elements);
481
482 return candidate_elements;
483}
void makeVectorUnique(std::vector< T > &v)
Definition Algorithm.h:173

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 56 of file MeshNodeSearcher.cpp.

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

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 191 of file IdentifySubdomainMesh.cpp.

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

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

◆ insertSubSegments()

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 514 of file GeoMapper.cpp.

518{
519 std::size_t const j(segment_it.getSegmentNumber());
520 std::size_t new_pnts_cnt(0);
521 for (auto const& segment : sub_segments)
522 {
523 auto const begin_id(points.push_back(
524 new GeoLib::Point(segment.getBeginPoint(), points.size())));
525 if (ply.insertPoint(j + new_pnts_cnt + 1, begin_id))
526 {
527 new_pnts_cnt++;
528 }
529 auto const end_id(points.push_back(
530 new GeoLib::Point(segment.getEndPoint(), points.size())));
531 if (ply.insertPoint(j + new_pnts_cnt + 1, end_id))
532 {
533 new_pnts_cnt++;
534 }
535 }
536 segment_it += new_pnts_cnt;
537}
std::size_t push_back(Point *pnt)
Definition PointVec.cpp:124
std::size_t getSegmentNumber() const
Definition Polyline.cpp:376
virtual bool insertPoint(std::size_t pos, std::size_t pnt_id)
Definition Polyline.cpp:44

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

Referenced by insertSubSegments(), and mapPolylineOnSurfaceMesh().

◆ mapLineSegment()

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 372 of file GeoMapper.cpp.

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

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

Definition at line 437 of file GeoMapper.cpp.

439{
440 // create plane equation: n*p = d
441 auto const& p = elem.getNode(0)->asEigenVector3d();
442 Eigen::Vector3d const n(MeshLib::FaceRule::getSurfaceNormal(elem));
443 if (n[2] == 0.0)
444 { // vertical plane, z coordinate is arbitrary
445 q[2] = p[2];
446 }
447 else
448 {
449 double const d(n.dot(p));
450 q[2] = (d - n[0] * q[0] - n[1] * q[1]) / n[2];
451 }
452}
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:33

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

Referenced by mapPointOnSurfaceElement(), and mapPolylineOnSurfaceMesh().

◆ mapPolylineOnSurfaceMesh()

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

Definition at line 539 of file GeoMapper.cpp.

543{
544 // for each segment ...
545 for (auto segment_it(ply.begin()); segment_it != ply.end(); ++segment_it)
546 {
548 mesh_element_grid, *segment_it));
549
550 auto mapPoint = [&candidate_elements](MathLib::Point3d& p)
551 {
552 auto const* elem(
553 findElementContainingPointXY(candidate_elements, p));
554 if (elem)
555 {
556 if (!snapPointToElementNode(p, *elem, 1e-3))
557 {
558 mapPointOnSurfaceElement(*elem, p);
559 }
560 }
561 return elem;
562 };
563
564 // map segment begin and end point
565 auto const* beg_elem(mapPoint((*segment_it).getBeginPoint()));
566 auto const* end_elem(mapPoint((*segment_it).getEndPoint()));
567
568 // Since the mapping of the segment begin and end points the coordinates
569 // changed. The internal data structures of PointVec are possibly
570 // invalid and hence it is necessary to re-create them.
571 orig_points.resetInternalDataStructures();
572
573 if (beg_elem == end_elem)
574 {
575 // TODO: handle cases: beg_elem == end_elem == nullptr
576 // There are further checks necessary to determine which case we are
577 // in:
578 // 1. beg_elem == end_elem and the segment intersects elements
579 // 2. beg_elem == end_elem and the segment does not intersect any
580 // element, i.e., the segment is located outside of the mesh area
581 //
582 // Case 1 needs additional work.
583 continue;
584 }
585
586 // map the line segment (and if necessary for the mapping partition it)
587 std::vector<GeoLib::LineSegment> sub_segments(mapLineSegment(
588 *segment_it, candidate_elements, beg_elem, end_elem));
589
590 if (sub_segments.empty())
591 {
592 continue;
593 }
594
595 // The case sub_segment.size() == 1 is already handled above.
596
597 if (sub_segments.size() > 1)
598 {
599 insertSubSegments(ply, orig_points, segment_it, sub_segments);
600 }
601 }
602}
void resetInternalDataStructures()
Definition PointVec.cpp:250
SegmentIterator begin() const
Definition Polyline.h:177
SegmentIterator end() const
Definition Polyline.h:179
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 16 of file MarkNodesOutsideOfPolygon.h.

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

26{
27 return geometrical_set_name + "_" + geometry_name;
28}

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 26 of file ResetMeshElementProperty.h.

32{
34 mesh, property_name, MeshLib::MeshItemType::Cell, 1);
35
36 if (pv->getMeshItemType() != MeshLib::MeshItemType::Cell)
37 {
38 ERR("Values of the PropertyVector are not assigned to cells.");
39 return;
40 }
41 auto const* material_ids =
42 mesh.getProperties().getPropertyVector<int>("MaterialIDs");
43
44 if (restrict_to_material_id != -1 && !material_ids)
45 {
47 "Restriction of resetting a property in a polygonal region "
48 "requires that a MaterialIDs data array is available in the "
49 "mesh.");
50 }
51
52 auto has_element_required_material_id = [&](int const element_id)
53 {
54 return restrict_to_material_id == -1 ||
55 (*material_ids)[element_id] == restrict_to_material_id;
56 };
57
58 auto const outside = markNodesOutSideOfPolygon(mesh.getNodes(), polygon);
59
60 auto is_node_outside = [&outside](std::size_t const node_id)
61 { return outside[node_id]; };
62
63 auto is_element_outside = [&](MeshLib::Element const& e)
64 {
65 auto ids = e.nodes() | MeshLib::views::ids;
66 return any_of ? ranges::all_of(ids, is_node_outside)
67 : ranges::any_of(ids, is_node_outside);
68 };
69
70 auto is_valid_element = [&](MeshLib::Element const& e)
71 {
72 return !is_element_outside(e) &&
73 has_element_required_material_id(e.getID());
74 };
75
76 auto compute_value = [&](MeshLib::Element const* const e) -> PT
77 { return is_valid_element(*e) ? new_property_value : (*pv)[e->getID()]; };
78
79 pv->assign(mesh.getElements() | ranges::views::transform(compute_value));
80}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
Properties & getProperties()
Definition Mesh.h:125
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:286
std::vector< bool > markNodesOutSideOfPolygon(std::vector< MeshLib::Node * > const &nodes, GeoLib::Polygon const &polygon)
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:216
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)

References MeshLib::Cell, ERR(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getNodes(), MeshLib::getOrCreateMeshProperty(), MeshLib::Mesh::getProperties(), MeshLib::Properties::getPropertyVector(), MeshLib::views::ids, markNodesOutSideOfPolygon(), and OGS_FATAL.

Referenced by main().

◆ snapPointToElementNode()

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

Definition at line 485 of file GeoMapper.cpp.

487{
488 // values will be initialized within computeSqrNodeDistanceRange
489 auto const [sqr_min, sqr_max] = MeshLib::computeSqrNodeDistanceRange(elem);
490
491 double const sqr_eps(rel_eps * rel_eps * sqr_min);
492 for (std::size_t k(0); k < elem.getNumberOfNodes(); ++k)
493 {
494 auto const& node(*elem.getNode(k));
495 double const sqr_dist_2d(MathLib::sqrDist2d(p, node));
496 if (sqr_dist_2d < sqr_eps)
497 {
498#ifdef DEBUG_GEOMAPPER
499 std::stringstream out;
500 out.precision(std::numeric_limits<double>::max_digits10);
501 out << "Segment point snapped from " << p;
502#endif
503 p = node;
504#ifdef DEBUG_GEOMAPPER
505 out << "to " << p;
506 DBUG("{:s}", out.str());
507#endif
508 return true;
509 }
510 }
511 return false;
512}
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.h:114
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:143

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

Referenced by mapPolylineOnSurfaceMesh(), and snapPointToElementNode().