OGS
Property.cpp
Go to the documentation of this file.
1
13#include "Property.h"
14
15#include <string>
16
17#include "Component.h"
18#include "Medium.h"
19#include "Phase.h"
20
21namespace MaterialPropertyLib
22{
23PropertyDataType fromVector(std::vector<double> const& values)
24{
25 switch (values.size())
26 {
27 case 1:
28 {
29 return values[0];
30 }
31 case 2:
32 {
33 return Eigen::Vector2d{values[0], values[1]};
34 }
35 case 3:
36 {
37 return Eigen::Vector3d{values[0], values[1], values[2]};
38 }
39 case 4:
40 {
41 using M = Eigen::Matrix2d;
42 // the values vector is in row major order
43 using MRM = Eigen::Matrix<double, 2, 2, Eigen::RowMajor>;
44 return M{Eigen::Map<MRM const>{values.data(), 2, 2}};
45 }
46 case 6:
47 {
48 // Symmetric Tensor - xx, yy, zz, xy, xz, yz
49 using M = Eigen::Matrix<double, 6, 1>;
50 return M{Eigen::Map<M const>{values.data(), 6}};
51 }
52 case 9:
53 {
54 using M = Eigen::Matrix3d;
55 // the values vector is in row major order
56 using MRM = Eigen::Matrix<double, 3, 3, Eigen::RowMajor>;
57 return M{Eigen::Map<MRM const>{values.data(), 3, 3}};
58 }
59 default:
60 {
62 "Conversion of a {:d}-vector to PropertyDataType is not "
63 "implemented.",
64 values.size());
65 }
66 }
67}
68
70 ParameterLib::SpatialPosition const& pos, double const t) const
71{
72 return value(EmptyVariableArray, pos, t,
73 std::numeric_limits<double>::quiet_NaN());
74}
75
77{
78#ifndef NDEBUG
79 property_used = true;
80#endif
81 return value_;
82}
83
85 VariableArray const& /*variable_array_prev*/,
86 ParameterLib::SpatialPosition const& /*pos*/,
87 double const /*t*/, double const /*dt*/) const
88{
89#ifndef NDEBUG
90 property_used = true;
91#endif
92 return value_;
93}
94
97 double const t, double const dt) const
98{
99#ifndef NDEBUG
100 property_used = true;
101#endif
102 return value(variable_array, EmptyVariableArray, pos, t, dt);
103}
104
106 VariableArray const& /*variable_array_prev*/,
107 Variable const /*variable*/,
108 ParameterLib::SpatialPosition const& /*pos*/,
109 double const /*t*/, double const /*dt*/) const
110{
111#ifndef NDEBUG
112 property_used = true;
113#endif
114 return dvalue_;
115}
116
120 Variable const variable,
122 double const t, double const dt) const
123{
124#ifndef NDEBUG
125 property_used = true;
126#endif
127 return dValue(variable_array, EmptyVariableArray, variable, pos, t, dt);
128}
129
132 Variable const /*variable*/,
133 Variable const /*variable*/,
134 ParameterLib::SpatialPosition const& /*pos*/,
135 double const /*t*/,
136 double const /*dt*/) const
137{
138#ifndef NDEBUG
139 property_used = true;
140#endif
141 return 0.0;
142}
143
146 std::vector<std::unique_ptr<Phase>> const& /*phases*/)
147{
148 // empty
149}
150
151std::string Property::description() const
152{
153 return "property '" + name_ + "' defined for " +
154 std::visit(
155 [](auto&& scale) -> std::string
156 {
157 if (scale == nullptr)
158 {
159 return "unknown scale";
160 }
161 return scale->description();
162 },
163 scale_);
164}
165} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual void setProperties(std::vector< std::unique_ptr< Phase > > const &phases)
Default implementation:
Definition Property.cpp:145
virtual PropertyDataType d2Value(VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
Default implementation: 2nd derivative of any constant property is zero.
Definition Property.cpp:131
std::string description() const
Definition Property.cpp:151
PropertyDataType value_
The single value of a property.
Definition Property.h:292
PropertyDataType dvalue_
Definition Property.h:293
virtual PropertyDataType value() const
Definition Property.cpp:76
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297
virtual PropertyDataType initialValue(ParameterLib::SpatialPosition const &pos, double const t) const
Definition Property.cpp:69
virtual PropertyDataType dValue(VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
Definition Property.cpp:105
PropertyDataType fromVector(std::vector< double > const &values)
Definition Property.cpp:23
static const VariableArray EmptyVariableArray
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