OGS
MeshToolsLib::BoundaryExtraction Namespace Reference

Functions

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

Function Documentation

◆ getBoundaryElementsAsMesh()

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

Copies relevant parts of scalar arrays to the surface mesh

Definition at line 474 of file MeshSurfaceExtraction.cpp.

479{
480 auto const mesh_dimension = bulk_mesh.getDimension();
481 if (mesh_dimension < 2 || mesh_dimension > 3)
482 {
483 ERR("Cannot handle meshes of dimension {}", mesh_dimension);
484 }
485
486 // create boundary elements based on the subsurface nodes
487 auto [boundary_elements, element_to_bulk_element_id_map,
488 element_to_bulk_face_id_map] = createBoundaryElements(bulk_mesh);
489
490 // create new nodes needed for the new surface elements
491 auto [boundary_nodes, node_id_map] = createNodesAndIDMapFromElements(
492 boundary_elements, bulk_mesh.getNumberOfNodes());
493
494 // create new elements using newly created nodes and delete temp-elements
495 auto new_elements = MeshLib::copyElementVector(
496 boundary_elements, boundary_nodes, &node_id_map);
497 for (auto* e : boundary_elements)
498 {
499 delete e;
500 }
501
502 auto boundary_node_ids = boundary_nodes | MeshLib::views::ids;
503
504 std::vector<std::size_t> const nodes_to_bulk_nodes_id_map(
505 boundary_node_ids.begin(), boundary_node_ids.end());
506
507 std::unique_ptr<MeshLib::Mesh> boundary_mesh(
508 new MeshLib::Mesh(bulk_mesh.getName() + "-boundary", boundary_nodes,
509 new_elements, true /* compute_element_neighbors */));
510
511 addBulkIDPropertiesToMesh(
512 *boundary_mesh, subsfc_node_id_prop_name, nodes_to_bulk_nodes_id_map,
513 subsfc_element_id_prop_name, element_to_bulk_element_id_map,
514 face_id_prop_name, element_to_bulk_face_id_map);
515
517 if (!createSfcMeshProperties(*boundary_mesh, bulk_mesh.getProperties(),
518 nodes_to_bulk_nodes_id_map,
519 element_to_bulk_element_id_map))
520 {
521 ERR("Transferring subsurface properties failed.");
522 }
523 return boundary_mesh;
524}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:225
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::Node * >, std::vector< std::size_t > > createNodesAndIDMapFromElements(std::vector< MeshLib::Element * > const &elements, std::size_t const n_all_nodes)
std::tuple< std::vector< MeshLib::Element * >, std::vector< std::size_t >, std::vector< std::size_t > > createBoundaryElements(MeshLib::Mesh const &bulk_mesh)

References MeshToolsLib::addBulkIDPropertiesToMesh(), MeshLib::copyElementVector(), MeshToolsLib::createBoundaryElements(), MeshToolsLib::createNodesAndIDMapFromElements(), MeshToolsLib::createSfcMeshProperties(), ERR(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getName(), MeshLib::Mesh::getNumberOfNodes(), MeshLib::Mesh::getProperties(), and MeshLib::views::ids.

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