From d4b5e241e16d3adf3eeed5afb221d97edc21f314 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Fri, 24 Mar 2023 12:16:22 +0100 Subject: [PATCH] Use MeshLib::bulkNodeIDs() --- Applications/Utils/MeshEdit/ReorderMesh.cpp | 19 ++++++---------- MeshGeoToolsLib/IdentifySubdomainMesh.cpp | 5 +---- NumLib/DOF/MeshComponentMap.cpp | 22 +++++++++---------- ProcessLib/AssemblyMixin.cpp | 6 ++--- .../DeactivatedSubdomainDirichlet.cpp | 10 ++------- ProcessLib/CreateDeactivatedSubdomain.cpp | 5 +---- 6 files changed, 24 insertions(+), 43 deletions(-) diff --git a/Applications/Utils/MeshEdit/ReorderMesh.cpp b/Applications/Utils/MeshEdit/ReorderMesh.cpp index 2d3920e45a8..006d8f8a88d 100644 --- a/Applications/Utils/MeshEdit/ReorderMesh.cpp +++ b/Applications/Utils/MeshEdit/ReorderMesh.cpp @@ -142,21 +142,16 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - auto const bulk_node_ids_string = - MeshLib::getBulkIDString(MeshLib::MeshItemType::Node); - if (!mesh->getProperties().existsPropertyVector<std::size_t>( - bulk_node_ids_string)) + auto const* bulk_node_ids = MeshLib::bulkNodeIDs(*mesh); + if (!bulk_node_ids) { OGS_FATAL("Property / data array '{}' has not been found in the mesh.", - bulk_node_ids_string); + MeshLib::getBulkIDString(MeshLib::MeshItemType::Node)); } - auto const& bulk_node_ids = - *mesh->getProperties().getPropertyVector<std::size_t>( - bulk_node_ids_string); auto const& nodes = mesh->getNodes(); auto const node_ids_reverse_mapping( - generateBulkIDsReverseMapping(bulk_node_ids)); + generateBulkIDsReverseMapping(*bulk_node_ids)); std::vector<MeshLib::Node*> reordered_nodes(nodes.size()); std::size_t pos = 0; @@ -197,8 +192,8 @@ int main(int argc, char* argv[]) { reordered_element->setNode( node_number, - reordered_nodes - [bulk_node_ids[e.getNode(node_number)->getID()]]); + reordered_nodes[( + *bulk_node_ids)[e.getNode(node_number)->getID()]]); } reordered_elements[pos] = reordered_element; pos++; @@ -219,7 +214,7 @@ int main(int argc, char* argv[]) auto const node_property_names = mesh->getProperties().getPropertyVectorNames( MeshLib::MeshItemType::Node); - reorderProperties(original_properties, bulk_node_ids, node_property_names, + reorderProperties(original_properties, *bulk_node_ids, node_property_names, properties); // element based properties diff --git a/MeshGeoToolsLib/IdentifySubdomainMesh.cpp b/MeshGeoToolsLib/IdentifySubdomainMesh.cpp index 322b4ee9b38..8a9dd8fd9f2 100644 --- a/MeshGeoToolsLib/IdentifySubdomainMesh.cpp +++ b/MeshGeoToolsLib/IdentifySubdomainMesh.cpp @@ -98,10 +98,7 @@ std::vector<std::size_t> findElementsInMesh( std::vector<std::vector<std::size_t>> identifySubdomainMeshElements( MeshLib::Mesh const& subdomain_mesh, MeshLib::Mesh const& bulk_mesh) { - auto& properties = subdomain_mesh.getProperties(); - auto const& bulk_node_ids = *properties.getPropertyVector<std::size_t>( - MeshLib::getBulkIDString(MeshLib::MeshItemType::Node), - MeshLib::MeshItemType::Node, 1); + auto const& bulk_node_ids = *MeshLib::bulkNodeIDs(subdomain_mesh); // Allocate space for all elements for random insertion. std::vector<std::vector<std::size_t>> bulk_element_ids_map( diff --git a/NumLib/DOF/MeshComponentMap.cpp b/NumLib/DOF/MeshComponentMap.cpp index a4bb5f31f5d..9fda517e0af 100644 --- a/NumLib/DOF/MeshComponentMap.cpp +++ b/NumLib/DOF/MeshComponentMap.cpp @@ -76,18 +76,18 @@ MeshComponentMap MeshComponentMap::getSubset( } // Mapping of the nodes in the new_mesh_subset to the bulk mesh nodes - auto const& new_mesh_properties = new_mesh_subset.getMesh().getProperties(); - if (!new_mesh_properties.template existsPropertyVector<std::size_t>( - getBulkIDString(MeshLib::MeshItemType::Node))) + auto bulk_node_ids = [](auto const& mesh) { - OGS_FATAL( - "Bulk node ids map expected in the construction of the mesh " - "subset."); - } - auto const& bulk_node_ids_map = - *new_mesh_properties.template getPropertyVector<std::size_t>( - getBulkIDString(MeshLib::MeshItemType::Node), - MeshLib::MeshItemType::Node, 1); + auto const* bulk_node_ids_ptr = MeshLib::bulkNodeIDs(mesh); + if (bulk_node_ids_ptr == nullptr) + { + OGS_FATAL( + "Bulk node ids map expected in the construction of the mesh " + "subset."); + } + return *bulk_node_ids_ptr; + }; + auto const& bulk_node_ids_map = bulk_node_ids(new_mesh_subset.getMesh()); // New dictionary for the subset. ComponentGlobalIndexDict subset_dict; diff --git a/ProcessLib/AssemblyMixin.cpp b/ProcessLib/AssemblyMixin.cpp index e73120ecff3..e814b8ab691 100644 --- a/ProcessLib/AssemblyMixin.cpp +++ b/ProcessLib/AssemblyMixin.cpp @@ -49,10 +49,8 @@ SubmeshAssemblyData::SubmeshAssemblyData( MeshLib::Mesh const& mesh, std::vector<std::reference_wrapper<MeshLib::PropertyVector<double>>>&& residuum_vectors) - : bulk_element_ids{*mesh.getProperties().getPropertyVector<std::size_t>( - "bulk_element_ids", MeshLib::MeshItemType::Cell, 1)}, - bulk_node_ids{*mesh.getProperties().getPropertyVector<std::size_t>( - "bulk_node_ids", MeshLib::MeshItemType::Node, 1)}, + : bulk_element_ids{*MeshLib::bulkElementIDs(mesh)}, + bulk_node_ids{*MeshLib::bulkNodeIDs(mesh)}, residuum_vectors{std::move(residuum_vectors)} { } diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp index 91407e7df1a..d3cc3ad43bc 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp @@ -56,15 +56,9 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( NumLib::IndexValueVector<GlobalIndexType>& bc_values) const { [[maybe_unused]] auto const& bulk_node_ids = - *_subdomain.mesh.getProperties() - .template getPropertyVector<std::size_t>( - MeshLib::getBulkIDString(MeshLib::MeshItemType::Node), - MeshLib::MeshItemType::Node, 1); + *MeshLib::bulkNodeIDs(_subdomain.mesh); [[maybe_unused]] auto const& bulk_element_ids = - *_subdomain.mesh.getProperties() - .template getPropertyVector<std::size_t>( - MeshLib::getBulkIDString(MeshLib::MeshItemType::Cell), - MeshLib::MeshItemType::Cell, 1); + *MeshLib::bulkElementIDs(_subdomain.mesh); auto is_inactive_id = [&](std::size_t const bulk_element_id) { return _is_active[bulk_element_id] == 0; }; diff --git a/ProcessLib/CreateDeactivatedSubdomain.cpp b/ProcessLib/CreateDeactivatedSubdomain.cpp index b54049ca6c2..37a432db10a 100644 --- a/ProcessLib/CreateDeactivatedSubdomain.cpp +++ b/ProcessLib/CreateDeactivatedSubdomain.cpp @@ -32,10 +32,7 @@ extractInnerAndOuterNodes(MeshLib::Mesh const& mesh, MeshLib::Mesh const& sub_mesh, IsActive is_active) { - auto* const bulk_node_ids = - sub_mesh.getProperties().template getPropertyVector<std::size_t>( - MeshLib::getBulkIDString(MeshLib::MeshItemType::Node), - MeshLib::MeshItemType::Node, 1); + auto* const bulk_node_ids = MeshLib::bulkNodeIDs(sub_mesh); if (bulk_node_ids == nullptr) { OGS_FATAL( -- GitLab