diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp index 942465c2f06d662f19d32810194423eaadb75bd6..142ff386356252b98d15f4a53081b0ce1eeb6921 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp +++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp @@ -689,6 +689,32 @@ void NodeWiseMeshPartitioner::partitionByMETIS() _partitioned_properties = partitionProperties(_mesh, _partitions); } +void NodeWiseMeshPartitioner::renumberBulkIdsProperty( + std::vector<Partition> const& partitions, + MeshLib::Properties& partitioned_properties) +{ + auto const bulk_node_ids_string = + MeshLib::getBulkIDString(MeshLib::MeshItemType::Node); + if (partitioned_properties.hasPropertyVector(bulk_node_ids_string)) + { + renumberBulkNodeIdsProperty( + partitioned_properties.getPropertyVector<std::size_t>( + bulk_node_ids_string, MeshLib::MeshItemType::Node, 1), + partitions); + } + auto const bulk_element_ids_string = + MeshLib::getBulkIDString(MeshLib::MeshItemType::Cell); + if (partitioned_properties.hasPropertyVector<std::size_t>( + static_cast<std::string>(bulk_element_ids_string), + MeshLib::MeshItemType::Cell)) + { + renumberBulkElementIdsProperty( + partitioned_properties.getPropertyVector<std::size_t>( + bulk_element_ids_string, MeshLib::MeshItemType::Cell, 1), + partitions); + } +} + void NodeWiseMeshPartitioner::renumberBulkNodeIdsProperty( MeshLib::PropertyVector<std::size_t>* const bulk_node_ids_pv, std::vector<Partition> const& local_partitions) const diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h index d0048d8cecf554af4833dddadea3fb73012074bb..f0ded7b1e99b2e143fd380e852109e49b7b48ce1 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h +++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h @@ -86,17 +86,8 @@ public: std::vector<Partition> partitionOtherMesh(MeshLib::Mesh const& mesh) const; - /// Renumber the bulk_node_ids property for each partition to match the - /// partitioned bulk mesh nodes. - void renumberBulkNodeIdsProperty( - MeshLib::PropertyVector<std::size_t>* const bulk_node_ids, - std::vector<Partition> const& local_partitions) const; - - /// Renumber the bulk_element_ids property for each partition to match the - /// partitioned bulk mesh elements. - void renumberBulkElementIdsProperty( - MeshLib::PropertyVector<std::size_t>* const bulk_element_ids_pv, - std::vector<Partition> const& local_partitions) const; + void renumberBulkIdsProperty(std::vector<Partition> const& partitions, + MeshLib::Properties& partitioned_properties); /// Write the partitions into binary files /// \param file_name_base The prefix of the file name. @@ -135,6 +126,18 @@ private: void renumberNodeIndices(); void processPartition(std::size_t const part_id); + + /// Renumber the bulk_node_ids property for each partition to match the + /// partitioned bulk mesh nodes. + void renumberBulkNodeIdsProperty( + MeshLib::PropertyVector<std::size_t>* const bulk_node_ids, + std::vector<Partition> const& local_partitions) const; + + /// Renumber the bulk_element_ids property for each partition to match the + /// partitioned bulk mesh elements. + void renumberBulkElementIdsProperty( + MeshLib::PropertyVector<std::size_t>* const bulk_element_ids_pv, + std::vector<Partition> const& local_partitions) const; }; } // namespace ApplicationUtils diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp b/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp index f0e5e155e7f389b77479b68206cef6f29a95c740..07576d20d558cf695f9687c260e429f177db3f65 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp +++ b/Applications/Utils/ModelPreparation/PartitionMesh/PartitionMesh.cpp @@ -224,21 +224,9 @@ int main(int argc, char* argv[]) auto partitions = mesh_partitioner.partitionOtherMesh(*mesh); auto partitioned_properties = partitionProperties(mesh, partitions); - auto const bulk_node_ids_string = - MeshLib::getBulkIDString(MeshLib::MeshItemType::Node); - mesh_partitioner.renumberBulkNodeIdsProperty( - partitioned_properties.getPropertyVector<std::size_t>( - bulk_node_ids_string, MeshLib::MeshItemType::Node, 1), - partitions); - auto const bulk_element_ids_string = - MeshLib::getBulkIDString(MeshLib::MeshItemType::Cell); - if (partitioned_properties.hasPropertyVector(bulk_element_ids_string)) - { - mesh_partitioner.renumberBulkElementIdsProperty( - partitioned_properties.getPropertyVector<std::size_t>( - bulk_element_ids_string, MeshLib::MeshItemType::Cell, 1), - partitions); - } + mesh_partitioner.renumberBulkIdsProperty(partitions, + partitioned_properties); + mesh_partitioner.writeOtherMesh( other_mesh_output_file_name_wo_extension, partitions, partitioned_properties);