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_data_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 includes
16 #include <vector>
17 #include <type_traits>
18 
19 // Project includes
20 #include "expression/expression.h"
22 
23 namespace Kratos {
24 
27 
33 template<class TDataType>
34 class KRATOS_API(KRATOS_CORE) VariableExpressionDataIO
35 {
36 public:
39 
40  using Pointer = std::shared_ptr<VariableExpressionDataIO<TDataType>>;
41 
42  using IndexType = std::size_t;
43 
44  using RawType = std::conditional_t<
45  std::disjunction_v<
46  std::is_same<TDataType, int>,
47  std::is_same<TDataType, std::vector<int>>
48  >, int, double>;
49 
51 
55 
64  VariableExpressionDataIO(const TDataType& SampleValue);
65 
71  VariableExpressionDataIO(const std::vector<IndexType>& rShape);
72 
76 
83  static Pointer Create(const TDataType& SampleValue);
84 
91  static Pointer Create(const std::vector<IndexType>& rShape);
92 
105  void Assign(
106  TDataType& rOutput,
107  const Expression& rExpression,
108  const IndexType EntityIndex) const;
109 
122  void Read(
123  RawLiteralFlatExpression& rExpression,
124  const IndexType EntityIndex,
125  const TDataType& Value) const;
126 
132  const std::vector<IndexType> GetItemShape() const { return mShape; }
133 
135 private:
138 
139  std::vector<IndexType> mShape;
140 
142 };
143 
144 } // namespace Kratos
Base class or all the expression types.
Definition: expression.h:38
Expression to hold a literal with a flattened data structure.
Definition: literal_flat_expression.h:39
Construct class to read into expressions from templated data values and write in to templated data va...
Definition: variable_expression_data_io.h:35
std::shared_ptr< VariableExpressionDataIO< TDataType > > Pointer
Definition: variable_expression_data_io.h:40
std::conditional_t< std::disjunction_v< std::is_same< TDataType, int >, std::is_same< TDataType, std::vector< int > > >, int, double > RawType
Definition: variable_expression_data_io.h:48
std::size_t IndexType
Definition: variable_expression_data_io.h:42
const std::vector< IndexType > GetItemShape() const
Get the shape of the data type.
Definition: variable_expression_data_io.h:132
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
void Assign(const Expression &rExpression, const IndexType EntityIndex, const IndexType EntityDataBeginIndex, TDataType &rValue, std::index_sequence< TIndex... >)
Definition: variable_expression_data_io.cpp:41
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
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75