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.
indexed_object.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 
14 #pragma once
15 
16 // System includes
17 #include <iostream>
18 
19 // External includes
20 
21 // Project includes
22 #include "includes/define.h"
23 #include "includes/serializer.h"
24 
25 namespace Kratos
26 {
29 
33 
37 
41 
45 
54 {
55 public:
58 
61 
63  typedef std::size_t IndexType;
64 
66  typedef std::size_t result_type;
67 
71 
73  explicit IndexedObject(IndexType NewId = 0) : mId(NewId) {}
74 
76  virtual ~IndexedObject() {}
77 
79  IndexedObject(IndexedObject const& rOther) : mId(rOther.mId) {}
80 
84 
87  {
88  mId = rOther.mId;
89 
90  return *this;
91  }
92 
93  template<class TObjectType>
94  IndexType operator()(TObjectType const& rThisObject) const
95  {
96  return rThisObject.Id();
97  }
98 
102 
106 
107  IndexType Id() const
108  {
109  return mId;
110  }
111 
112  IndexType GetId() const
113  {
114  return mId;
115  }
116 
117  virtual void SetId(IndexType NewId)
118  {
119  mId = NewId;
120  }
121 
124  {
125  return mId;
126  }
127 
131 
135 
137  virtual std::string Info() const
138  {
139  std::stringstream buffer;
140  buffer << "indexed object # "
141  << mId;
142  return buffer.str();
143  }
144 
146  virtual void PrintInfo(std::ostream& rOStream) const
147  {
148  rOStream << Info();
149  }
150 
152  virtual void PrintData(std::ostream& rOStream) const
153  {
154  }
155 
159 
161 protected:
164 
168 
172 
176 
180 
184 
188 
190 private:
193 
197 
198  IndexType mId;
199 
203 
207 
211 
212  friend class Serializer;
213 
214  virtual void save(Serializer& rSerializer) const
215  {
216  rSerializer.save("Id",mId);
217  }
218 
219  virtual void load(Serializer& rSerializer)
220  {
221  rSerializer.load("Id",mId);
222  }
223 
227 
231 
235 
237 
238 }; // Class IndexedObject
239 
241 
244 
248 
250 inline std::istream& operator >> (std::istream& rIStream,
251  IndexedObject& rThis);
252 
254 inline std::ostream& operator << (std::ostream& rOStream,
255  const IndexedObject& rThis)
256 {
257  rThis.PrintInfo(rOStream);
258  rOStream << std::endl;
259  rThis.PrintData(rOStream);
260 
261  return rOStream;
262 }
264 
265 } // namespace Kratos.
266 
This object defines an indexed object.
Definition: indexed_object.h:54
std::size_t result_type
The definition of the result_type.
Definition: indexed_object.h:66
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: indexed_object.h:146
IndexedObject(IndexedObject const &rOther)
Copy constructor.
Definition: indexed_object.h:79
IndexedObject & operator=(IndexedObject const &rOther)
Assignment operator.
Definition: indexed_object.h:86
virtual std::string Info() const
Turn back information as a string.
Definition: indexed_object.h:137
IndexedObject(IndexType NewId=0)
Default constructor.
Definition: indexed_object.h:73
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: indexed_object.h:152
KRATOS_CLASS_POINTER_DEFINITION(IndexedObject)
Pointer definition of IndexedObject.
IndexType & DepricatedIdAccess()
TODO: remove this function when removing data_file_io object.
Definition: indexed_object.h:123
std::size_t IndexType
The definition of the index type.
Definition: indexed_object.h:63
virtual ~IndexedObject()
Destructor.
Definition: indexed_object.h:76
IndexType operator()(TObjectType const &rThisObject) const
Definition: indexed_object.h:94
IndexType Id() const
Definition: indexed_object.h:107
virtual void SetId(IndexType NewId)
Definition: indexed_object.h:117
IndexType GetId() const
Definition: indexed_object.h:112
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
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
def load(f)
Definition: ode_solve.py:307