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.
gather_modelpart_utility.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 // Michael Andre, https://github.com/msandre
12 // Jordi Cotela Dalmau
13 // Vicente Mataix Ferrandiz
14 //
15 
16 #pragma once
17 
18 // System includes
19 
20 // External includes
21 
22 // Project includes
23 #include "containers/variable.h"
24 #include "containers/array_1d.h"
25 #include "includes/model_part.h"
26 
29 
33 
37 
41 
45 
53 namespace Kratos
54 {
55 class KRATOS_API(KRATOS_MPI_CORE) GatherModelPartUtility
56 {
57 public:
60 
63 
66 
69 
72 
76 
85  const int GatherRank,
86  ModelPart& rOriginModelPart,
87  ModelPart& rDestinationModelPart
88  ) : GatherModelPartUtility(GatherRank, rOriginModelPart, 0, rDestinationModelPart)
89  {
90  // Nothing to do here
91  }
92 
102  const int GatherRank,
103  ModelPart& rOriginModelPart,
104  const int MeshId,
105  ModelPart& rDestinationModelPart
106  );
107 
111 
115 
119  void GatherOnMaster();
120 
125  template <class TDataType>
126  void GatherOnMaster(const Variable<TDataType>& rVariable);
127 
132  template <class TDataType>
133  void ScatterFromMaster(const Variable<TDataType>& rVariable);
134 
145  static void GatherEntitiesFromOtherPartitions(
146  ModelPart& rModelPart,
147  const std::map<int, std::vector<std::size_t>>& rNodesToBring,
148  const std::map<int, std::vector<std::size_t>>& rElementsToBring,
149  const std::map<int, std::vector<std::size_t>>& rConditionsToBring,
150  const bool CallExecuteAfterBringingEntities = true,
151  const int EchoLevel = 0
152  );
153 
162  static void GatherNodesFromOtherPartitions(
163  ModelPart& rModelPart,
164  const std::map<int, std::vector<std::size_t>>& rNodesToBring,
165  const bool CallExecuteAfterBringingEntities = true,
166  const int EchoLevel = 0
167  );
168 
177  static void GatherElementsFromOtherPartitions(
178  ModelPart& rModelPart,
179  const std::map<int, std::vector<std::size_t>>& rElementsToBring,
180  const bool CallExecuteAfterBringingEntities = true,
181  const int EchoLevel = 0
182  );
183 
192  static void GatherConditionsFromOtherPartitions(
193  ModelPart& rModelPart,
194  const std::map<int, std::vector<std::size_t>>& rConditionsToBring,
195  const bool CallExecuteAfterBringingEntities = true,
196  const int EchoLevel = 0
197  );
198 
202 
206 
210 
212  std::string Info() const;
213 
215  void PrintInfo(std::ostream& rOStream) const;
216 
218  void PrintData(std::ostream& rOStream) const;
219 
223 
225 private:
228 
232 
233  ModelPart& mrModelPart;
234  int mGatherRank;
235 
239 
243 
251  template <class TObjectType>
252  static void GatherEntityFromOtherPartitions(
253  ModelPart& rModelPart,
254  const std::map<int, std::vector<std::size_t>>& rEntitiesToBring,
255  const int EchoLevel = 0
256  );
257 
261 
265 
269 
271 
273 
275 
276  GatherModelPartUtility(GatherModelPartUtility const& rOther) = delete;
277 
279 
280 }; // Class GatherModelPartUtility
281 
285 
286 extern template void GatherModelPartUtility::GatherOnMaster(const Variable<double>&);
287 extern template void GatherModelPartUtility::GatherOnMaster(const Variable<array_1d<double, 3>>&);
288 extern template void GatherModelPartUtility::ScatterFromMaster(const Variable<double>&);
289 extern template void GatherModelPartUtility::ScatterFromMaster(const Variable<array_1d<double, 3>>&);
290 
294 
296 inline std::istream & operator >>(std::istream& rIStream,
297  GatherModelPartUtility& rThis)
298 {
299  return rIStream;
300 }
301 
303 inline std::ostream & operator <<(std::ostream& rOStream,
304  const GatherModelPartUtility& rThis)
305 {
306  rThis.PrintInfo(rOStream);
307  rOStream << std::endl;
308  rThis.PrintData(rOStream);
309 
310  return rOStream;
311 }
313 
314 } // namespace Kratos.
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Definition: gather_modelpart_utility.h:56
ModelPart::NodesContainerType NodesContainerType
Nodes container definition.
Definition: gather_modelpart_utility.h:62
ModelPart::ElementsContainerType ElementsContainerType
Elements container definition.
Definition: gather_modelpart_utility.h:65
ModelPart::ConditionsContainerType ConditionsContainerType
Conditions container definition.
Definition: gather_modelpart_utility.h:68
void ScatterFromMaster(const Variable< TDataType > &rVariable)
The function scatters the model part from the master rank to the other ranks.
Definition: gather_modelpart_utility.cpp:166
GatherModelPartUtility(const int GatherRank, ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart)
Default constructor.
Definition: gather_modelpart_utility.h:84
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: gather_modelpart_utility.cpp:471
void GatherOnMaster()
This function gathers the model part on the master rank.
Definition: gather_modelpart_utility.cpp:150
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: gather_modelpart_utility.cpp:476
KRATOS_CLASS_POINTER_DEFINITION(GatherModelPartUtility)
Pointer definition of GatherModelPartUtility.
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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