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 
27 namespace ApplicationUtils
28 {
30 struct Partition
31 {
32  std::vector<MeshLib::Node*> nodes;
35  std::size_t number_of_base_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 
43  std::size_t numberOfMeshItems(MeshLib::MeshItemType const item_type) const;
44 
45  std::ostream& writeNodes(
46  std::ostream& os,
47  std::vector<std::size_t> const& global_node_ids) const;
48 
49  std::ostream& writeConfig(std::ostream& os) const;
50 };
51 
54  MeshLib::Properties const& properties,
55  std::vector<Partition> const& partitions);
56 
59 {
60 public:
61  using IntegerType = long;
62 
63 public:
68  NodeWiseMeshPartitioner(const IntegerType num_partitions,
69  std::unique_ptr<MeshLib::Mesh>&& mesh)
70  : _partitions(num_partitions),
72  _mesh(std::move(mesh)),
73  _nodes_global_ids(_mesh->getNumberOfNodes()),
74  _nodes_partition_ids(_mesh->getNumberOfNodes())
75  {
76  }
77 
82  void partitionByMETIS(const bool is_mixed_high_order_linear_elems);
83 
84  std::vector<Partition> partitionOtherMesh(
85  MeshLib::Mesh const& mesh,
86  bool const is_mixed_high_order_linear_elems) const;
87 
91  MeshLib::PropertyVector<std::size_t>* const bulk_node_ids,
92  std::vector<Partition> const& local_partitions) const;
93 
97  MeshLib::PropertyVector<std::size_t>* const bulk_element_ids_pv,
98  std::vector<Partition> const& local_partitions) const;
99 
102  void write(const std::string& file_name_base);
103 
104  void writeOtherMesh(
105  std::string const& output_filename_base,
106  std::vector<Partition> const& partitions,
107  MeshLib::Properties const& partitioned_properties) const;
108 
110  std::vector<std::size_t>&& node_partition_ids)
111  {
112  _nodes_partition_ids = std::move(node_partition_ids);
113  }
114 
115  MeshLib::Mesh const& mesh() const { return *_mesh; }
116 
117 private:
119  std::vector<Partition> _partitions;
120 
123 
125  std::unique_ptr<MeshLib::Mesh> _mesh;
126 
128  std::vector<std::size_t> _nodes_global_ids;
129 
131  std::vector<std::size_t> _nodes_partition_ids;
132 
133  // Renumber the global indices of nodes,
137  void renumberNodeIndices(const bool is_mixed_high_order_linear_elems);
138 
139  void processPartition(std::size_t const part_id,
140  const bool is_mixed_high_order_linear_elems);
141 };
142 
143 } // namespace ApplicationUtils
Definition of the Element class.
Definition of the Mesh class.
Definition of the Node class.
void processPartition(std::size_t const part_id, const bool is_mixed_high_order_linear_elems)
void renumberBulkElementIdsProperty(MeshLib::PropertyVector< std::size_t > *const bulk_element_ids_pv, std::vector< Partition > const &local_partitions) const
void partitionByMETIS(const bool is_mixed_high_order_linear_elems)
NodeWiseMeshPartitioner(const IntegerType num_partitions, std::unique_ptr< MeshLib::Mesh > &&mesh)
void write(const std::string &file_name_base)
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.
std::vector< Partition > partitionOtherMesh(MeshLib::Mesh const &mesh, bool const is_mixed_high_order_linear_elems) const
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.
void renumberNodeIndices(const bool is_mixed_high_order_linear_elems)
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(MeshLib::Properties const &properties, std::vector< Partition > const &partitions)
Partition existing properties and add vtkGhostType cell data array property.
MeshItemType
Definition: Location.h:21
std::ostream & writeConfig(std::ostream &os) const
std::vector< MeshLib::Node * > nodes
nodes.
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