OGS
NodeWiseMeshPartitioner.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <memory>
18#include <string>
19#include <tuple>
20#include <vector>
21
24#include "MeshLib/Mesh.h"
25#include "MeshLib/Node.h"
26
27namespace ApplicationUtils
28{
31{
32 std::vector<MeshLib::Node const*> nodes;
39 std::vector<const MeshLib::Element*> regular_elements;
40 std::vector<const MeshLib::Element*> ghost_elements;
41 std::vector<bool> duplicate_ghost_cell;
42
44
45 // Note: for property vector OGS_VERSION or IntegrationPointMetaData, the
46 // number gotten from this function is not used for reading the property
47 // vector under MPI because the sizes of the partitions of such vectors are
48 // the same.
49 std::size_t numberOfMeshItems(MeshLib::MeshItemType const item_type) const;
50
51 std::ostream& writeNodes(
52 std::ostream& os,
53 std::vector<std::size_t> const& global_node_ids) const;
54
55 std::ostream& writeConfig(std::ostream& os) const;
56};
57
60 std::unique_ptr<MeshLib::Mesh> const& mesh,
61 std::vector<Partition>& partitions);
62
65{
66public:
67 using IntegerType = long;
68
69public:
75 std::unique_ptr<MeshLib::Mesh>&& mesh)
76 : _partitions(num_partitions),
78 _mesh(std::move(mesh)),
79 _nodes_global_ids(_mesh->getNumberOfNodes()),
80 _nodes_partition_ids(_mesh->getNumberOfNodes())
81 {
82 }
83
85 void partitionByMETIS();
86
87 std::vector<Partition> partitionOtherMesh(MeshLib::Mesh const& mesh) const;
88
89 void renumberBulkIdsProperty(std::vector<Partition> const& partitions,
90 MeshLib::Properties& partitioned_properties);
91
94 void write(const std::string& file_name_base);
95
96 void writeOtherMesh(
97 std::string const& output_filename_base,
98 std::vector<Partition> const& partitions,
99 MeshLib::Properties const& partitioned_properties) const;
100
102 std::vector<std::size_t>&& node_partition_ids)
103 {
104 _nodes_partition_ids = std::move(node_partition_ids);
105 }
106
107 MeshLib::Mesh const& mesh() const { return *_mesh; }
108
109private:
111 std::vector<Partition> _partitions;
112
115
117 std::unique_ptr<MeshLib::Mesh> _mesh;
118
120 std::vector<std::size_t> _nodes_global_ids;
121
123 std::vector<std::size_t> _nodes_partition_ids;
124
125 // Renumber the global indices of nodes,
126 void renumberNodeIndices();
127
131 MeshLib::PropertyVector<std::size_t>* const bulk_node_ids,
132 std::vector<Partition> const& local_partitions) const;
133
137 MeshLib::PropertyVector<std::size_t>* const bulk_element_ids_pv,
138 std::vector<Partition> const& local_partitions) const;
139};
140
141} // namespace ApplicationUtils
Definition of the Element class.
Definition of the Mesh class.
Definition of the Node class.
void renumberBulkElementIdsProperty(MeshLib::PropertyVector< std::size_t > *const bulk_element_ids_pv, std::vector< Partition > const &local_partitions) const
std::vector< Partition > partitionOtherMesh(MeshLib::Mesh const &mesh) const
NodeWiseMeshPartitioner(const IntegerType num_partitions, std::unique_ptr< MeshLib::Mesh > &&mesh)
void write(const std::string &file_name_base)
void renumberBulkIdsProperty(std::vector< Partition > const &partitions, MeshLib::Properties &partitioned_properties)
void renumberBulkNodeIdsProperty(MeshLib::PropertyVector< std::size_t > *const bulk_node_ids, std::vector< Partition > const &local_partitions) const
std::unique_ptr< MeshLib::Mesh > _mesh
Pointer to a mesh object.
MeshLib::Properties _partitioned_properties
Properties where values at ghost nodes and extra nodes are inserted.
void resetPartitionIdsForNodes(std::vector< std::size_t > &&node_partition_ids)
std::vector< std::size_t > _nodes_global_ids
Global IDs of all nodes after partitioning.
std::vector< Partition > _partitions
Data for all partitions.
std::vector< std::size_t > _nodes_partition_ids
Partition IDs of each nodes.
void writeOtherMesh(std::string const &output_filename_base, std::vector< Partition > const &partitions, MeshLib::Properties const &partitioned_properties) const
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition: Properties.h:36
MeshLib::Properties partitionProperties(std::unique_ptr< MeshLib::Mesh > const &mesh, std::vector< Partition > &partitions)
Partition existing properties and add vtkGhostType cell data array property.
MeshItemType
Definition: Location.h:21
std::ostream & writeConfig(std::ostream &os) const
std::size_t numberOfMeshItems(MeshLib::MeshItemType const item_type) const
std::vector< bool > duplicate_ghost_cell
std::vector< const MeshLib::Element * > regular_elements
Non ghost elements.
std::vector< const MeshLib::Element * > ghost_elements
std::ostream & writeNodes(std::ostream &os, std::vector< std::size_t > const &global_node_ids) const
std::vector< MeshLib::Node const * > nodes
nodes.