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.
periodic_variables_container.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: Jordi Cotela Dalmau
11 //
12 //
13 
14 #ifndef KRATOS_PERIODIC_VARIABLES_CONTAINER_H
15 #define KRATOS_PERIODIC_VARIABLES_CONTAINER_H
16 
17 // System includes
18 #include <string>
19 #include <iostream>
20 
21 
22 // External includes
23 #include <boost/iterator/indirect_iterator.hpp>
24 
25 // Project includes
26 #include "includes/define.h"
27 #include "includes/serializer.h"
28 #include "containers/variable.h"
29 
30 
31 namespace Kratos
32 {
35 
38 
42 
46 
50 
54 
56 
60 {
61 public:
64 
67 
70 
72  typedef std::vector<const DoubleVariableType*> DoubleVariablesContainerType;
73 
75  typedef boost::indirect_iterator<DoubleVariablesContainerType::const_iterator> DoubleVariablesConstIterator;
76 
77  typedef std::size_t SizeType;
78 
82 
85  mPeriodicDoubleVars()
86  {
87  }
88 
91  mPeriodicDoubleVars(rOther.mPeriodicDoubleVars)
92  {
93  }
94 
97  {
98  }
99 
100 
104 
107  {
108  this->mPeriodicDoubleVars = rOther.mPeriodicDoubleVars;
109  return *this;
110  }
111 
115 
117  void Add(DoubleVariableType const& rThisVariable)
118  {
119  mPeriodicDoubleVars.push_back(&rThisVariable);
120  }
121 
123  void Clear()
124  {
125  mPeriodicDoubleVars.clear();
126  }
127 
131 
134  {
135  return DoubleVariablesConstIterator( mPeriodicDoubleVars.begin() );
136  }
137 
140  {
141  return DoubleVariablesConstIterator( mPeriodicDoubleVars.end() );
142  }
143 
145  SizeType size() const
146  {
147  return mPeriodicDoubleVars.size();
148  }
149 
153 
154 
158 
160  std::string Info() const
161  {
162  std::stringstream buffer;
163  buffer << "PeriodicVariablesContainer";
164  return buffer.str();
165  }
166 
168  void PrintInfo(std::ostream& rOStream) const
169  {
170  rOStream << "PeriodicVariablesContainer";
171  }
172 
174  void PrintData(std::ostream& rOStream) const
175  {
176  rOStream << "Double Variables:" << std::endl;
177  for (DoubleVariablesContainerType::const_iterator it = mPeriodicDoubleVars.begin(); it != mPeriodicDoubleVars.end(); ++it)
178  {
179  (*it)->PrintInfo(rOStream);
180  rOStream << std::endl;
181  }
182  }
183 
184 
188 
189 
191 
192 protected:
195 
196 
200 
201 
205 
206 
210 
211 
215 
216 
220 
221 
225 
226 
228 
229 private:
232 
233 
237 
239  DoubleVariablesContainerType mPeriodicDoubleVars;
240 
241 
245 
246 
250 
254 
255  friend class Serializer;
256 
257  virtual void save(Serializer& rSerializer) const
258  {
259  std::size_t DoubleVarSize= mPeriodicDoubleVars.size();
260  rSerializer.save("DoubleVarSize",DoubleVarSize);
261  for(std::size_t i = 0; i < DoubleVarSize; i++)
262  rSerializer.save("Variable Name", mPeriodicDoubleVars[i]->Name());
263  }
264 
265  virtual void load(Serializer& rSerializer)
266  {
267  std::string Name;
268  std::size_t DoubleVarSize;
269  rSerializer.load("DoubleVarSize",DoubleVarSize);
270  for(std::size_t i = 0; i < DoubleVarSize; i++)
271  {
272  rSerializer.load("Variable Name", Name);
274  }
275  }
276 
280 
281 
285 
286 
290 
291 
293 
294 }; // Class PeriodicVariablesContainer
295 
297 
300 
301 
305 
306 
308 inline std::istream & operator >>(std::istream& rIStream,
310 {
311  return rIStream;
312 }
313 
315 inline std::ostream & operator <<(std::ostream& rOStream,
316  const PeriodicVariablesContainer& rThis)
317 {
318  rThis.PrintInfo(rOStream);
319  rOStream << std::endl;
320  rThis.PrintData(rOStream);
321 
322  return rOStream;
323 }
325 
327 
328 } // namespace Kratos.
329 
330 #endif /* KRATOS_PERIODIC_VARIABLES_CONTAINER_H */
331 
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
A container of Kratos variables used to define a periodic boundary condition.
Definition: periodic_variables_container.h:60
Variable< double > DoubleVariableType
Kratos double Variable.
Definition: periodic_variables_container.h:69
DoubleVariablesConstIterator DoubleVariablesEnd() const
Iterator for the list of scalar variables.
Definition: periodic_variables_container.h:139
PeriodicVariablesContainer()
Default constructor.
Definition: periodic_variables_container.h:84
boost::indirect_iterator< DoubleVariablesContainerType::const_iterator > DoubleVariablesConstIterator
Double Variable iterator.
Definition: periodic_variables_container.h:75
PeriodicVariablesContainer(PeriodicVariablesContainer const &rOther)
Copy constructor.
Definition: periodic_variables_container.h:90
DoubleVariablesConstIterator DoubleVariablesBegin() const
Iterator for the list of scalar variables.
Definition: periodic_variables_container.h:133
std::vector< const DoubleVariableType * > DoubleVariablesContainerType
Container of pointers to Kratos double variables.
Definition: periodic_variables_container.h:72
std::string Info() const
Turn back information as a string.
Definition: periodic_variables_container.h:160
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: periodic_variables_container.h:168
~PeriodicVariablesContainer()
Destructor.
Definition: periodic_variables_container.h:96
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: periodic_variables_container.h:174
SizeType size() const
Total number of periodic variables (including scalars and vector components)
Definition: periodic_variables_container.h:145
PeriodicVariablesContainer & operator=(PeriodicVariablesContainer const &rOther)
Assignment operator.
Definition: periodic_variables_container.h:106
void Add(DoubleVariableType const &rThisVariable)
Add a scalar variable to the list of variables where periodic conditions will be imposed.
Definition: periodic_variables_container.h:117
KRATOS_CLASS_POINTER_DEFINITION(PeriodicVariablesContainer)
Pointer definition of PeriodicVariablesContainer.
void Clear()
Erase all information contained in this object.
Definition: periodic_variables_container.h:123
std::size_t SizeType
Definition: periodic_variables_container.h:77
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
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
integer i
Definition: TensorModule.f:17