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.
result_dabatase.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: Vicente Mataix Ferrandiz
11 //
12 
13 #if !defined(KRATOS_RESULT_DATABASE_H_INCLUDED )
14 #define KRATOS_RESULT_DATABASE_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 #include <unordered_map>
20 
21 // Project includes
22 #include "includes/table.h"
23 
24 namespace Kratos
25 {
26 
29 
33 
37 
41 
45 
53 {
54 public:
57 
60 
62  typedef std::vector<Table<double, double>*> GPDatabaseType;
63 
65  typedef std::vector<GPDatabaseType> DataType;
66 
68  typedef std::size_t IndexType;
69 
71  typedef std::size_t SizeType;
72 
76 
81  const SizeType SizeVector,
82  const GPDatabaseType& rBaseData
83  ) : mData(SizeVector, rBaseData)
84  {
85  }
86 
88  virtual ~EntityDatabase()
89  {
90  this->Clear();
91  }
92 
95  : mData(rOther.mData)
96  {
97  }
98 
102 
107  GPDatabaseType& operator[](const std::size_t i)
108  {
109  return mData[i];
110  }
111 
115 
119  DataType::iterator begin()
120  {
121  return mData.begin();
122  }
123 
127  DataType::const_iterator begin() const
128  {
129  return mData.begin();
130  }
131 
135  DataType::iterator end()
136  {
137  return mData.end();
138  }
139 
143  DataType::const_iterator end() const
144  {
145  return mData.end();
146  }
147 
152  const GPDatabaseType& GetResultaData(const SizeType GPIndex = 0) const;
153 
160  double GetValue(
161  const double Time,
162  const SizeType ComponentIndex = 0,
163  const SizeType GPIndex = 0
164  ) const;
165 
173  void SetValues(
174  const Vector& rValuesX,
175  const Vector& rValuesY,
176  const SizeType ComponentIndex = 0,
177  const SizeType GPIndex = 0
178  );
179 
183  void Clear();
184 
188 
190  virtual std::string Info() const
191  {
192  return "EntityDatabase";
193  }
194 
196  virtual void PrintInfo(std::ostream& rOStream) const
197  {
198  rOStream << "EntityDatabase";
199  }
200 
202  virtual void PrintData(std::ostream& rOStream) const
203  {
204  }
205 protected:
208 
212 
213  DataType mData; // The database storing the values
214 
216 
217 }; // Class EntityDatabase
218 
226 {
227 public:
230 
233 
235  typedef std::vector<EntityDatabase> DataType;
236 
238  typedef std::size_t IndexType;
239 
241  typedef std::size_t SizeType;
242 
246 
251  const SizeType SizeVector,
252  const EntityDatabase& rBaseData
253  ) : mData(SizeVector, rBaseData)
254  {
255  }
256 
259  {
260  this->Clear();
261  }
262 
265  : mData(rOther.mData)
266  {
267  }
268 
272 
277  EntityDatabase& operator[](const std::size_t i)
278  {
279  return mData[i];
280  }
281 
285 
289  DataType::iterator begin()
290  {
291  return mData.begin();
292  }
293 
297  DataType::const_iterator begin() const
298  {
299  return mData.begin();
300  }
301 
305  DataType::iterator end()
306  {
307  return mData.end();
308  }
309 
313  DataType::const_iterator end() const
314  {
315  return mData.end();
316  }
317 
322  const EntityDatabase& GetEntityData(const IndexType EntityIndex) const;
323 
331  double GetValue(
332  const IndexType EntityIndex,
333  const double Time,
334  const SizeType ComponentIndex = 0,
335  const SizeType GPIndex = 0
336  ) const;
337 
346  void SetValues(
347  const Vector& rValuesX,
348  const Vector& rValuesY,
349  const IndexType EntityIndex,
350  const SizeType ComponentIndex = 0,
351  const SizeType GPIndex = 0
352  );
353 
357  void Clear();
358 
362 
364  virtual std::string Info() const
365  {
366  return "VariableDatabase";
367  }
368 
370  virtual void PrintInfo(std::ostream& rOStream) const
371  {
372  rOStream << "VariableDatabase";
373  }
374 
376  virtual void PrintData(std::ostream& rOStream) const
377  {
378  }
379 protected:
382 
386 
387  DataType mData; // The database storing the values
388 
390 }; // Class VariableDatabase
391 
403 {
404 public:
407 
410 
412  typedef std::size_t IndexType;
413 
415  typedef std::size_t SizeType;
416 
420 
425 
427  virtual ~ResultDatabase()
428  {
429  this->Clear();
430  }
431 
434  : mData(rOther.mData),
436  {
437  }
438 
442 
446 
452  void Initialize(
453  const std::vector<IndexType>& rVariablesIndexes,
454  const std::vector<IndexType>& rValuesSizes,
455  const SizeType NumberOfEntites,
456  const SizeType NumberOfGP = 1
457  );
458 
464  template<class TVariableType>
465  VariableDatabase& GetVariableData(const TVariableType& rVariable)
466  {
467  const auto it = mData.find(rVariable.Key());
468  if (it != mData.end()) {
469  return it->second;
470  } else {
471  KRATOS_ERROR << "Not allocated Variable: " << rVariable.Name() << std::endl;
472  }
473  }
474 
480  template<class TVariableType>
481  const VariableDatabase& GetVariableData(const TVariableType& rVariable) const
482  {
483  const auto it = mData.find(rVariable.Key());
484  if (it != mData.end()) {
485  return it->second;
486  } else {
487  KRATOS_ERROR << "Not allocated Variable: " << rVariable.Name() << std::endl;
488  }
489  }
490 
501  template<class TVariableType>
502  void SetValues(
503  const Vector& rValuesX,
504  const Vector& rValuesY,
505  const TVariableType& rVariable,
506  const IndexType EntityIndex,
507  const SizeType ComponentIndex = 0,
508  const SizeType GPIndex = 0
509  )
510  {
511  auto it = mData.find(rVariable.Key());
512  if (it != mData.end()) {
513  auto& r_database = it->second;
514  r_database.SetValues(rValuesX, rValuesY, EntityIndex, ComponentIndex, GPIndex);
515  } else {
516  KRATOS_ERROR << "Not allocated Variable: " << rVariable.Name() << std::endl;
517  }
518  }
519 
523  void Clear();
524 
528  int Check();
529 
533 
539  {
540  return mCommonColumn;
541  }
542 
547  void SetCommonColumn(const Vector& rCommonColumn)
548  {
549  mCommonColumn = rCommonColumn;
550  }
551 
555 
559 
561  virtual std::string Info() const
562  {
563  return "ResultDatabase";
564  }
565 
567  virtual void PrintInfo(std::ostream& rOStream) const
568  {
569  rOStream << "ResultDatabase";
570  }
571 
573  virtual void PrintData(std::ostream& rOStream) const
574  {
575  }
576 
577 protected:
580 
584 
585  std::unordered_map<IndexType, VariableDatabase> mData; // The database storing the values
586 
588 
590 
591 }; // Class ResultDatabase
592 
594 
597 
598 
602 
604 
605 
606 } // namespace Kratos.
607 
608 #endif // KRATOS_RESULT_DATABASE_H_INCLUDED defined
This class stores the results of a entity.
Definition: result_dabatase.h:53
std::size_t SizeType
The definition of the sizetype.
Definition: result_dabatase.h:71
virtual ~EntityDatabase()
Destructor.
Definition: result_dabatase.h:88
DataType::const_iterator begin() const
The const begin iterator.
Definition: result_dabatase.h:127
DataType::iterator end()
The end iterator.
Definition: result_dabatase.h:135
std::size_t IndexType
The definition of the index type.
Definition: result_dabatase.h:68
DataType mData
Definition: result_dabatase.h:213
double GetValue(const double Time, const SizeType ComponentIndex=0, const SizeType GPIndex=0) const
This method retrieves the interpolated value from the database.
Definition: result_dabatase.cpp:32
const GPDatabaseType & GetResultaData(const SizeType GPIndex=0) const
This method retrieves the entity database.
Definition: result_dabatase.cpp:23
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: result_dabatase.h:196
void SetValues(const Vector &rValuesX, const Vector &rValuesY, const SizeType ComponentIndex=0, const SizeType GPIndex=0)
This method set the values into the tables.
Definition: result_dabatase.cpp:45
DataType::iterator begin()
The begin iterator.
Definition: result_dabatase.h:119
std::vector< Table< double, double > * > GPDatabaseType
GP database definition.
Definition: result_dabatase.h:62
EntityDatabase(EntityDatabase const &rOther)
Copy constructor.
Definition: result_dabatase.h:94
GPDatabaseType & operator[](const std::size_t i)
The [] operator.
Definition: result_dabatase.h:107
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: result_dabatase.h:202
std::vector< GPDatabaseType > DataType
Base type definition.
Definition: result_dabatase.h:65
EntityDatabase(const SizeType SizeVector, const GPDatabaseType &rBaseData)
Default constructor.
Definition: result_dabatase.h:80
virtual std::string Info() const
Turn back information as a string.
Definition: result_dabatase.h:190
KRATOS_CLASS_POINTER_DEFINITION(EntityDatabase)
Pointer definition of ResultDatabase.
void Clear()
This function is designed for clear all the databases.
Definition: result_dabatase.cpp:71
DataType::const_iterator end() const
The const end iterator.
Definition: result_dabatase.h:143
This class stores the results of a simulation for a later comparison.
Definition: result_dabatase.h:403
std::unordered_map< IndexType, VariableDatabase > mData
Definition: result_dabatase.h:585
void Clear()
This function is designed for clear all the databases.
Definition: result_dabatase.cpp:177
virtual ~ResultDatabase()
Destructor.
Definition: result_dabatase.h:427
const VariableDatabase & GetVariableData(const TVariableType &rVariable) const
This method retrieves the variable database.
Definition: result_dabatase.h:481
Vector mCommonColumn
Definition: result_dabatase.h:587
ResultDatabase(ResultDatabase const &rOther)
Copy constructor.
Definition: result_dabatase.h:433
virtual std::string Info() const
Turn back information as a string.
Definition: result_dabatase.h:561
Vector & GetCommonColumn()
This method returns the common column vector.
Definition: result_dabatase.h:538
ResultDatabase()
Default constructor.
Definition: result_dabatase.h:424
void Initialize(const std::vector< IndexType > &rVariablesIndexes, const std::vector< IndexType > &rValuesSizes, const SizeType NumberOfEntites, const SizeType NumberOfGP=1)
This method initializes the database.
Definition: result_dabatase.cpp:137
int Check()
This function is designed for being called after ExecuteInitialize ONCE to verify that the input is c...
Definition: result_dabatase.cpp:198
KRATOS_CLASS_POINTER_DEFINITION(ResultDatabase)
Pointer definition of ResultDatabase.
void SetCommonColumn(const Vector &rCommonColumn)
This method sets the common column.
Definition: result_dabatase.h:547
void SetValues(const Vector &rValuesX, const Vector &rValuesY, const TVariableType &rVariable, const IndexType EntityIndex, const SizeType ComponentIndex=0, const SizeType GPIndex=0)
This method set the values into the tables.
Definition: result_dabatase.h:502
std::size_t SizeType
The definition of the sizetype.
Definition: result_dabatase.h:415
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: result_dabatase.h:573
VariableDatabase & GetVariableData(const TVariableType &rVariable)
This method retrieves the variable database.
Definition: result_dabatase.h:465
std::size_t IndexType
The definition of the index type.
Definition: result_dabatase.h:412
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: result_dabatase.h:567
This class stores the results of a variable.
Definition: result_dabatase.h:226
std::size_t SizeType
The definition of the sizetype.
Definition: result_dabatase.h:241
DataType::const_iterator end() const
The const end iterator.
Definition: result_dabatase.h:313
virtual ~VariableDatabase()
Destructor.
Definition: result_dabatase.h:258
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: result_dabatase.h:376
EntityDatabase & operator[](const std::size_t i)
The [] operator.
Definition: result_dabatase.h:277
double GetValue(const IndexType EntityIndex, const double Time, const SizeType ComponentIndex=0, const SizeType GPIndex=0) const
This method retrieves the interpolated value from the database.
Definition: result_dabatase.cpp:94
void SetValues(const Vector &rValuesX, const Vector &rValuesY, const IndexType EntityIndex, const SizeType ComponentIndex=0, const SizeType GPIndex=0)
This method set the values into the tables.
Definition: result_dabatase.cpp:108
DataType::iterator begin()
The begin iterator.
Definition: result_dabatase.h:289
std::vector< EntityDatabase > DataType
Base type definition.
Definition: result_dabatase.h:235
std::size_t IndexType
The definition of the index type.
Definition: result_dabatase.h:238
const EntityDatabase & GetEntityData(const IndexType EntityIndex) const
This method retrieves the entity database.
Definition: result_dabatase.cpp:85
void Clear()
This function is designed for clear all the databases.
Definition: result_dabatase.cpp:123
virtual std::string Info() const
Turn back information as a string.
Definition: result_dabatase.h:364
VariableDatabase(VariableDatabase const &rOther)
Copy constructor.
Definition: result_dabatase.h:264
DataType mData
Definition: result_dabatase.h:387
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: result_dabatase.h:370
DataType::const_iterator begin() const
The const begin iterator.
Definition: result_dabatase.h:297
DataType::iterator end()
The end iterator.
Definition: result_dabatase.h:305
KRATOS_CLASS_POINTER_DEFINITION(VariableDatabase)
Pointer definition of ResultDatabase.
VariableDatabase(const SizeType SizeVector, const EntityDatabase &rBaseData)
Default constructor.
Definition: result_dabatase.h:250
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_ERROR
Definition: exception.h:161
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
integer i
Definition: TensorModule.f:17