Loading [MathJax]/extensions/tex2jax.js
OGS
Exponential.cpp
Go to the documentation of this file.
1
12
13#include <cmath>
14
15namespace MaterialPropertyLib
16{
18 double const offset,
19 PropertyDataType const& property_reference_value,
20 ExponentData const& v)
21 : exponent_data_(v), offset_(offset)
22{
23 name_ = std::move(name);
24 auto const f = std::get<double>(exponent_data_.factor);
25 auto const v0 = std::get<double>(exponent_data_.reference_condition);
26 value_ = std::get<double>(property_reference_value) * std::exp(-f * v0);
27}
28
31 double const t, double const /*dt*/) const
32{
33 double v = 0.0;
34 if (Variable const* const variable =
35 std::get_if<Variable>(&exponent_data_.type))
36 {
37 v = std::get<double>(variable_array[*variable]);
38 }
39 else if (auto* str_ptr = std::get_if<std::string>(&exponent_data_.type))
40 {
41 if (*str_ptr == "t")
42 v = t;
43 else if (*str_ptr == "x")
44 v = pos.getCoordinates().value()[0];
45 else if (*str_ptr == "y")
46 v = pos.getCoordinates().value()[1];
47 else if (*str_ptr == "z")
48 v = pos.getCoordinates().value()[2];
49 else
51 "Unknown independent_variable {:s} for exponential property.",
52 *str_ptr)
53 }
54 else
55 {
57 "Could not convert independent_variable neither to a Variable nor "
58 "to a std::string.");
59 }
60 auto const f = std::get<double>(exponent_data_.factor);
61
62 return offset_ + std::get<double>(value_) * std::exp(f * v);
63}
64
66 VariableArray const& variable_array, Variable const variable,
67 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
68 double const /*dt*/) const
69{
70 Variable const* const independent_variable =
71 std::get_if<Variable>(&exponent_data_.type);
72 if (independent_variable == nullptr)
73 {
74 return 0.;
75 }
76 if (*independent_variable != variable)
77 {
78 return 0.;
79 }
80
81 auto const f = std::get<double>(exponent_data_.factor);
82 auto const v = std::get<double>(variable_array[*independent_variable]);
83
84 return std::get<double>(value_) * f * std::exp(f * v);
85}
86
88 VariableArray const& variable_array, Variable const pv1, Variable const pv2,
89 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
90 double const /*dt*/) const
91{
92 Variable const* const independent_variable =
93 std::get_if<Variable>(&exponent_data_.type);
94 if (independent_variable == nullptr)
95 {
96 return 0.;
97 }
98 if (*independent_variable != pv1 && *independent_variable != pv2)
99 {
100 return 0.;
101 }
102
103 auto const f = std::get<double>(exponent_data_.factor);
104 auto const v = std::get<double>(variable_array[*independent_variable]);
105
106 return std::get<double>(value_) * f * f * std::exp(f * v);
107}
108
109} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
double const offset_
additive offset in units of the property.
Definition Exponential.h:73
ExponentData const exponent_data_
Definition Exponential.h:72
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
Exponential(std::string name, double const offset, PropertyDataType const &property_reference_value, ExponentData const &v)
PropertyDataType d2Value(VariableArray const &variable_array, Variable const pv1, Variable const pv2, ParameterLib::SpatialPosition const &, double const, double const) const override
PropertyDataType value_
The single value of a property.
Definition Property.h:292
virtual PropertyDataType value() const
Definition Property.cpp:76
std::optional< MathLib::Point3d > const getCoordinates() const
std::variant< double, Eigen::Matrix< double, 2, 1 >, Eigen::Matrix< double, 3, 1 >, Eigen::Matrix< double, 2, 2 >, Eigen::Matrix< double, 3, 3 >, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 >, Eigen::MatrixXd > PropertyDataType
Definition Property.h:31
VariableType factor
a dimensionless exponent.
Definition Exponential.h:24