OGS
anonymous_namespace{BoundaryElementsAlongPolyline.cpp} Namespace Reference

Functions

bool includesAllEdgeNodeIDs (std::vector< std::size_t > const &vec_node_ids, MeshLib::Element const &edge, std::vector< std::size_t > &edge_node_distances)
 
MeshLib::ElementmodifyEdgeNodeOrdering (const MeshLib::Element &edge, const GeoLib::Polyline &ply, const std::vector< std::size_t > &edge_node_distances_along_ply, const std::vector< std::size_t > &node_ids_on_poly)
 

Function Documentation

◆ includesAllEdgeNodeIDs()

bool anonymous_namespace{BoundaryElementsAlongPolyline.cpp}::includesAllEdgeNodeIDs ( std::vector< std::size_t > const & vec_node_ids,
MeshLib::Element const & edge,
std::vector< std::size_t > & edge_node_distances )

Check if a vector of node IDs includes all nodes of a given element

Parameters
vec_node_idsa vector of Node IDs
edgeEdge object whose node IDs are checked
edge_node_distancesa vector of distances of the edge nodes from the beginning of the given node ID vector
Returns
true if all element nodes are included in the vector

Definition at line 34 of file BoundaryElementsAlongPolyline.cpp.

37{
38 unsigned j = 0;
39 for (; j < edge.getNumberOfBaseNodes(); j++)
40 {
41 auto itr = std::find(vec_node_ids.begin(), vec_node_ids.end(),
42 getNodeIndex(edge, j));
43 if (itr != vec_node_ids.end())
44 {
45 edge_node_distances.push_back(
46 std::distance(vec_node_ids.begin(), itr));
47 }
48 else
49 {
50 break;
51 }
52 }
53 return j == edge.getNumberOfBaseNodes();
54}

References MeshLib::Element::getNumberOfBaseNodes().

◆ modifyEdgeNodeOrdering()

MeshLib::Element * anonymous_namespace{BoundaryElementsAlongPolyline.cpp}::modifyEdgeNodeOrdering ( const MeshLib::Element & edge,
const GeoLib::Polyline & ply,
const std::vector< std::size_t > & edge_node_distances_along_ply,
const std::vector< std::size_t > & node_ids_on_poly )

Modify node ordering of an edge so that its first node is closer to the beginning of a polyline than others

Parameters
edgeElement object
plyPolyline object
edge_node_distances_along_plyA vector of current edge node distances along poly
node_ids_on_polyA vector of node IDs along the polyine
Returns
A pointer to the new modified edge object. A pointer to the original edge is returned if the modification is unnecessary.

Definition at line 67 of file BoundaryElementsAlongPolyline.cpp.

71{
72 // The first node of the edge should be always closer to the beginning of
73 // the polyline than other nodes.
74 if (edge_node_distances_along_ply.front() >
75 edge_node_distances_along_ply.back() ||
76 (ply.isClosed() &&
77 edge_node_distances_along_ply.back() == node_ids_on_poly.size() - 1))
78 { // Create a new element with reversed local node index
79 if (auto const* e = dynamic_cast<MeshLib::Line const*>(&edge))
80 {
81 std::array nodes = {const_cast<MeshLib::Node*>(e->getNode(1)),
82 const_cast<MeshLib::Node*>(e->getNode(0))};
83 return new MeshLib::Line(nodes, e->getID());
84 }
85 if (auto const* e = dynamic_cast<MeshLib::Line3 const*>(&edge))
86 {
87 std::array nodes = {const_cast<MeshLib::Node*>(e->getNode(1)),
88 const_cast<MeshLib::Node*>(e->getNode(0)),
89 const_cast<MeshLib::Node*>(e->getNode(2))};
90 return new MeshLib::Line3(nodes, e->getID());
91 }
92 OGS_FATAL("Not implemented for element type {:s}", typeid(edge).name());
93 }
94
95 // Return the original edge otherwise.
96 return const_cast<MeshLib::Element*>(&edge);
97}
#define OGS_FATAL(...)
Definition Error.h:26
bool isClosed() const
Definition Polyline.cpp:119
TemplateElement< MeshLib::LineRule2 > Line
Definition Line.h:25
TemplateElement< MeshLib::LineRule3 > Line3
Definition Line.h:26

References GeoLib::Polyline::isClosed(), and OGS_FATAL.