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.
process_info.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: Pooyan Dadvand
11 //
12 //
13 
14 #if !defined( KRATOS_PROCESS_INFO_H_INCLUDED )
15 #define KRATOS_PROCESS_INFO_H_INCLUDED
16 
17 // System includes
18 #include <string>
19 #include <iostream>
20 #include <sstream>
21 #include <cstddef>
22 
23 // External includes
24 
25 // Project includes
26 #include "includes/define.h"
28 #include "containers/flags.h"
29 
30 namespace Kratos
31 {
32 
35 
39 
43 
47 
51 
53 
58 class KRATOS_API(KRATOS_CORE) ProcessInfo : public DataValueContainer, public Flags
59 {
60 public:
63 
66 
68 
69  typedef std::size_t SizeType;
70 
71  typedef std::size_t IndexType;
72 
76 
79  BaseType(),
80  Flags(),
81  mIsTimeStep(true),
82  mSolutionStepIndex(),
83  mpPreviousSolutionStepInfo(),
84  mpPreviousTimeStepInfo()
85  {
86  }
87 
89  ProcessInfo(const ProcessInfo& Other) :
90  BaseType(Other),
91  Flags(Other),
92  mIsTimeStep(Other.mIsTimeStep),
93  mSolutionStepIndex(Other.mSolutionStepIndex),
94  mpPreviousSolutionStepInfo(Other.mpPreviousSolutionStepInfo),
95  mpPreviousTimeStepInfo(Other.mpPreviousTimeStepInfo)
96  {
97  }
98 
100  ~ProcessInfo() override {}
101 
102 
106 
109  {
110  BaseType::operator=(rOther);
111  Flags::operator=(rOther);
112 
113  mIsTimeStep = rOther.mIsTimeStep;
114  mSolutionStepIndex = rOther.mSolutionStepIndex;
115  mpPreviousSolutionStepInfo = rOther.mpPreviousSolutionStepInfo;
116  mpPreviousTimeStepInfo = rOther.mpPreviousTimeStepInfo;
117 
118  return *this;
119  }
120 
124 
125  void CreateTimeStepInfo(IndexType SolutionStepIndex = 0)
126  {
127  CreateSolutionStepInfo(SolutionStepIndex);
128  mIsTimeStep = true;
129  }
130 
131  void CloneTimeStepInfo(IndexType SolutionStepIndex = 0)
132  {
133  CreateSolutionStepInfo(SolutionStepIndex);
134  mIsTimeStep = true;
135  }
136 
137  /* void CloneTimeStepInfo(IndexType SolutionStepIndex, IndexType SourceSolutionStepIndex) */
138  /* { */
139  /* CloneSolutionStepInfo(SolutionStepIndex, SourceSolutionStepIndex); */
140  /* mIsTimeStep = true; */
141  /* } */
142 
143  void CloneTimeStepInfo(IndexType SolutionStepIndex, ProcessInfo const & SourceSolutionStepInfo)
144  {
145  CloneSolutionStepInfo(SolutionStepIndex, SourceSolutionStepInfo);
146  mIsTimeStep = true;
147  }
148 
149  void CreateTimeStepInfo(double NewTime, IndexType SolutionStepIndex = 0)
150  {
151  CreateTimeStepInfo(SolutionStepIndex);
152  SetCurrentTime(NewTime);
153  }
154 
155  void CloneTimeStepInfo(double NewTime, IndexType SourceSolutionStepIndex = 0)
156  {
157  CloneTimeStepInfo(SourceSolutionStepIndex);
158  SetCurrentTime(NewTime);
159  }
160 
161  /* void CloneTimeStepInfo(double NewTime, IndexType SolutionStepIndex = 0) */
162  /* { */
163  /* CloneTimeStepInfo(SolutionStepIndex); */
164  /* SetCurrentTime(NewTime); */
165  /* } */
166 
167  /* void CloneTimeStepInfo(double NewTime, IndexType SolutionStepIndex = 0, IndexType SourceSolutionStepIndex = 0) */
168  /* { */
169  /* CloneTimeStepInfo(SolutionStepIndex, SourceSolutionStepIndex); */
170  /* SetCurrentTime(NewTime); */
171  /* } */
172 
173  void CloneTimeStepInfo(double NewTime, IndexType SolutionStepIndex, ProcessInfo const & SourceSolutionStepInfo)
174  {
175  CloneTimeStepInfo(SolutionStepIndex, SourceSolutionStepInfo);
176  SetCurrentTime(NewTime);
177  }
178 
179  void SetAsTimeStepInfo();
180 
181  void SetAsTimeStepInfo(double NewTime);
182 
183  ProcessInfo::Pointer pGetPreviousTimeStepInfo(IndexType StepsBefore = 1);
184 
185  const ProcessInfo::Pointer pGetPreviousTimeStepInfo(IndexType StepsBefore = 1) const;
186 
188  {
189  return *pGetPreviousTimeStepInfo(StepsBefore);
190  }
191 
192  ProcessInfo const& GetPreviousTimeStepInfo(IndexType StepsBefore = 1) const
193  {
194  return *pGetPreviousTimeStepInfo(StepsBefore);
195  }
196 
198  {
199  return GetPreviousTimeStepInfo(StepsBefore).GetSolutionStepIndex();
200  }
201 
205 
206  void SetCurrentTime(double NewTime);
207 
208  void ReIndexBuffer(SizeType BufferSize, IndexType BaseIndex = 0);
209 
210 
214 
215  void CreateSolutionStepInfo(IndexType SolutionStepIndex = 0);
216 
217 // void CloneSolutionStepInfo(IndexType SolutionStepIndex = 0)
218 // {
219 // mpPreviousSolutionStepInfo = Pointer(new ProcessInfo(*this));
220 // mSolutionStepIndex = SolutionStepIndex;
221 // if(mIsTimeStep)
222 // mpPreviousTimeStepInfo = mpPreviousSolutionStepInfo;
223 // mIsTimeStep = false;
224 // }
225 
226 // void CloneSolutionStepInfo(IndexType SolutionStepIndex = 0, IndexType SourceSolutionStepIndex = 0)
227 // {
228 // ProcessInfo& source_info = FindSolutionStepInfo(SourceSolutionStepIndex);
229 // if(source_info.GetSolutionStepIndex() == SourceSolutionStepIndex)
230 // {
231 // mpPreviousSolutionStepInfo = Pointer(new ProcessInfo(*this));
232 // mSolutionStepIndex = SolutionStepIndex;
233 // BaseType::operator=(source_info);
234 // if(mIsTimeStep)
235 // mpPreviousTimeStepInfo = mpPreviousSolutionStepInfo;
236 // mIsTimeStep = false;
237 // }
238 // else
239 // CreateSolutionStepInfo(SolutionStepIndex);
240 // }
241 
242  void CloneSolutionStepInfo();
243 
244  void CloneSolutionStepInfo(IndexType SourceSolutionStepIndex);
245 
246  void CloneSolutionStepInfo(IndexType SolutionStepIndex, ProcessInfo const & SourceSolutionStepInfo);
247 
248  ProcessInfo& FindSolutionStepInfo(IndexType ThisIndex);
249 
250  void RemoveSolutionStepInfo(IndexType SolutionStepIndex);
251 
252  void ClearHistory(IndexType StepsBefore = 0);
253 
254  ProcessInfo::Pointer pGetPreviousSolutionStepInfo(IndexType StepsBefore = 1);
255 
256  const ProcessInfo::Pointer pGetPreviousSolutionStepInfo(IndexType StepsBefore = 1) const;
257 
259  {
260  return *pGetPreviousSolutionStepInfo(StepsBefore);
261  }
262 
263  ProcessInfo const& GetPreviousSolutionStepInfo(IndexType StepsBefore = 1) const
264  {
265  return *pGetPreviousSolutionStepInfo(StepsBefore);
266  }
267 
269  {
270  return GetPreviousSolutionStepInfo(StepsBefore).GetSolutionStepIndex();
271  }
272 
276 
278  {
279  return mSolutionStepIndex;
280  }
281 
283  {
284  mSolutionStepIndex = NewIndex;
285  }
286 
290 
291 
295 
297  std::string Info() const override
298  {
299  return "Process Info";
300  }
301 
303  void PrintInfo(std::ostream& rOStream) const override
304  {
305  rOStream << Info();
306  }
307 
309  void PrintData(std::ostream& rOStream) const override
310  {
311  rOStream << " Current solution step index : " << mSolutionStepIndex << std::endl;
312  BaseType::PrintData(rOStream);
313  }
314 
318 
319 
321 
322 protected:
325 
326 
330 
331 
335 
336 
340 
341 
345 
346 
350 
351 
355 
356 
358 
359 private:
362 
363 
367 
368  bool mIsTimeStep;
369 
370  IndexType mSolutionStepIndex;
371 
372  ProcessInfo::Pointer mpPreviousSolutionStepInfo;
373 
374  ProcessInfo::Pointer mpPreviousTimeStepInfo;
375 
379 
380 
384 
388 
389  friend class Serializer;
390 
391  void save(Serializer& rSerializer) const override;
392 
393  void load(Serializer& rSerializer) override;
394 
398 
399 
403 
404 
408 
409 
411 
412 }; // Class ProcessInfo
413 
415 
418 
419 
423 
424 
426 inline std::istream& operator >> (std::istream& rIStream,
427  ProcessInfo& rThis);
428 
430 inline std::ostream& operator << (std::ostream& rOStream,
431  const ProcessInfo& rThis)
432 {
433  rThis.PrintInfo(rOStream);
434  rOStream << std::endl;
435  rThis.PrintData(rOStream);
436 
437  return rOStream;
438 }
440 
441 
442 } // namespace Kratos.
443 
444 #endif // KRATOS_PROCESS_INFO_H_INCLUDED defined
445 
446 
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Container for storing data values associated with variables.
Definition: data_value_container.h:63
Definition: flags.h:58
std::size_t IndexType
Definition: flags.h:74
Flags & operator=(Flags const &rOther)
Assignment operator.
Definition: flags.h:151
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
ProcessInfo()
Default constructor.
Definition: process_info.h:78
IndexType GetPreviousSolutionStepIndex(IndexType StepsBefore=1) const
Definition: process_info.h:268
ProcessInfo const & GetPreviousSolutionStepInfo(IndexType StepsBefore=1) const
Definition: process_info.h:263
void CreateTimeStepInfo(IndexType SolutionStepIndex=0)
Definition: process_info.h:125
~ProcessInfo() override
Destructor.
Definition: process_info.h:100
IndexType GetPreviousTimeStepIndex(IndexType StepsBefore=1) const
Definition: process_info.h:197
void CreateTimeStepInfo(double NewTime, IndexType SolutionStepIndex=0)
Definition: process_info.h:149
void CloneTimeStepInfo(double NewTime, IndexType SourceSolutionStepIndex=0)
Definition: process_info.h:155
std::size_t SizeType
Definition: process_info.h:69
void SetSolutionStepIndex(IndexType NewIndex)
Definition: process_info.h:282
ProcessInfo const & GetPreviousTimeStepInfo(IndexType StepsBefore=1) const
Definition: process_info.h:192
ProcessInfo & GetPreviousSolutionStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:258
std::size_t IndexType
Definition: process_info.h:71
ProcessInfo(const ProcessInfo &Other)
Copy constructor.
Definition: process_info.h:89
DataValueContainer BaseType
Definition: process_info.h:67
void CloneTimeStepInfo(double NewTime, IndexType SolutionStepIndex, ProcessInfo const &SourceSolutionStepInfo)
Definition: process_info.h:173
void CloneTimeStepInfo(IndexType SolutionStepIndex=0)
Definition: process_info.h:131
ProcessInfo & operator=(const ProcessInfo &rOther)
Assignment operator.
Definition: process_info.h:108
ProcessInfo & GetPreviousTimeStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:187
void CloneTimeStepInfo(IndexType SolutionStepIndex, ProcessInfo const &SourceSolutionStepInfo)
Definition: process_info.h:143
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: process_info.h:309
std::string Info() const override
Turn back information as a string.
Definition: process_info.h:297
IndexType GetSolutionStepIndex() const
Definition: process_info.h:277
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: process_info.h:303
KRATOS_CLASS_POINTER_DEFINITION(ProcessInfo)
Pointer definition of ProcessInfo.
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
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::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
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