OGS
MeshLib::anonymous_namespace{ConvertToLinearMesh.cpp} Namespace Reference

Functions

template<typename T_ELEMENT >
T_ELEMENT * createLinearElement (MeshLib::Element const *e, std::vector< MeshLib::Node * > const &vec_new_nodes)
 

Function Documentation

◆ createLinearElement()

template<typename T_ELEMENT >
T_ELEMENT* MeshLib::anonymous_namespace{ConvertToLinearMesh.cpp}::createLinearElement ( MeshLib::Element const *  e,
std::vector< MeshLib::Node * > const &  vec_new_nodes 
)

Definition at line 31 of file ConvertToLinearMesh.cpp.

33 {
34  auto const n_base_nodes = T_ELEMENT::n_base_nodes;
35  auto** nodes = new MeshLib::Node*[n_base_nodes];
36  for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++)
37  {
38  auto const it = find_if(
39  begin(vec_new_nodes), end(vec_new_nodes),
40  [node_i = e->getNode(i)](Node* const new_node)
41  {
42  return *node_i ==
43  *new_node; // coordinate comparison up to epsilon
44  });
45  if (it == end(vec_new_nodes))
46  {
47  OGS_FATAL(
48  "A base node {:d} (with original global node id {:d}) not "
49  "found in the list for element {:d}.",
50  i, e->getNode(i)->getID(), e->getID());
51  }
52  nodes[i] = const_cast<MeshLib::Node*>(*it);
53  }
54  return new T_ELEMENT(nodes);
55 }
#define OGS_FATAL(...)
Definition: Error.h:26

References MathLib::Point3dWithID::getID(), MeshLib::Element::getID(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfBaseNodes(), and OGS_FATAL.