OGS
MeshLib::BoundaryExtraction Namespace Reference

Functions

std::unique_ptr< MeshLib::MeshgetBoundaryElementsAsMesh (MeshLib::Mesh const &bulk_mesh, std::string const &subsfc_node_id_prop_name, std::string const &subsfc_element_id_prop_name, std::string const &face_id_prop_name)
 

Function Documentation

◆ getBoundaryElementsAsMesh()

std::unique_ptr< MeshLib::Mesh > MeshLib::BoundaryExtraction::getBoundaryElementsAsMesh ( MeshLib::Mesh const &  bulk_mesh,
std::string const &  subsfc_node_id_prop_name,
std::string const &  subsfc_element_id_prop_name,
std::string const &  face_id_prop_name 
)

Copies relevant parts of scalar arrays to the surface mesh

Definition at line 444 of file MeshSurfaceExtraction.cpp.

449 {
450  auto const mesh_dimension = bulk_mesh.getDimension();
451  if (mesh_dimension < 2 || mesh_dimension > 3)
452  {
453  ERR("Cannot handle meshes of dimension {:i}", mesh_dimension);
454  }
455 
456  // create boundary elements based on the subsurface nodes
457  auto [boundary_elements, element_to_bulk_element_id_map,
458  element_to_bulk_face_id_map] = createBoundaryElements(bulk_mesh);
459 
460  // create new nodes needed for the new surface elements
461  auto [boundary_nodes, node_id_map] = createNodesAndIDMapFromElements(
462  boundary_elements, bulk_mesh.getNumberOfNodes());
463 
464  // create new elements using newly created nodes and delete temp-elements
465  auto new_elements = MeshLib::copyElementVector(
466  boundary_elements, boundary_nodes, &node_id_map);
467  for (auto* e : boundary_elements)
468  {
469  delete e;
470  }
471 
472  std::vector<std::size_t> nodes_to_bulk_nodes_id_map;
473  nodes_to_bulk_nodes_id_map.reserve(boundary_nodes.size());
474  std::transform(begin(boundary_nodes), end(boundary_nodes),
475  std::back_inserter(nodes_to_bulk_nodes_id_map),
476  [](MeshLib::Node* const n) { return n->getID(); });
477 
478  std::unique_ptr<MeshLib::Mesh> boundary_mesh(new Mesh(
479  bulk_mesh.getName() + "-boundary", boundary_nodes, new_elements));
480 
482  *boundary_mesh, subsfc_node_id_prop_name, nodes_to_bulk_nodes_id_map,
483  subsfc_element_id_prop_name, element_to_bulk_element_id_map,
484  face_id_prop_name, element_to_bulk_face_id_map);
485 
487  if (!createSfcMeshProperties(*boundary_mesh, bulk_mesh.getProperties(),
488  nodes_to_bulk_nodes_id_map,
489  element_to_bulk_element_id_map))
490  {
491  ERR("Transferring subsurface properties failed.");
492  }
493  return boundary_mesh;
494 }
void ERR(char const *fmt, Args const &... args)
Definition: Logging.h:42
std::size_t getID() const
Definition: Point3dWithID.h:62
bool createSfcMeshProperties(MeshLib::Mesh &sfc_mesh, MeshLib::Properties const &properties, std::vector< std::size_t > const &node_ids_map, std::vector< std::size_t > const &element_ids_map)
std::tuple< std::vector< MeshLib::Node * >, std::vector< std::size_t > > createNodesAndIDMapFromElements(std::vector< MeshLib::Element * > const &elements, std::size_t const n_all_nodes)
void addBulkIDPropertiesToMesh(MeshLib::Mesh &surface_mesh, std::string const &node_to_bulk_node_id_map_name, std::vector< std::size_t > const &node_to_bulk_node_id_map, std::string const &element_to_bulk_element_id_map_name, std::vector< std::size_t > const &element_to_bulk_element_id_map, std::string const &element_to_bulk_face_id_map_name, std::vector< std::size_t > const &element_to_bulk_face_id_map)
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)
std::tuple< std::vector< MeshLib::Element * >, std::vector< std::size_t >, std::vector< std::size_t > > createBoundaryElements(MeshLib::Mesh const &bulk_mesh)

References MeshLib::addBulkIDPropertiesToMesh(), MeshLib::copyElementVector(), MeshLib::createBoundaryElements(), MeshLib::createNodesAndIDMapFromElements(), MeshLib::createSfcMeshProperties(), ERR(), MeshLib::Mesh::getDimension(), MathLib::Point3dWithID::getID(), MeshLib::Mesh::getName(), MeshLib::Mesh::getNumberOfNodes(), and MeshLib::Mesh::getProperties().

Referenced by MeshLib::MeshValidation::detectHoles(), extractBoundaries(), and main().