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.
model_part_communicator_utilities.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 author: Jordi Cotela
11 //
12 
13 #ifndef KRATOS_MODEL_PART_COMMUNICATOR_UTILITIES_H_INCLUDED
14 #define KRATOS_MODEL_PART_COMMUNICATOR_UTILITIES_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "includes/define.h"
22 #include "includes/model_part.h"
24 
25 namespace Kratos
26 {
27 
30 
33 
36 {
37 public:
40 
43 
47 
50 
53 
57 
59 
64  static inline void SetMPICommunicator(ModelPart& rThisModelPart, const DataCommunicator& rDataCommunicator)
65  {
66  KRATOS_ERROR_IF_NOT(rDataCommunicator.IsDistributed()) << "Only distributed DataCommunicators can be used!" << std::endl;
67  VariablesList * p_variables_list = &rThisModelPart.GetNodalSolutionStepVariablesList();
68  rThisModelPart.SetCommunicator(Kratos::make_shared<MPICommunicator>(p_variables_list, rDataCommunicator));
69  }
70 
72 
77  static inline void SetMPICommunicatorRecursively(ModelPart& rThisModelPart, const DataCommunicator& rDataCommunicator)
78  {
79  SetMPICommunicator(rThisModelPart, rDataCommunicator);
80  for (auto& r_smp : rThisModelPart.SubModelParts()) {
81  SetMPICommunicatorRecursively(r_smp, rDataCommunicator);
82  }
83  }
84 
85  KRATOS_DEPRECATED_MESSAGE("This function is deprecated, please use the one that accepts a DataCommunicator") static inline void SetMPICommunicator(ModelPart& rThisModelPart)
86  {
87  VariablesList * p_variables_list = &rThisModelPart.GetNodalSolutionStepVariablesList();
88  rThisModelPart.SetCommunicator(Kratos::make_shared<MPICommunicator>(p_variables_list, DataCommunicator::GetDefault()));
89  }
90 
92 
93 }; // Class ModelPartCommunicatorUtilities
94 
96 
98 
99 } // namespace Kratos.
100 
101 #endif /* KRATOS_MODEL_PART_COMMUNICATOR_UTILITIES_H_INCLUDED */
102 
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
static DataCommunicator & GetDefault()
Convenience function to retrieve the current default DataCommunicator.
Definition: data_communicator.cpp:18
virtual bool IsDistributed() const
Check whether this DataCommunicator is aware of parallelism.
Definition: data_communicator.h:606
Utilitiy class for ModelPart::Comunicator management in an MPI context.
Definition: model_part_communicator_utilities.h:36
ModelPartCommunicatorUtilities(const ModelPartCommunicatorUtilities &rOther)=delete
Deleted copy constructor.
static void SetMPICommunicatorRecursively(ModelPart &rThisModelPart, const DataCommunicator &rDataCommunicator)
Create and assign an MPICommunicator for a ModelPart instance and its SubModelParts.
Definition: model_part_communicator_utilities.h:77
KRATOS_CLASS_POINTER_DEFINITION(ModelPartCommunicatorUtilities)
Pointer definition of ModelPartCommunicatorUtilities.
static void SetMPICommunicator(ModelPart &rThisModelPart, const DataCommunicator &rDataCommunicator)
Create and assign an MPICommunicator for a ModelPart instance.
Definition: model_part_communicator_utilities.h:64
ModelPartCommunicatorUtilities()=delete
Deleted default constructor.
KRATOS_DEPRECATED_MESSAGE("This function is deprecated, please use the one that accepts a DataCommunicator") static inline void SetMPICommunicator(ModelPart &rThisModelPart)
Definition: model_part_communicator_utilities.h:85
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
void SetCommunicator(Communicator::Pointer pNewCommunicator)
Definition: model_part.h:1836
SubModelPartsContainerType & SubModelParts()
Definition: model_part.h:1718
VariablesList & GetNodalSolutionStepVariablesList()
Definition: model_part.h:549
Holds a list of variables and their position in VariablesListDataValueContainer.
Definition: variables_list.h:50
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21