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, [[maybe_unused]] 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 MeshGeoToolsLib::SearchAllNodes : bool
strong
Enumerator
Yes 
No 

Definition at line 13 of file SearchAllNodes.h.

14 {
15  Yes = true,
16  No = false
17 };

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  std::vector<int> new_mat_ids;
41  const std::size_t n_ply(ply_vec.size());
42  // for each polyline
43  for (std::size_t k(0); k < n_ply; k++)
44  {
45  const GeoLib::Polyline* ply = (*ply_vec.getVector())[k];
46 
47  // search nodes on the polyline
49  mesh, *ply, mesh.getMinEdgeLength() * 0.5,
51  auto& vec_nodes_on_ply = mshNodesAlongPoly.getNodeIDs();
52  if (vec_nodes_on_ply.empty())
53  {
54  std::string ply_name;
55  ply_vec.getNameOfElementByID(k, ply_name);
56  INFO("No nodes found on polyline {:s}", ply_name);
57  continue;
58  }
59 
60  // add line elements
61  for (std::size_t i = 0; i < vec_nodes_on_ply.size() - 1; i++)
62  {
63  std::array<MeshLib::Node*, 2> element_nodes;
64  element_nodes[0] = vec_new_nodes[vec_nodes_on_ply[i]];
65  element_nodes[1] = vec_new_nodes[vec_nodes_on_ply[i + 1]];
66  vec_new_eles.push_back(
67  new MeshLib::Line(element_nodes, vec_new_eles.size()));
68  new_mat_ids.push_back(max_matID + k + 1);
69  }
70  }
71 
72  // generate a mesh
73  const std::string name = mesh.getName() + "_with_lines";
74  auto new_mesh =
75  std::make_unique<MeshLib::Mesh>(name, vec_new_nodes, vec_new_eles);
76  auto new_material_ids =
77  new_mesh->getProperties().createNewPropertyVector<int>(
78  "MaterialIDs", MeshLib::MeshItemType::Cell);
79  if (!new_material_ids)
80  {
81  OGS_FATAL("Could not create MaterialIDs cell vector in new mesh.");
82  }
83  new_material_ids->reserve(new_mesh->getNumberOfElements());
84  if (material_ids != nullptr)
85  {
86  std::copy(begin(*material_ids), end(*material_ids),
87  std::back_inserter(*new_material_ids));
88  }
89  else
90  {
91  new_material_ids->resize(mesh.getNumberOfElements());
92  }
93  std::copy(begin(new_mat_ids), end(new_mat_ids),
94  std::back_inserter(*new_material_ids));
95  return new_mesh;
96 }
#define OGS_FATAL(...)
Definition: Error.h:26
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition: Polyline.h:51
const std::vector< T * > * getVector() const
Definition: TemplateVec.h:112
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
Definition: TemplateVec.h:153
std::size_t size() const
Definition: TemplateVec.h:106
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:95
double getMinEdgeLength() const
Get the minimum edge length over all elements of the mesh.
Definition: Mesh.h:80
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:92
std::size_t getNumberOfElements() const
Get the number of elements.
Definition: Mesh.h:86
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37
std::vector< Node * > copyNodeVector(const std::vector< Node * > &nodes)
Creates a deep copy of a Node vector.
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
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, MathLib::LinAlg::copy(), MeshLib::copyElementVector(), MeshLib::copyNodeVector(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getMinEdgeLength(), MeshLib::Mesh::getName(), GeoLib::TemplateVec< T >::getNameOfElementByID(), MeshGeoToolsLib::MeshNodesAlongPolyline::getNodeIDs(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfElements(), GeoLib::TemplateVec< T >::getVector(), INFO(), MeshLib::materialIDs(), MaterialPropertyLib::name, 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 297 of file GeoMapper.cpp.

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

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

Referenced by 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 30 of file ConstructMeshesFromGeometries.cpp.

34 {
35  std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
36 
37  for (GeometryVec* const geometry_vec : geometries)
38  {
39  // Each geometry_vec has a name, this is the first part of the full
40  // name.
41  auto const& vec_name = geometry_vec->getName();
42 
43  auto const& vec_data = *geometry_vec->getVector();
44 
45  auto const vec_size = geometry_vec->size();
46  for (std::size_t i = 0; i < vec_size; ++i)
47  {
48  // Each geometry has a name, this is the second part of the full
49  // name.
50  std::string geometry_name;
51  bool const is_geometry_named =
52  geometry_vec->getNameOfElementByID(i, geometry_name);
53  if (!is_geometry_named)
54  {
55  continue;
56  }
57 
58  auto const& geometry = *vec_data[i];
59 
60  DBUG("Creating mesh from geometry {:s} {:s}.", vec_name,
61  geometry_name);
62 
63  additional_meshes.emplace_back(createMeshFromElementSelection(
64  meshNameFromGeometry(vec_name, geometry_name),
66  boundary_element_searcher.getBoundaryElements(
67  geometry, multiple_nodes_allowed))));
68  }
69  }
70  return additional_meshes;
71 }
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
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::unique_ptr< MeshLib::Mesh > createMeshFromElementSelection(std::string mesh_name, std::vector< MeshLib::Element * > const &elements)
Definition: Mesh.cpp:268
std::vector< Element * > cloneElements(std::vector< Element * > const &elements)
Clones a vector of elements using the Element::clone() function.

References MeshLib::cloneElements(), MeshLib::createMeshFromElementSelection(), DBUG(), MeshGeoToolsLib::BoundaryElementsSearcher::getBoundaryElements(), and meshNameFromGeometry().

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 74 of file ConstructMeshesFromGeometries.cpp.

79 {
80  std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
81 
82  auto const& mesh_node_searcher =
84  mesh, std::move(search_length_algorithm));
85 
86  MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(
87  mesh, mesh_node_searcher);
88 
89  //
90  // Points
91  //
92  {
93  auto point_meshes = constructAdditionalMeshesFromGeometries(
94  geo_objects.getPoints(), boundary_element_searcher,
95  multiple_nodes_allowed);
96  std::move(begin(point_meshes), end(point_meshes),
97  std::back_inserter(additional_meshes));
98  }
99 
100  //
101  // Polylines
102  //
103  {
104  auto polyline_meshes = constructAdditionalMeshesFromGeometries(
105  geo_objects.getPolylines(), boundary_element_searcher,
106  multiple_nodes_allowed);
107  std::move(begin(polyline_meshes), end(polyline_meshes),
108  std::back_inserter(additional_meshes));
109  }
110 
111  // Surfaces
112  {
113  auto surface_meshes = constructAdditionalMeshesFromGeometries(
114  geo_objects.getSurfaces(), boundary_element_searcher,
115  multiple_nodes_allowed);
116  std::move(begin(surface_meshes), end(surface_meshes),
117  std::back_inserter(additional_meshes));
118  }
119 
120  // Set axial symmetry for the additional meshes to the same value as the
121  // "bulk" mesh.
122  std::for_each(begin(additional_meshes), end(additional_meshes),
123  [axial_symmetry = mesh.isAxiallySymmetric()](auto& m)
124  { m->setAxiallySymmetric(axial_symmetry); });
125  return additional_meshes;
126 }
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 main(), and 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 321 of file GeoMapper.cpp.

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

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

