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.
table_accessor.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: Alejandro Cornejo
11 // Riccardo Rossi
12 // Carlos Roig
13 // Ruben Zorrilla
14 //
15 
16 # pragma once
17 
18 // System includes
19 
20 // External includes
21 
22 // Project includes
23 #include "includes/accessor.h"
24 
25 namespace Kratos
26 {
29 
32 
41 class KRATOS_API(KRATOS_CORE) TableAccessor : public Accessor
42 {
43 public:
46 
49 
52 
54  using BaseType = Accessor;
55 
57 
58  using SizeType = std::size_t;
59 
62 
67  {}
68 
70  TableAccessor(VariableType& rInputVariable, const std::string& rInputVariableType = "node_historical")
71  : mpInputVariable(&rInputVariable)
72  {
73  // We initialize the variable type only once
74  if (rInputVariableType == "node_historical") {
75  mInputVariableType = Globals::DataLocation::NodeHistorical;
76  } else if (rInputVariableType == "node_non_historical") {
77  mInputVariableType = Globals::DataLocation::NodeNonHistorical;
78  } else if (rInputVariableType == "element") {
79  mInputVariableType = Globals::DataLocation::Element;
80  } else {
81  KRATOS_ERROR << "The table_input_variable_type is incorrect or not supported. Types available are : 'node_historical', 'node_non_historical' and 'element'" << std::endl;
82  }
83  }
84 
86  TableAccessor(const TableAccessor& rOther)
87  : BaseType(rOther),
88  mpInputVariable(rOther.mpInputVariable),
89  mInputVariableType(rOther.mInputVariableType)
90  {}
91 
95 
105  double GetValue(
106  const Variable<double>& rVariable,
107  const Properties& rProperties,
108  const GeometryType& rGeometry,
109  const Vector& rShapeFunctionVector,
110  const ProcessInfo& rProcessInfo
111  ) const override;
112 
117  double GetValueFromTable(
118  const Variable<double>& rIndependentVariable,
119  const Variable<double>& rDependentVariable,
120  const Properties& rProperties,
121  const GeometryType& rGeometry,
122  const Vector& rShapeFunctionVector,
123  const ProcessInfo& rProcessInfo) const;
124 
125 
130  {
131  return *mpInputVariable;
132  }
133 
134  // Getting a pointer to the class
135  Accessor::UniquePointer Clone() const override;
136 
140 
142  std::string Info() const override
143  {
144  std::stringstream buffer;
145  buffer << "TableAccessor" ;
146 
147  return buffer.str();
148  }
149 
151  void PrintInfo(std::ostream& rOStream) const override {rOStream << "TableAccessor";}
152 
154  void PrintData(std::ostream& rOStream) const override {rOStream << "TableAccessor class";}
155 
157 
158 private:
159 
162 
163  VariableType* mpInputVariable;
164  Globals::DataLocation mInputVariableType = Globals::DataLocation::NodeHistorical; // NodalHistorical by default
165 
166  friend class Serializer;
167 
168  void save(Serializer &rSerializer) const override;
169 
170  void load(Serializer &rSerializer) override;
171 
172 }; // class
174 
176 
177 } // namespace Kratos
This class defines the way a certain property is accessed.
Definition: accessor.h:43
Geometry base class.
Definition: geometry.h:71
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
This class defines the way a certain property is accessed according to a table.
Definition: table_accessor.h:42
TableAccessor(const TableAccessor &rOther)
Copy constructor.
Definition: table_accessor.h:86
TableAccessor(VariableType &rInputVariable, const std::string &rInputVariableType="node_historical")
Custom constructor.
Definition: table_accessor.h:70
std::string Info() const override
Turn back information as a string.
Definition: table_accessor.h:142
VariableType & GetInputVariable() const
Returns the member input variable.
Definition: table_accessor.h:129
TableAccessor()
Definition: table_accessor.h:66
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: table_accessor.h:151
KRATOS_CLASS_POINTER_DEFINITION(TableAccessor)
Pointer definition of TableAccessor.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: table_accessor.h:154
std::size_t SizeType
Definition: table_accessor.h:58
#define KRATOS_ERROR
Definition: exception.h:161
DataLocation
Enum for location of data.
Definition: global_variables.h:48
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
def load(f)
Definition: ode_solve.py:307