OGS
VolumeFractionAverage.cpp
Go to the documentation of this file.
1
13
16
17namespace MaterialPropertyLib
18{
20{
21 // get the corresponding property's name
22 name_ = std::move(name);
23
25}
26
28{
29 if (!std::holds_alternative<Medium*>(scale_))
30 {
32 "The property 'VolumeFractionAverage' is "
33 "implemented on the 'medium' scale only.");
34 }
35}
36
38 std::vector<std::unique_ptr<Phase>> const& phases)
39{
40 // run over phases, identify them and get properties
41 for (auto const& phase : phases)
42 {
43 if (phase == nullptr)
44 {
46 "One of the required phases (AqueousLiquid/FrozenLiquid/Solid) "
47 "does not exist!");
48 }
49 std::string const& phase_name = phase->name;
50
51 if (!phase->hasProperty(prop_type_))
52 {
54 "The phase '{}' does not have the required property '{}'!",
56 }
57 auto const& property = phase->property(prop_type_);
58 if (phase_name == "AqueousLiquid")
59 {
60 properties_.liquid = &property;
61 }
62 else if (phase_name == "FrozenLiquid")
63 {
64 properties_.frozen = &property;
65 }
66 else if (phase_name == "Solid")
67 {
68 properties_.porous = &property;
69 }
70 }
71}
72
74 VariableArray const& variable_array,
75 ParameterLib::SpatialPosition const& pos, double const t,
76 double const dt) const
77{
78 auto const& medium = *std::get<Medium*>(scale_);
79 auto const& porosity = medium[PropertyType::porosity];
80
81 double phi_fr = 0;
82 double prop_value_frozen = 0;
83
84 // get frozen pore volume fraction, and porosity
85 if (medium.hasProperty(PropertyType::volume_fraction))
86 {
87 assert(properties_.frozen != nullptr);
88 auto const& fraction = medium[PropertyType::volume_fraction];
89 phi_fr = std::get<double>(fraction.value(variable_array, pos, t, dt));
90 prop_value_frozen = std::get<double>(
91 properties_.frozen->value(variable_array, pos, t, dt));
92 }
93
94 auto const phi =
95 std::get<double>(porosity.value(variable_array, pos, t, dt));
96 auto const prop_value_liquid =
97 std::get<double>(properties_.liquid->value(variable_array, pos, t, dt));
98 auto const prop_value_porous =
99 std::get<double>(properties_.porous->value(variable_array, pos, t, dt));
100
101 return (phi - phi_fr) * prop_value_liquid + phi_fr * prop_value_frozen +
102 (1 - phi) * prop_value_porous;
103}
104
106 VariableArray const& variable_array, Variable const variable,
107 ParameterLib::SpatialPosition const& pos, double const t,
108 double const dt) const
109{
110 (void)variable;
111 assert((variable == Variable::temperature) &&
112 "VolumeFractionAverage::dValue is implemented for "
113 "derivatives with respect to temperature only.");
114
115 double dphi_fr_dT = 0;
116 double prop_value_frozen = 0;
117
118 auto const& medium = *std::get<Medium*>(scale_);
119 if (medium.hasProperty(PropertyType::volume_fraction))
120 {
121 auto const& fraction = medium[PropertyType::volume_fraction];
122 dphi_fr_dT = std::get<double>(
123 fraction.dValue(variable_array, Variable::temperature, pos, t, dt));
124 prop_value_frozen = std::get<double>(
125 properties_.frozen->value(variable_array, pos, t, dt));
126 }
127
128 double prop_value_liquid =
129 std::get<double>(properties_.liquid->value(variable_array, pos, t, dt));
130
131 return (prop_value_frozen - prop_value_liquid) * dphi_fr_dT;
132}
133} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297
void setProperties(std::vector< std::unique_ptr< Phase > > const &phases) override
Default implementation:
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
PropertyType convertStringToProperty(std::string const &string)
static const std::array< std::string, PropertyType::number_of_properties > property_enum_to_string
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