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*> 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{
60public:
61 using IntegerType = long;
62
63public:
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
79 void partitionByMETIS();
80
81 std::vector<Partition> partitionOtherMesh(MeshLib::Mesh const& mesh) const;
82
86 MeshLib::PropertyVector<std::size_t>* const bulk_node_ids,
87 std::vector<Partition> const& local_partitions) const;
88
92 MeshLib::PropertyVector<std::size_t>* const bulk_element_ids_pv,
93 std::vector<Partition> const& local_partitions) const;
94
97 void write(const std::string& file_name_base);
98
99 void writeOtherMesh(
100 std::string const& output_filename_base,
101 std::vector<Partition> const& partitions,
102 MeshLib::Properties const& partitioned_properties) const;
103
105 std::vector<std::size_t>&& node_partition_ids)
106 {
107 _nodes_partition_ids = std::move(node_partition_ids);
108 }
109
110 MeshLib::Mesh const& mesh() const { return *_mesh; }
111
112private:
114 std::vector<Partition> _partitions;
115
118
120 std::unique_ptr<MeshLib::Mesh> _mesh;
121
123 std::vector<std::size_t> _nodes_global_ids;
124
126 std::vector<std::size_t> _nodes_partition_ids;
127
128 // Renumber the global indices of nodes,
129 void renumberNodeIndices();
130
131 void processPartition(std::size_t const part_id);
132};
133
134} // 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 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 processPartition(std::size_t const part_id)
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(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