OGS
RelPermUdellNonwettingPhase.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 <algorithm>
7#include <cmath>
8
10
11namespace MaterialPropertyLib
12{
14 std::string name,
15 const double residual_liquid_saturation,
16 const double residual_gas_saturation,
17 const double min_relative_permeability)
20 min_relative_permeability_(min_relative_permeability)
21{
22 name_ = std::move(name);
23}
24
26 VariableArray const& variable_array,
27 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
28 double const /*dt*/) const
29{
30 const double S_L = variable_array.liquid_saturation;
31
32 if (std::isnan(S_L))
33 {
35 "In RelPermUdellNonwettingPhase::value, the liquid saturation is "
36 "NaN.");
37 }
38
39 auto const S_L_res = residual_liquid_saturation_;
40 auto const S_L_max = 1. - residual_gas_saturation_;
41
42 auto const S_e = (S_L - S_L_res) / (S_L_max - S_L_res);
43
44 if (S_e >= 1.0)
45 {
46 // fully saturated medium
48 }
49 if (S_e <= 0.0)
50 {
51 // dry medium
52 return 1.0;
53 }
54
55 auto const S_e_g = (1. - S_e);
56
57 return std::max(min_relative_permeability_, S_e_g * S_e_g * S_e_g);
58}
60 VariableArray const& variable_array, Variable const variable,
61 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
62 double const /*dt*/) const
63{
64 if (variable != Variable::liquid_saturation)
65 {
67 "RelPermUdellNonwettingPhase::dValue is implemented for "
68 "derivatives with respect to liquid saturation only.");
69 }
70
71 const double S_L = variable_array.liquid_saturation;
72
73 auto const S_L_res = residual_liquid_saturation_;
74 auto const S_L_max = 1. - residual_gas_saturation_;
75 auto const S_e = (S_L - S_L_res) / (S_L_max - S_L_res);
76
77 if ((S_e < 0.) || (S_e > 1.))
78 {
79 return 0.;
80 }
81
82 auto const dS_e_dS_L = 1. / (S_L_max - S_L_res);
83
84 auto const dk_rel_GR_dS_e = -3. * (1. - S_e) * (1. - S_e);
85 return dk_rel_GR_dS_e * dS_e_dS_L;
86}
87
88} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
virtual PropertyDataType value() const
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
RelPermUdellNonwettingPhase(std::string name, const double residual_liquid_saturation, const double residual_gas_saturation, const double min_relative_permeability)
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