OGS
Linear.cpp
Go to the documentation of this file.
1
12
13#include <numeric>
14
15namespace MaterialPropertyLib
16{
17Linear::Linear(std::string name,
18 PropertyDataType const& property_reference_value,
19 std::vector<IndependentVariable> const& vs)
20 : independent_variables_(vs)
21{
22 name_ = std::move(name);
23 value_ = property_reference_value;
24}
25
27 ParameterLib::SpatialPosition const& /*pos*/,
28 double const /*t*/, double const /*dt*/) const
29{
30 auto calculate_linearized_ratio =
31 [&variable_array](double const initial_linearized_ratio, auto const& iv)
32 {
33 return initial_linearized_ratio +
34 std::get<double>(iv.slope) *
35 (std::get<double>(variable_array[iv.type]) -
36 std::get<double>(iv.reference_condition));
37 };
38
39 double const linearized_ratio_to_reference_value =
40 std::accumulate(independent_variables_.begin(),
42 1.0,
43 calculate_linearized_ratio);
44
45 return std::get<double>(value_) * linearized_ratio_to_reference_value;
46}
47
49 Variable const variable,
50 ParameterLib::SpatialPosition const& /*pos*/,
51 double const /*t*/, double const /*dt*/) const
52{
53 auto const independent_variable = std::find_if(
56 [&variable](auto const& iv) -> bool { return iv.type == variable; });
57
58 return independent_variable != independent_variables_.end()
59 ? std::get<double>(value_) *
60 std::get<double>(independent_variable->slope)
61 : decltype(value_){};
62}
63
65 Variable const /*pv1*/, Variable const /*pv2*/,
66 ParameterLib::SpatialPosition const& /*pos*/,
67 double const /*t*/, double const /*dt*/) const
68{
69 return decltype(value_){};
70}
71
72} // namespace MaterialPropertyLib
std::vector< IndependentVariable > const independent_variables_
Definition Linear.h:61
PropertyDataType d2Value(VariableArray const &variable_array, Variable const pv1, Variable const pv2, ParameterLib::SpatialPosition const &, double const, double const) const override
Definition Linear.cpp:64
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
Definition Linear.cpp:48
Linear(std::string name, PropertyDataType const &property_reference_value, std::vector< IndependentVariable > const &vs)
Definition Linear.cpp:17
PropertyDataType value_
The single value of a property.
Definition Property.h:292
virtual PropertyDataType value() const
Definition Property.cpp:76
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