OGS
VariableType.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <BaseLib/Error.h>
16
17#include <Eigen/Core>
18#include <array>
19#include <string>
20#include <variant>
21
22namespace MaterialPropertyLib
23{
24
28enum class Variable : int
29{
33 density,
48 stress,
56};
57
58static const std::array<std::string,
59 static_cast<int>(Variable::number_of_variables)>
60 variable_enum_to_string{{"capillary_pressure",
61 "concentration",
62 "deformation_gradient",
63 "density",
64 "effective_pore_pressure",
65 "enthalpy",
66 "enthalpy_of_evaporation",
67 "equivalent_plastic_strain",
68 "grain_compressibility",
69 "liquid_phase_pressure",
70 "liquid_saturation",
71 "mechanical_strain",
72 "molar_mass",
73 "molar_mass_derivative",
74 "molar_fraction",
75 "gas_phase_pressure",
76 "porosity",
77 "solid_grain_pressure",
78 "stress",
79 "temperature",
80 "total_strain",
81 "total_stress",
82 "transport_porosity",
83 "vapour_pressure",
84 "volumetric_strain"}};
85
88using VariableType = std::variant<std::monostate,
89 double,
90 Eigen::Matrix<double, 4, 1>,
91 Eigen::Matrix<double, 5, 1>,
92 Eigen::Matrix<double, 6, 1>,
93 Eigen::Matrix<double, 9, 1>>;
94
96{
97public:
100 VariableType operator[](Variable const variable) const
101 {
102 auto identity = [](auto&& arg) -> VariableType { return arg; };
103 switch (variable)
104 {
106 return capillary_pressure;
108 return concentration;
110 return std::visit(identity, deformation_gradient);
112 return density;
116 return enthalpy;
126 return liquid_saturation;
128 return std::visit(identity, mechanical_strain);
130 return molar_mass;
134 return molar_fraction;
136 return gas_phase_pressure;
138 return porosity;
141 case Variable::stress:
142 return std::visit(identity, stress);
144 return temperature;
146 return std::visit(identity, total_strain);
148 return std::visit(identity, total_stress);
150 return transport_porosity;
152 return vapour_pressure;
154 return volumetric_strain;
155 default:
156 OGS_FATAL(
157 "No conversion to VariableType is provided for variable "
158 "{:d}",
159 static_cast<int>(variable));
160 };
161 }
162
165 // Compare to GMatrixPolicy::GradientVectorType. The 1d case = Matrix<3, 1>
166 // is not used so far.
167 std::variant<std::monostate,
168 Eigen::Matrix<double, 5, 1>,
169 Eigen::Matrix<double, 9, 1>>
171 double density = nan_;
173 double enthalpy = nan_;
179 std::variant<std::monostate,
180 Eigen::Matrix<double, 4, 1>,
181 Eigen::Matrix<double, 6, 1>>
183 double molar_mass = nan_;
187 double porosity = nan_;
189 std::variant<std::monostate,
190 Eigen::Matrix<double, 4, 1>,
191 Eigen::Matrix<double, 6, 1>>
194 std::variant<std::monostate,
195 Eigen::Matrix<double, 4, 1>,
196 Eigen::Matrix<double, 6, 1>>
198 std::variant<std::monostate,
199 Eigen::Matrix<double, 4, 1>,
200 Eigen::Matrix<double, 6, 1>>
205
206private:
207 static constexpr auto nan_ = std::numeric_limits<double>::signaling_NaN();
208};
209
211
214Variable convertStringToVariable(std::string const& string);
215} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition: Error.h:26
VariableType operator[](Variable const variable) const
Definition: VariableType.h:100
std::variant< std::monostate, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 > > mechanical_strain
Definition: VariableType.h:182
std::variant< std::monostate, Eigen::Matrix< double, 5, 1 >, Eigen::Matrix< double, 9, 1 > > deformation_gradient
Definition: VariableType.h:170
std::variant< std::monostate, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 > > total_strain
Definition: VariableType.h:197
std::variant< std::monostate, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 > > stress
Definition: VariableType.h:192
std::variant< std::monostate, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 > > total_stress
Definition: VariableType.h:201
static const VariableArray EmptyVariableArray
Definition: VariableType.h:210
static const std::array< std::string, static_cast< int >(Variable::number_of_variables)> variable_enum_to_string
Definition: VariableType.h:60
std::variant< std::monostate, double, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 5, 1 >, Eigen::Matrix< double, 6, 1 >, Eigen::Matrix< double, 9, 1 > > VariableType
Definition: VariableType.h:93
@ concentration
used to specify decay rate of a substance.
Definition: PropertyType.h:46
Variable convertStringToVariable(std::string const &string)