Referenced by 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 262 of file GeoMapper.cpp.

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

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,
[[maybe_unused] ] 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 468 of file GeoMapper.cpp.

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

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

Referenced by 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 194 of file IdentifySubdomainMesh.cpp.

198 {
199  auto const& bulk_node_ids =
200  identifySubdomainMeshNodes(subdomain_mesh, mesh_node_searcher);
201 
203  subdomain_mesh, "bulk_node_ids", bulk_node_ids,
204  MeshLib::MeshItemType::Node, force_overwrite);
205 
206  auto const& bulk_element_ids =
207  identifySubdomainMeshElements(subdomain_mesh, bulk_mesh);
208 
209  // The bulk_element_ids could be of two types: one element per entry---this
210  // is the expected case for the boundary meshes; multiple elements per
211  // entry---this happens if the subdomain mesh lies inside the bulk mesh and
212  // has lower dimension.
213  // First find out the type, then add/check the CellData or FieldData.
214  if (all_of(begin(bulk_element_ids), end(bulk_element_ids),
215  [](std::vector<std::size_t> const& v) { return v.size() == 1; }))
216  {
217  // All vectors are of size 1, so the data can be flattened and
218  // stored in CellData or compared to existing CellData.
219  std::vector<std::size_t> unique_bulk_element_ids;
220  unique_bulk_element_ids.reserve(bulk_element_ids.size());
221  transform(begin(bulk_element_ids), end(bulk_element_ids),
222  back_inserter(unique_bulk_element_ids),
223  [](std::vector<std::size_t> const& v) { return v[0]; });
224 
226  subdomain_mesh, "bulk_element_ids", unique_bulk_element_ids,
227  MeshLib::MeshItemType::Cell, force_overwrite);
228  }
229  else
230  {
231  // Some of the boundary elements are connected to multiple bulk
232  // elements; Store the array in FieldData with additional CellData array
233  // for the number of elements, which also provides the offsets.
234  std::vector<std::size_t> flat_bulk_element_ids;
235  flat_bulk_element_ids.reserve(2 * bulk_element_ids.size()); // Guess.
236  std::vector<std::size_t> number_of_bulk_element_ids;
237  number_of_bulk_element_ids.reserve(bulk_element_ids.size());
238 
239  for (std::vector<std::size_t> const& v : bulk_element_ids)
240  {
241  number_of_bulk_element_ids.push_back(v.size());
242  flat_bulk_element_ids.insert(end(flat_bulk_element_ids), begin(v),
243  end(v));
244  }
245 
247  subdomain_mesh, "number_bulk_elements", number_of_bulk_element_ids,
248  MeshLib::MeshItemType::Cell, force_overwrite);
250  subdomain_mesh, "bulk_element_ids", flat_bulk_element_ids,
251  MeshLib::MeshItemType::IntegrationPoint, force_overwrite);
252  }
253 }
std::vector< std::size_t > identifySubdomainMeshNodes(MeshLib::Mesh const &subdomain_mesh, MeshGeoToolsLib::MeshNodeSearcher const &mesh_node_searcher)
std::vector< std::vector< std::size_t > > identifySubdomainMeshElements(MeshLib::Mesh const &subdomain_mesh, MeshLib::Mesh const &bulk_mesh)
void updateOrCheckExistingSubdomainProperty(MeshLib::Mesh &mesh, std::string const &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, anonymous_namespace{IdentifySubdomainMesh.cpp}::identifySubdomainMeshElements(), anonymous_namespace{IdentifySubdomainMesh.cpp}::identifySubdomainMeshNodes(), MeshLib::IntegrationPoint, MeshLib::Node, and anonymous_namespace{IdentifySubdomainMesh.cpp}::updateOrCheckExistingSubdomainProperty().

Referenced by identifyAndWriteBoundaryMeshes(), and main().

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

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

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

Referenced by 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 384 of file GeoMapper.cpp.

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

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

Referenced by mapPolylineOnSurfaceMesh().

◆ mapPointOnSurfaceElement()

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

Definition at line 449 of file GeoMapper.cpp.

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

References MathLib::TemplatePoint< T, DIM >::getCoords(), MeshLib::Element::getNode(), MeshLib::FaceRule::getSurfaceNormal(), MathLib::p, and MathLib::q.

Referenced by mapPolylineOnSurfaceMesh().

◆ mapPolylineOnSurfaceMesh()

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

Definition at line 552 of file GeoMapper.cpp.

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

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

Referenced by MeshGeoToolsLib::GeoMapper::advancedMapOnMesh().

◆ 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 to xy_plane
27  Eigen::Vector3d normal;
28  GeoLib::Polygon rot_polygon(GeoLib::rotatePolygonToXY(polygon, 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  // *** mark rotated nodes
45  std::vector<bool> outside(rotated_nodes.size(), true);
46  for (std::size_t k(0); k < rotated_nodes.size(); k++)
47  {
48  if (rot_polygon.isPntInPolygon(*(rotated_nodes[k])))
49  {
50  outside[k] = false;
51  }
52  }
53 
54  for (auto& rotated_node : rotated_nodes)
55  {
56  delete rotated_node;
57  }
58 
59  std::vector<GeoLib::Point*>& rot_polygon_pnts(
60  const_cast<std::vector<GeoLib::Point*>&>(rot_polygon.getPointsVec()));
61  for (auto& rot_polygon_pnt : rot_polygon_pnts)
62  {
63  delete rot_polygon_pnt;
64  }
65 
66  return outside;
67 }
GeoLib::Polygon rotatePolygonToXY(GeoLib::Polygon const &polygon_in, Eigen::Vector3d &plane_normal)
void rotatePoints(Eigen::Matrix3d const &rot_mat, InputIterator pnts_begin, InputIterator pnts_end)
Eigen::Matrix3d computeRotationMatrixToXY(Eigen::Vector3d const &n)

References GeoLib::computeRotationMatrixToXY(), GeoLib::Polyline::getPointsVec(), GeoLib::Polygon::isPntInPolygon(), GeoLib::rotatePoints(), and GeoLib::rotatePolygonToXY().

Referenced by resetMeshElementProperty().

◆ meshNameFromGeometry()

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

Definition at line 22 of file ConstructMeshesFromGeometries.cpp.

24 {
25  return geometrical_set_name + "_" + geometry_name;
26 }

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

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

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

500 {
501  // values will be initialized within computeSqrNodeDistanceRange
502  auto const [sqr_min, sqr_max] = MeshLib::computeSqrNodeDistanceRange(elem);
503 
504  double const sqr_eps(rel_eps * rel_eps * sqr_min);
505  for (std::size_t k(0); k < elem.getNumberOfNodes(); ++k)
506  {
507  auto const& node(*elem.getNode(k));
508  double const sqr_dist_2d(MathLib::sqrDist2d(p, node));
509  if (sqr_dist_2d < sqr_eps)
510  {
511 #ifdef DEBUG_GEOMAPPER
512  std::stringstream out;
513  out.precision(std::numeric_limits<double>::digits10);
514  out << "Segment point snapped from " << p;
515 #endif
516  p = node;
517 #ifdef DEBUG_GEOMAPPER
518  out << "to " << p;
519  DBUG("{:s}", out.str());
520 #endif
521  return true;
522  }
523  }
524  return false;
525 }
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.h:58
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:142

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

Referenced by mapPolylineOnSurfaceMesh().