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.
mapper_local_system.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
23 #include "includes/define.h"
24 #include "mapper_interface_info.h"
25 
26 namespace Kratos
27 {
30 
33 
35 
39 {
40 public:
43 
46 
49 
51 
52  typedef Matrix MatrixType;
53  typedef std::vector<int> EquationIdVectorType; // int bcs of mpi
54 
57 
61 
62  enum class PairingStatus
63  {
67  };
68 
72 
74  virtual ~MapperLocalSystem() = default;
75 
79 
81  EquationIdVectorType& rDestinationIds)
82  {
83  if (!mIsComputed) {
85  mIsComputed = true;
86  }
87 
88  rOriginIds = mOriginIds;
89  rDestinationIds = mDestinationIds;
90  }
91 
92  void CalculateLocalSystem(MatrixType& rLocalMappingMatrix,
93  EquationIdVectorType& rOriginIds,
94  EquationIdVectorType& rDestinationIds) const
95  {
96  if (mIsComputed) {
97  // This will be called if the EquationIdVectors have been querried before
98  // i.e. matrix-based mapping
99  rLocalMappingMatrix = mLocalMappingMatrix;
100  rOriginIds = mOriginIds;
101  rDestinationIds = mDestinationIds;
102  }
103  else {
104  // This will be called if the EquationIdVectors have NOT been querried before
105  // i.e. matrix-free mapping
106  CalculateAll(rLocalMappingMatrix, rOriginIds, rDestinationIds, mPairingStatus);
107  }
108  }
109 
121  void ResizeToZero(MatrixType& rLocalMappingMatrix,
122  EquationIdVectorType& rOriginIds,
123  EquationIdVectorType& rDestinationIds,
124  MapperLocalSystem::PairingStatus& rPairingStatus) const
125  {
127 
128  rLocalMappingMatrix.resize(0, 0, false);
129  rOriginIds.resize(0);
130  rDestinationIds.resize(0);
131  }
132 
133  virtual CoordinatesArrayType& Coordinates() const = 0;
134 
135 
136  void AddInterfaceInfo(MapperInterfaceInfoPointerType pInterfaceInfo) // TODO pass by const ref?
137  {
138  mInterfaceInfos.push_back(pInterfaceInfo);
139  }
140 
141  bool HasInterfaceInfo() const
142  {
143  return mInterfaceInfos.size() > 0;
144  }
145 
147  {
148  for (const auto& r_info : mInterfaceInfos) {
149  if (!r_info->GetIsApproximation()) {
150  return true;
151  }
152  }
153  return false;
154  }
155 
156  virtual bool IsDoneSearching() const
157  {
159  }
160 
162  {
163  KRATOS_ERROR << "Create is not implemented for NodePointerType!" << std::endl;
164  }
165 
167  {
168  KRATOS_ERROR << "Create is not implemented for GeometryPointerType!" << std::endl;
169  }
170 
171 
172  virtual void Clear()
173  {
174  mInterfaceInfos.clear();
176  mOriginIds.clear();
177  mDestinationIds.clear();
178  mIsComputed = false;
179  }
180 
182  {
183  return mPairingStatus;
184  }
185 
187  {
188  KRATOS_ERROR << "SetPairingStatusForPrinting is not implemented!" << std::endl;
189  }
190 
194 
195  virtual void PairingInfo(std::ostream& rOStream, const int EchoLevel) const = 0;
196 
198  virtual std::string Info() const {return "MapperLocalSystem";}
199 
201  virtual void PrintInfo(std::ostream& rOStream) const {}
202 
204  virtual void PrintData(std::ostream& rOStream) const {}
205 
207 
208 protected:
211 
212  MapperLocalSystem() = default; // only accessbĂ­ble by derived classes
213 
217 
218  std::vector<MapperInterfaceInfoPointerType> mInterfaceInfos;
219 
220  bool mIsComputed = false;
221 
225 
227 
231 
232  // This function calculates the components necessary for the mapping
233  // Note that it is "const", therefore it can NOT modify its members
234  // Whether members are to be saved is decided in other functions of this class
235  virtual void CalculateAll(MatrixType& rLocalMappingMatrix,
236  EquationIdVectorType& rOriginIds,
237  EquationIdVectorType& rDestinationIds,
238  MapperLocalSystem::PairingStatus& rPairingStatus) const = 0;
239 
241 
242 }; // Class MapperLocalSystem
243 
245 
247 
248 } // namespace Kratos.
Geometry base class.
Definition: geometry.h:71
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
void clear()
Definition: amatrix_interface.h:284
InterfaceObject::CoordinatesArrayType CoordinatesArrayType
Definition: mapper_interface_info.h:52
This is the "Condition" of the mappers.
Definition: mapper_local_system.h:39
void AddInterfaceInfo(MapperInterfaceInfoPointerType pInterfaceInfo)
Definition: mapper_local_system.h:136
PairingStatus GetPairingStatus() const
Definition: mapper_local_system.h:181
std::vector< MapperInterfaceInfoPointerType > mInterfaceInfos
Definition: mapper_local_system.h:218
PairingStatus
Definition: mapper_local_system.h:63
virtual std::string Info() const
Turn back information as a string.
Definition: mapper_local_system.h:198
KRATOS_CLASS_POINTER_DEFINITION(MapperLocalSystem)
Pointer definition of MapperLocalSystem.
Kratos::shared_ptr< MapperInterfaceInfo > MapperInterfaceInfoPointerType
Definition: mapper_local_system.h:47
std::vector< int > EquationIdVectorType
Definition: mapper_local_system.h:53
EquationIdVectorType mOriginIds
Definition: mapper_local_system.h:223
InterfaceObject::NodePointerType NodePointerType
Definition: mapper_local_system.h:55
void EquationIdVectors(EquationIdVectorType &rOriginIds, EquationIdVectorType &rDestinationIds)
Definition: mapper_local_system.h:80
void ResizeToZero(MatrixType &rLocalMappingMatrix, EquationIdVectorType &rOriginIds, EquationIdVectorType &rDestinationIds, MapperLocalSystem::PairingStatus &rPairingStatus) const
Resizing the output if no InterfaceInfo is available This function resizes the system vectors to zero...
Definition: mapper_local_system.h:121
virtual CoordinatesArrayType & Coordinates() const =0
bool mIsComputed
Definition: mapper_local_system.h:220
virtual MapperLocalSystemUniquePointer Create(NodePointerType pNode) const
Definition: mapper_local_system.h:161
virtual ~MapperLocalSystem()=default
Destructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: mapper_local_system.h:201
virtual void PairingInfo(std::ostream &rOStream, const int EchoLevel) const =0
bool HasInterfaceInfoThatIsNotAnApproximation() const
Definition: mapper_local_system.h:146
MapperInterfaceInfo::CoordinatesArrayType CoordinatesArrayType
Definition: mapper_local_system.h:50
bool HasInterfaceInfo() const
Definition: mapper_local_system.h:141
virtual void Clear()
Definition: mapper_local_system.h:172
MatrixType mLocalMappingMatrix
Definition: mapper_local_system.h:222
virtual MapperLocalSystemUniquePointer Create(GeometryPointerType pGeometry) const
Definition: mapper_local_system.h:166
Kratos::unique_ptr< MapperLocalSystem > MapperLocalSystemUniquePointer
Definition: mapper_local_system.h:48
Matrix MatrixType
Definition: mapper_local_system.h:52
EquationIdVectorType mDestinationIds
Definition: mapper_local_system.h:224
virtual void CalculateAll(MatrixType &rLocalMappingMatrix, EquationIdVectorType &rOriginIds, EquationIdVectorType &rDestinationIds, MapperLocalSystem::PairingStatus &rPairingStatus) const =0
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: mapper_local_system.h:204
virtual void SetPairingStatusForPrinting()
Definition: mapper_local_system.h:186
InterfaceObject::GeometryPointerType GeometryPointerType
Definition: mapper_local_system.h:56
virtual bool IsDoneSearching() const
Definition: mapper_local_system.h:156
PairingStatus mPairingStatus
Definition: mapper_local_system.h:226
void CalculateLocalSystem(MatrixType &rLocalMappingMatrix, EquationIdVectorType &rOriginIds, EquationIdVectorType &rDestinationIds) const
Definition: mapper_local_system.h:92
This class defines the node.
Definition: node.h:65
#define KRATOS_ERROR
Definition: exception.h:161
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::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33