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.
interface_communicator_mpi.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: Philipp Bucher, Jordi Cotela
11 //
12 // See Master-Thesis P.Bucher
13 // "Development and Implementation of a Parallel
14 // Framework for Non-Matching Grid Mapping"
15 
16 #pragma once
17 
18 // System includes
19 
20 // External includes
21 
22 // Project includes
24 
25 namespace Kratos
26 {
29 
32 
34 
37 class KRATOS_API(MAPPING_APPLICATION) InterfaceCommunicatorMPI : public InterfaceCommunicator
38 {
39 public:
42 
45 
46  typedef std::vector<std::vector<double>> BufferTypeDouble;
47  typedef std::vector<std::vector<char>> BufferTypeChar;
48 
52 
53  InterfaceCommunicatorMPI(ModelPart& rModelPartOrigin,
54  MapperLocalSystemPointerVector& rMapperLocalSystems,
55  Parameters SearchSettings);
56 
59  {
60  }
61 
65 
67  std::string Info() const override
68  {
69  std::stringstream buffer;
70  buffer << "InterfaceCommunicatorMPI" ;
71  return buffer.str();
72  }
73 
75  void PrintInfo(std::ostream& rOStream) const override
76  {
77  rOStream << "InterfaceCommunicatorMPI";
78  }
79 
81  void PrintData(std::ostream& rOStream) const override {}
82 
84 
85 protected:
88 
89  void InitializeSearch(const MapperInterfaceInfoUniquePointerType& rpRefInterfaceInfo) override;
90 
91  // This function constructs the InterfaceObjects on the Destination
92  // In serial it only does it once, whereas in MPI this involves Data-Exchange!
93  // Imagine a sliding interface, there the partitions might change!
94  void InitializeSearchIteration(const MapperInterfaceInfoUniquePointerType& rpRefInterfaceInfo) override;
95 
96  void FinalizeSearchIteration(const MapperInterfaceInfoUniquePointerType& rpRefInterfaceInfo) override;
97 
99 
100 private:
103 
104  std::vector<double> mGlobalBoundingBoxes;
105  // xmax, xmin, ymax, ymin, zmax, zmin
106 
107  int mCommRank;
108  int mCommSize;
109 
110  std::vector<int> mSendSizes;
111  std::vector<int> mRecvSizes;
112 
113  BufferTypeDouble mSendBufferDouble;
114  BufferTypeDouble mRecvBufferDouble;
115 
116  BufferTypeChar mSendBufferChar;
117  BufferTypeChar mRecvBufferChar;
118 
122 
123  std::size_t GetBufferSizeEstimate() const
124  {
125  return mrMapperLocalSystems.size() / mCommSize;
126  }
127 
128  void ComputeGlobalBoundingBoxes();
129 
130  template< typename TDataType >
131  int ExchangeDataAsync(
132  const std::vector<std::vector<TDataType>>& rSendBuffer,
133  std::vector<std::vector<TDataType>>& rRecvBuffer);
134 
136 
137 }; // Class InterfaceCommunicatorMPI
138 
140 
142 
143 } // namespace Kratos.
Object for exchanging data on the Interface.
Definition: interface_communicator.h:45
std::vector< MapperLocalSystemPointer > MapperLocalSystemPointerVector
Definition: interface_communicator.h:59
Object for exchanging data on the Interface in MPI.
Definition: interface_communicator_mpi.h:38
virtual ~InterfaceCommunicatorMPI()
Destructor.
Definition: interface_communicator_mpi.h:58
std::vector< std::vector< char > > BufferTypeChar
Definition: interface_communicator_mpi.h:47
std::string Info() const override
Turn back information as a string.
Definition: interface_communicator_mpi.h:67
std::vector< std::vector< double > > BufferTypeDouble
Definition: interface_communicator_mpi.h:46
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: interface_communicator_mpi.h:75
KRATOS_CLASS_POINTER_DEFINITION(InterfaceCommunicatorMPI)
Pointer definition of InterfaceCommunicatorMPI.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: interface_communicator_mpi.h:81
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Kratos::unique_ptr< MapperInterfaceInfo > MapperInterfaceInfoUniquePointerType
Definition: mapper_utilities.h:40
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21