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.
variable_expression_io.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: Suneth Warnakulasuriya
11 //
12 
13 #pragma once
14 
15 // System incldues
16 #include <variant>
17 
18 // Project includes
19 #include "containers/array_1d.h"
21 #include "expression/traits.h"
22 #include "containers/variable.h"
23 #include "expression_io.h"
24 #include "includes/define.h"
25 #include "includes/model_part.h"
27 
28 namespace Kratos {
29 
30 
31 class KRATOS_API(KRATOS_CORE) VariableExpressionIO
32 {
33 public:
36 
37  using VariableType = std::variant<
38  const Variable<int>*,
39  const Variable<double>*,
44  const Variable<Vector>*,
45  const Variable<Matrix>*>;
46 
50 
51  class KRATOS_API(KRATOS_CORE) Input : public ExpressionInput
52  {
53  public:
56 
58 
62 
63  Input(
64  const ModelPart& rModelPart,
65  const VariableType& rVariable,
66  Globals::DataLocation CurrentLocation,
67  MeshType CurrentMeshType = MeshType::Local);
68 
69  ~Input() override = default;
70 
74 
75  Expression::Pointer Execute() const override;
76 
78 
79  private:
82 
83  ModelPart const * mpModelPart;
84 
85  VariableType mpVariable;
86 
87  Globals::DataLocation mDataLocation;
88 
89  MeshType mMeshType;
90 
92 
93  };
94 
95  class KRATOS_API(KRATOS_CORE) Output : public ExpressionOutput
96  {
97  public:
100 
102 
106 
107  Output(
108  ModelPart& rModelPart,
109  const VariableType& rVariable,
110  Globals::DataLocation CurrentLocation,
111  MeshType CurrentMeshType = MeshType::Local);
112 
113  ~Output() override = default;
114 
118 
119  void Execute(const Expression& rExpression) override;
120 
122 
123  private:
126 
127  ModelPart * mpModelPart;
128 
129  VariableType mpVariable;
130 
131  Globals::DataLocation mDataLocation;
132 
133  MeshType mMeshType;
134 
136 
137  };
138 
142 
143  template<MeshType TMeshType>
144  KRATOS_API(KRATOS_CORE) static void Read(
146  const VariableType& rVariable,
147  const bool IsHistorical);
148 
149  template<class TContainerType, MeshType TMeshType>
150  KRATOS_API(KRATOS_CORE) static void Read(
152  const VariableType& rVariable);
153 
154  template<MeshType TMeshType>
155  KRATOS_API(KRATOS_CORE) static void Write(
157  const VariableType& rVariable,
158  const bool IsHistorical);
159 
160  template<class TContainerType, MeshType TMeshType>
161  KRATOS_API(KRATOS_CORE) static void Write(
162  const ContainerExpression<TContainerType, TMeshType>& rContainerExpression,
163  const VariableType& rVariable);
164 
166 
167 }; // class ExpressionIO
168 
169 
170 } // namespace Kratos
Container variable data holder.
Definition: container_expression.h:80
Base class or all the expression types.
Definition: expression.h:38
Kratos::intrusive_ptr< Expression > Pointer
Definition: expression.h:44
Definition: expression_io.h:25
Definition: expression_io.h:69
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Definition: variable_expression_io.h:52
Definition: variable_expression_io.h:96
Definition: variable_expression_io.h:32
std::variant< const Variable< int > *, const Variable< double > *, const Variable< array_1d< double, 3 > > *, const Variable< array_1d< double, 4 > > *, const Variable< array_1d< double, 6 > > *, const Variable< array_1d< double, 9 > > *, const Variable< Vector > *, const Variable< Matrix > * > VariableType
Definition: variable_expression_io.h:45
#define KRATOS_API(...)
Definition: kratos_export_api.h:40
DataLocation
Enum for location of data.
Definition: global_variables.h:48
void Read(LiteralFlatExpression< std::conditional_t< std::is_same_v< TDataType, int >, int, double >> &rExpression, const IndexType EntityDataBeginIndex, const TDataType &rValue, std::index_sequence< TIndex... >)
Definition: variable_expression_data_io.cpp:31
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
MeshType
Definition: traits.h:19
@ Local
Definition: traits.h:20