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