KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
metis_divide_heterogeneous_input_process.h
Go to the documentation of this file.
1 #pragma once
2 
3 // External includes
4 #include "metis.h"
5 
6 // Project includes
7 #include "includes/io.h"
8 #include "processes/process.h"
9 
10 namespace Kratos
11 {
14 
17 
21 
25 
29 
33 
35 class KRATOS_API(METIS_APPLICATION) MetisDivideHeterogeneousInputProcess : public Process
36 {
37 public:
40 
43 
49  using idxtype = idx_t; // from metis
50 
54 
57  IO& rIO,
58  SizeType NumberOfPartitions,
59  int Dimension = 3,
60  int Verbosity = 0,
61  bool SynchronizeConditions = false):
62  mrIO(rIO),
63  mNumberOfPartitions(NumberOfPartitions),
64  mSynchronizeConditions(SynchronizeConditions),
65  mVerbosity(Verbosity)
66  {
67  }
68 
71 
74  {
75  }
76 
77 
81 
82  void operator()()
83  {
84  this->Execute();
85  }
86 
87 
91 
93 
95  void Execute() override;
96 
97  virtual void GetNodesPartitions(std::vector<idxtype> &rNodePartition, SizeType &rNumNodes);
98 
102 
103 
107 
108 
112 
114  std::string Info() const override
115  {
116  return "MetisDivideHeterogeneousInputProcess";
117  }
118 
120  void PrintInfo(std::ostream& rOStream) const override
121  {
122  rOStream << "MetisDivideHeterogeneousInputProcess";
123  }
124 
126  void PrintData(std::ostream& rOStream) const override
127  {
128  }
129 
130 
134 
135 
137 
138 protected:
141 
145 
147 
149 
151 
154 
155  std::vector<std::unordered_set<std::size_t>> mNodeConnectivities;
156 
160 
164 
165  void ExecutePartitioning(PartitioningInfo& rPartitioningInfo);
166 
168 
176  int PartitionNodes(SizeType NumNodes,
177  idxtype* NodeIndices,
178  idxtype* NodeConnectivities,
179  std::vector<idxtype>& rNodePartition);
180 
182  void PartitionMesh(std::vector<idxtype> const& NodePartition,
183  const IO::ConnectivitiesContainerType& rElemConnectivities,
184  std::vector<idxtype>& rElemPartition);
185 
187  void PartitionElementsSynchronous(std::vector<idxtype> const& NodePartition,
188  const IO::ConnectivitiesContainerType& rElemConnectivities,
189  std::vector<idxtype>& rElemPartition);
190 
192  void PartitionConditionsSynchronous(const std::vector<idxtype>& rNodePartition,
193  const std::vector<idxtype>& rElemPartition,
194  const IO::ConnectivitiesContainerType& rCondConnectivities,
195  const IO::ConnectivitiesContainerType& rElemConnectivities,
196  std::vector<idxtype>& rCondPartition);
197 
198  void RedistributeHangingNodes(
199  std::vector<idxtype>& rNodePartition,
200  std::vector<idxtype> const& rElementPartition,
201  const IO::ConnectivitiesContainerType& rElementConnectivities,
202  std::vector<idxtype> const& rConditionPartition,
203  const IO::ConnectivitiesContainerType& rConditionConnectivities);
204 
205  SizeType FindMax(SizeType NumTerms, const std::vector<int>& rVect);
206 
207  void PrintDebugData(const std::string& rLabel,
208  const std::vector<idxtype>& rPartitionData);
209 
213 
214 
218 
219 
223 
226 
227  // Copy constructor.
228  //MetisDivideHeterogeneousInputProcess(MetisDivideHeterogeneousInputProcess const& rOther);
229 
230 
232 
233 }; // Class MetisDivideHeterogeneousInputProcess
234 
236 
239 
240 
244 
245 
247 inline std::istream& operator >> (std::istream& rIStream,
249 
251 inline std::ostream& operator << (std::ostream& rOStream,
253 {
254  rThis.PrintInfo(rOStream);
255  rOStream << std::endl;
256  rThis.PrintData(rOStream);
257 
258  return rOStream;
259 }
261 
263 
264 }
IO provides different implementation of input output procedures which can be used to read and write w...
Definition: io.h:58
std::vector< std::vector< std::size_t > > ConnectivitiesContainerType
Definition: io.h:91
DenseMatrix< int > GraphType
Definition: io.h:99
std::size_t SizeType
Definition: io.h:97
std::vector< std::size_t > PartitionIndicesType
Definition: io.h:95
std::vector< std::vector< std::size_t > > PartitionIndicesContainerType
Definition: io.h:93
Definition: amatrix_interface.h:41
Call Metis to divide an heterogeneous mesh, by partitioning its nodal graph.
Definition: metis_divide_heterogeneous_input_process.h:36
std::string Info() const override
Turn back information as a string.
Definition: metis_divide_heterogeneous_input_process.h:114
MetisDivideHeterogeneousInputProcess(IO &rIO, SizeType NumberOfPartitions, int Dimension=3, int Verbosity=0, bool SynchronizeConditions=false)
Default constructor.
Definition: metis_divide_heterogeneous_input_process.h:56
idx_t idxtype
Definition: metis_divide_heterogeneous_input_process.h:49
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: metis_divide_heterogeneous_input_process.h:126
SizeType mNumberOfPartitions
Definition: metis_divide_heterogeneous_input_process.h:148
IO::PartitionIndicesType PartitionIndicesType
Definition: metis_divide_heterogeneous_input_process.h:47
MetisDivideHeterogeneousInputProcess & operator=(MetisDivideHeterogeneousInputProcess const &rOther)
Assignment operator.
IO::PartitionIndicesContainerType PartitionIndicesContainerType
Definition: metis_divide_heterogeneous_input_process.h:48
std::vector< std::unordered_set< std::size_t > > mNodeConnectivities
Definition: metis_divide_heterogeneous_input_process.h:155
KRATOS_CLASS_POINTER_DEFINITION(MetisDivideHeterogeneousInputProcess)
Pointer definition of MetisDivideHeterogeneousInputProcess.
MetisDivideHeterogeneousInputProcess(MetisDivideHeterogeneousInputProcess const &rOther)=delete
Copy constructor.
bool mSynchronizeConditions
Definition: metis_divide_heterogeneous_input_process.h:150
virtual ~MetisDivideHeterogeneousInputProcess()
Destructor.
Definition: metis_divide_heterogeneous_input_process.h:73
void operator()()
Definition: metis_divide_heterogeneous_input_process.h:82
IO::SizeType SizeType
Definition: metis_divide_heterogeneous_input_process.h:44
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: metis_divide_heterogeneous_input_process.h:120
IO & mrIO
Definition: metis_divide_heterogeneous_input_process.h:146
int mNumNodes
Definition: metis_divide_heterogeneous_input_process.h:153
int mVerbosity
Definition: metis_divide_heterogeneous_input_process.h:152
The base class for all processes in Kratos.
Definition: process.h:49
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
Definition: io.h:103