OGS
RelPermLiakopoulos.cpp
Go to the documentation of this file.
1 
14 #include "RelPermLiakopoulos.h"
15 
16 #include <algorithm>
17 #include <cmath>
18 
19 #include "MaterialLib/MPL/Medium.h"
20 
21 namespace MaterialPropertyLib
22 {
24 {
25  name_ = std::move(name);
26 }
27 
29  VariableArray const& variable_array,
30  ParameterLib::SpatialPosition const& pos, double const t,
31  double const dt) const
32 {
37  auto const s_L = std::visit(
38  [&variable_array, &pos, t, dt](auto&& scale) -> double
39  {
40  return scale->property(PropertyType::saturation)
41  .template value<double>(variable_array, pos, t, dt);
42  },
43  scale_);
44  auto const s_L_res = residual_liquid_saturation_;
45 
46  if (s_L <= s_L_res)
47  {
48  return 0.0;
49  }
50 
51  if (s_L >= 1.)
52  {
53  return 1.0;
54  }
55 
56  auto const a = parameter_a_;
57  auto const b = parameter_b_;
58 
59  auto const k_rel_LR = 1. - a * std::pow(1. - s_L, b);
60 
61  return std::max(k_rel_LR, 0.);
62 }
63 
65  VariableArray const& variable_array, Variable const variable,
66  ParameterLib::SpatialPosition const& pos, double const t,
67  double const dt) const
68 {
69  if (variable != Variable::liquid_saturation)
70  {
71  OGS_FATAL(
72  "RelPermLiakopoulos::dValue is implemented for derivatives with "
73  "respect to liquid saturation only.");
74  }
79  auto const s_L = std::visit(
80  [&variable_array, &pos, t, dt](auto&& scale) -> double
81  {
82  return scale->property(PropertyType::saturation)
83  .template value<double>(variable_array, pos, t, dt);
84  },
85  scale_);
86  auto const s_L_res = residual_liquid_saturation_;
87  auto const s_L_max = maximal_liquid_saturation_;
88 
89  const double s_L_within_range = std::min(std::max(s_L_res, s_L), s_L_max);
90 
91  auto const a = parameter_a_;
92  auto const b = parameter_b_;
93 
94  return a * b * std::pow(1. - s_L_within_range, b - 1.);
95 }
96 
97 } // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition: Error.h:26
virtual PropertyDataType value() const
Definition: Property.cpp:72
std::variant< Medium *, Phase *, Component * > scale_
Definition: Property.h:287
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
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 > > PropertyDataType
Definition: Property.h:35
std::array< VariableType, static_cast< int >(Variable::number_of_variables)> VariableArray
Definition: VariableType.h:108
void scale(PETScVector &x, double const a)
Definition: LinAlg.cpp:44