OGS
RelPermUdell.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
4#include "RelPermUdell.h"
5
6#include <algorithm>
7#include <cmath>
8
10
11namespace MaterialPropertyLib
12{
14 const double residual_liquid_saturation,
15 const double residual_gas_saturation,
16 const double min_relative_permeability)
19 min_relative_permeability_(min_relative_permeability)
20{
21 name_ = std::move(name);
22}
23
25 VariableArray const& variable_array,
26 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
27 double const /*dt*/) const
28{
29 const double S_L = variable_array.liquid_saturation;
30
31 if (std::isnan(S_L))
32 {
33 OGS_FATAL("Liquid saturation not set in RelPermUdell::value().");
34 }
35
36 auto const S_L_res = residual_liquid_saturation_;
37 auto const S_L_max = 1. - residual_gas_saturation_;
38
39 auto const S_e = (S_L - S_L_res) / (S_L_max - S_L_res);
40
41 if (S_e >= 1.0)
42 {
43 // fully saturated medium
44 return 1.0;
45 }
46 if (S_e <= 0.0)
47 {
48 // dry medium
50 }
51
52 return std::max(min_relative_permeability_, S_e * S_e * S_e);
53}
55 VariableArray const& variable_array, Variable const variable,
56 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
57 double const /*dt*/) const
58{
59 if (variable != Variable::liquid_saturation)
60 {
62 "RelPermUdell::dValue is implemented for derivatives with respect "
63 "to liquid saturation only.");
64 }
65
66 const double S_L = variable_array.liquid_saturation;
67
68 auto const S_L_res = residual_liquid_saturation_;
69 auto const S_L_max = 1. - residual_gas_saturation_;
70 auto const S_e = (S_L - S_L_res) / (S_L_max - S_L_res);
71
72 if ((S_e < 0.) || (S_e > 1.))
73 {
74 return 0.;
75 }
76
77 auto const dS_e_dS_L = 1. / (S_L_max - S_L_res);
78
79 auto const dk_rel_LR_dS_e = 3. * S_e * S_e;
80 return dk_rel_LR_dS_e * dS_e_dS_L;
81}
82
83} // 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
RelPermUdell(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