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.
container_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 <string>
17 
18 // Project includes
19 #include "containers/variable.h"
20 #include "includes/model_part.h"
21 
22 namespace Kratos {
23 
26 
27 namespace ContainerDataIOTags {
28  struct Historical {};
29  struct NonHistorical {};
30 } // namespace Tags
31 
32 // Dummy generic class to be specialized later
33 template <class TContainerDataIOTags>
34 struct ContainerDataIO {};
35 
36 template <>
37 struct ContainerDataIO<ContainerDataIOTags::Historical>
38 {
39  static constexpr std::string_view mInfo = "Historical";
40 
41  template <class TDataType>
42  static const TDataType& GetValue(
43  const ModelPart::NodeType& rNode,
44  const Variable<TDataType>& rVariable)
45  {
46  return rNode.FastGetSolutionStepValue(rVariable);
47  }
48 
49  template <class TDataType>
50  static void SetValue(
51  ModelPart::NodeType& rNode,
52  const Variable<TDataType>& rVariable,
53  const TDataType& rValue)
54  {
55  rNode.FastGetSolutionStepValue(rVariable) = rValue;
56  }
57 };
58 
59 template <>
60 struct ContainerDataIO<ContainerDataIOTags::NonHistorical>
61 {
62  static constexpr std::string_view mInfo = "NonHistorical";
63 
64  template<class TDataType, class TEntityType>
65  static const TDataType& GetValue(
66  const TEntityType& rEntity,
67  const Variable<TDataType>& rVariable)
68  {
69  return rEntity.GetValue(rVariable);
70  }
71 
72  template<class TDataType, class TEntityType>
73  static void SetValue(
74  TEntityType& rEntity,
75  const Variable<TDataType>& rVariable,
76  const TDataType& rValue)
77  {
78  rEntity.SetValue(rVariable, rValue);
79  }
80 };
81 
82 } // namespace Kratos
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
static const TDataType & GetValue(const ModelPart::NodeType &rNode, const Variable< TDataType > &rVariable)
Definition: container_data_io.h:42
static void SetValue(ModelPart::NodeType &rNode, const Variable< TDataType > &rVariable, const TDataType &rValue)
Definition: container_data_io.h:50
static const TDataType & GetValue(const TEntityType &rEntity, const Variable< TDataType > &rVariable)
Definition: container_data_io.h:65
static void SetValue(TEntityType &rEntity, const Variable< TDataType > &rVariable, const TDataType &rValue)
Definition: container_data_io.h:73
Definition: container_data_io.h:34
Definition: container_data_io.h:28
Definition: container_data_io.h:29