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 v = t;
36 else if (*str_ptr == "x")
37 v = pos.getCoordinates().value()[0];
38 else if (*str_ptr == "y")
39 v = pos.getCoordinates().value()[1];
40 else if (*str_ptr == "z")
41 v = pos.getCoordinates().value()[2];
42 else
44 "Unknown independent_variable {:s} for exponential property.",
45 *str_ptr)
46 }
47 else
48 {
50 "Could not convert independent_variable neither to a Variable nor "
51 "to a std::string.");
52 }
53 auto const f = std::get<double>(exponent_data_.factor);
54
55 return offset_ + std::get<double>(value_) * std::exp(f * v);
56}
57
59 VariableArray const& variable_array, Variable const variable,
60 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
61 double const /*dt*/) const
62{
63 Variable const* const independent_variable =
64 std::get_if<Variable>(&exponent_data_.type);
65 if (independent_variable == nullptr)
66 {
67 return 0.;
68 }
69 if (*independent_variable != variable)
70 {
71 return 0.;
72 }
73
74 auto const f = std::get<double>(exponent_data_.factor);
75 auto const v = std::get<double>(variable_array[*independent_variable]);
76
77 return std::get<double>(value_) * f * std::exp(f * v);
78}
79
81 VariableArray const& variable_array, Variable const pv1, Variable const pv2,
82 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
83 double const /*dt*/) const
84{
85 Variable const* const independent_variable =
86 std::get_if<Variable>(&exponent_data_.type);
87 if (independent_variable == nullptr)
88 {
89 return 0.;
90 }
91 if (*independent_variable != pv1 && *independent_variable != pv2)
92 {
93 return 0.;
94 }
95
96 auto const f = std::get<double>(exponent_data_.factor);
97 auto const v = std::get<double>(variable_array[*independent_variable]);
98
99 return std::get<double>(value_) * f * f * std::exp(f * v);
100}
101
102} // 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