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 475 of file MeshSurfaceExtraction.cpp.

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