OGS
Exponential.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <cmath>
7
9{
11 double const offset,
12 PropertyDataType const& property_reference_value,
13 ExponentData const& v)
14 : exponent_data_(v), offset_(offset)
15{
16 name_ = std::move(name);
17 auto const f = std::get<double>(exponent_data_.factor);
18 auto const v0 = std::get<double>(exponent_data_.reference_condition);
19 value_ = std::get<double>(property_reference_value) * std::exp(-f * v0);
20}
21
24 double const t, double const /*dt*/) const
25{
26 double v = 0.0;
27 if (Variable const* const variable =
28 std::get_if<Variable>(&exponent_data_.type))
29 {
30 v = std::get<double>(variable_array[*variable]);
31 }
32 else if (auto* str_ptr = std::get_if<std::string>(&exponent_data_.type))
33 {
34 if (*str_ptr == "t")
35 {
36 v = t;
37 }
38 else if (*str_ptr == "x")
39 {
40 v = pos.getCoordinates().value()[0];
41 }
42 else if (*str_ptr == "y")
43 {
44 v = pos.getCoordinates().value()[1];
45 }
46 else if (*str_ptr == "z")
47 {
48 v = pos.getCoordinates().value()[2];
49 }
50 else
52 "Unknown independent_variable {:s} for exponential property.",
53 *str_ptr)
54 }
55 else
56 {
58 "Could not convert independent_variable neither to a Variable nor "
59 "to a std::string.");
60 }
61 auto const f = std::get<double>(exponent_data_.factor);
62
63 return offset_ + std::get<double>(value_) * std::exp(f * v);
64}
65
67 VariableArray const& variable_array, Variable const variable,
68 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
69 double const /*dt*/) const
70{
71 Variable const* const independent_variable =
72 std::get_if<Variable>(&exponent_data_.type);
73 if (independent_variable == nullptr)
74 {
75 return 0.;
76 }
77 if (*independent_variable != variable)
78 {
79 return 0.;
80 }
81
82 auto const f = std::get<double>(exponent_data_.factor);
83 auto const v = std::get<double>(variable_array[*independent_variable]);
84
85 return std::get<double>(value_) * f * std::exp(f * v);
86}
87
89 VariableArray const& variable_array, Variable const pv1, Variable const pv2,
90 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
91 double const /*dt*/) const
92{
93 Variable const* const independent_variable =
94 std::get_if<Variable>(&exponent_data_.type);
95 if (independent_variable == nullptr)
96 {
97 return 0.;
98 }
99 if (*independent_variable != pv1 && *independent_variable != pv2)
100 {
101 return 0.;
102 }
103
104 auto const f = std::get<double>(exponent_data_.factor);
105 auto const v = std::get<double>(variable_array[*independent_variable]);
106
107 return std::get<double>(value_) * f * f * std::exp(f * v);
108}
109
110} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
double const offset_
additive offset in units of the property.
Definition Exponential.h:67
ExponentData const exponent_data_
Definition Exponential.h:66
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.
virtual PropertyDataType value() const
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