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.
global_pointers_unordered_map.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 //
12 
13 #if !defined(KRATOS_GLOBAL_POINTER_UNORDERED_MAP_H_INCLUDED )
14 #define KRATOS_GLOBAL_POINTER_UNORDERED_MAP_H_INCLUDED
15 
16 // System includes
17 #include <vector>
18 #include <iostream>
19 #include <utility>
20 
21 
22 // External includes
23 
24 
25 // Project includes
26 #include "includes/define.h"
28 #include "includes/serializer.h"
29 
30 namespace Kratos
31 {
34 
37 
41 
45 
49 
53 
55 
57 template< class TDataType, class TValueType >
58 class GlobalPointersUnorderedMap : public std::unordered_map< GlobalPointer<TDataType>,
59  TValueType,
60  GlobalPointerHasher<TDataType>,
61  GlobalPointerComparor<TDataType>
62  >
63 {
64 public:
67 
70 
74 
77 
80 
84 
85 
89 
90 
94 
95 
99 
100 
104 
106  virtual std::string Info() const
107  {
108  std::stringstream buffer;
109  buffer << "GlobalPointersUnorderedMap" ;
110  return buffer.str();
111  }
112 
114  virtual void PrintInfo(std::ostream& rOStream) const
115  {
116  rOStream << "GlobalPointersUnorderedMap";
117  }
118 
120  virtual void PrintData(std::ostream& rOStream) const {}
121 
122 
126 
127 
129 
130 protected:
133 
134 
138 
139 
143 
144 
148 
149 
153 
154 
158 
159 
163 
164 
166 
167 private:
170 
171 
175 
176 
180  friend class Serializer;
181 
182  void save(Serializer& rSerializer) const
183  {
184  rSerializer.save("Size", this->size());
185  for(const auto& item : (*this))
186  {
187  rSerializer.save("pair", item);
188  }
189  }
190 
191  void load(Serializer& rSerializer)
192  {
193  std::size_t size;
194  rSerializer.load("Size", size);
195  this->reserve(size);
196 
197  for(std::size_t i = 0; i<size; ++i)
198  {
199  std::pair< GlobalPointer<TDataType>, TValueType> tmp(nullptr, TValueType());
200  rSerializer.load("pair", tmp);
201  this->insert(tmp);
202  }
203  }
204 
205 
209 
210 
214 
215 
219 
220 
224 
226 
227 }; // Class GlobalPointersUnorderedMap
228 
230 
233 
234 
238 
239 
241 template< class TDataType, class TValueType >
242 inline std::istream& operator >> (std::istream& rIStream,
244 {
245  return rIStream;
246 }
247 
249 template< class TDataType, class TValueType >
250 inline std::ostream& operator << (std::ostream& rOStream,
252 {
253  rThis.PrintInfo(rOStream);
254  rOStream << std::endl;
255  rThis.PrintData(rOStream);
256 
257  return rOStream;
258 }
260 
262 
263 } // namespace Kratos.
264 
265 #endif // KRATOS_GLOBAL_POINTER_UNORDERED_MAP_H_INCLUDED defined
266 
267 
Short class definition.
Definition: global_pointers_unordered_map.h:63
virtual std::string Info() const
Turn back information as a string.
Definition: global_pointers_unordered_map.h:106
GlobalPointersUnorderedMap()
Default constructor.
Definition: global_pointers_unordered_map.h:76
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: global_pointers_unordered_map.h:120
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: global_pointers_unordered_map.h:114
friend class Serializer
Definition: global_pointers_unordered_map.h:180
KRATOS_CLASS_POINTER_DEFINITION(GlobalPointersUnorderedMap)
Pointer definition of GlobalPointersUnorderedMap.
virtual ~GlobalPointersUnorderedMap()
Destructor.
Definition: global_pointers_unordered_map.h:79
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
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
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
def load(f)
Definition: ode_solve.py:307
integer i
Definition: TensorModule.f:17