www.mooseframework.org
PorousFlowRelativePermeabilityVG.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "libmesh/utility.h"
12 
15 
16 template <bool is_ad>
19 {
22  "m", "m > 0 & m < 1", "The van Genuchten exponent of the phase");
23  params.addRangeCheckedParam<Real>("seff_turnover",
24  1.0,
25  "seff_turnover > 0 & seff_turnover <= 1",
26  "The relative permeability will be a cubic for seff > "
27  "seff_turnover. The cubic is chosen so that its derivative "
28  "and value matche the VG function at seff=seff_turnover");
29  params.addParam<bool>("zero_derivative",
30  false,
31  "Employ a cubic for seff>seff_turnover that has zero derivative at seff=1");
32  params.addParam<bool>("wetting",
33  true,
34  "If true, use the van Genuchten form appropriate for a wetting (liquid) "
35  "phase. If false, use the non-wetting (gas) expression.");
36  params.addClassDescription("This Material calculates relative permeability of a phase "
37  "using the van Genuchten model");
38  return params;
39 }
40 
41 template <bool is_ad>
43  const InputParameters & parameters)
44  : PorousFlowRelativePermeabilityBaseTempl<is_ad>(parameters),
45  _m(this->template getParam<Real>("m")),
46  _wetting(this->template getParam<bool>("wetting")),
47  _cut(this->template getParam<Real>("seff_turnover")),
48  _cub0(_wetting ? PorousFlowVanGenuchten::relativePermeability(_cut, _m)
50  _cub1(_wetting ? PorousFlowVanGenuchten::dRelativePermeability(_cut, _m)
52  _cub2(_cut < 1.0
53  ? (this->template getParam<bool>("zero_derivative")
54  ? 3.0 * (1.0 - _cub0 - _cub1 * (1.0 - _cut)) / Utility::pow<2>(1.0 - _cut) +
55  _cub1 / (1.0 - _cut)
56  : (_wetting ? PorousFlowVanGenuchten::d2RelativePermeability(_cut, _m)
58  : 0.0),
59  _cub3(_cut < 1.0
60  ? (this->template getParam<bool>("zero_derivative")
61  ? -2.0 * (1.0 - _cub0 - _cub1 * (1.0 - _cut)) / Utility::pow<3>(1.0 - _cut) -
62  _cub1 / Utility::pow<2>(1.0 - _cut)
63  : (1.0 - _cub0 - _cub1 * (1.0 - _cut) - _cub2 * Utility::pow<2>(1.0 - _cut)) /
64  Utility::pow<3>(1.0 - _cut))
65  : 0.0)
66 {
67 }
68 
69 template <bool is_ad>
72 {
73  if (MetaPhysicL::raw_value(seff) < _cut)
74  {
75  if (_wetting)
77  else
79  }
80 
81  return _cub0 + _cub1 * (seff - _cut) + _cub2 * Utility::pow<2>(seff - _cut) +
82  _cub3 * Utility::pow<3>(seff - _cut);
83 }
84 
85 template <bool is_ad>
86 Real
88 {
89  if (seff < _cut)
90  {
91  if (_wetting)
93  else
95  }
96 
97  return _cub1 + 2.0 * _cub2 * (seff - _cut) + 3.0 * _cub3 * Utility::pow<2>(seff - _cut);
98 }
99 
Real d2RelativePermeability(Real s, Real c, Real sn, Real ss, Real kn, Real ks)
Second derivative of relative permeability with respect to saturation.
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
Real dRelativePermeabilityNW(Real seff, Real lambda)
Derivative of relative permeability of the non-wetting phase wrt to effective saturation.
registerMooseObject("PorousFlowApp", PorousFlowRelativePermeabilityVG)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual Real dRelativePermeability(Real seff) const override
Derivative of relative permeability with respect to effective saturation.
T relativePermeabilityNW(const T &seff, Real m)
Relative permeability for a non-wetting phase as a function of effective saturation.
T relativePermeabilityNW(const T &seff, Real lambda)
Relative permeability of the non-wetting phase as a function of effective saturation.
auto raw_value(const Eigen::Map< T > &in)
T relativePermeability(const T &s, Real c, Real sn, Real ss, Real kn, Real ks)
Relative permeability as a function of saturation.
van Genuchten effective saturation, capillary pressure and relative permeability functions.
virtual GenericReal< is_ad > relativePermeability(GenericReal< is_ad > seff) const override
Relative permeability equation (must be overriden in derived class)
Material to calculate van Genuchten-type relative permeability of an arbitrary phase given the satura...
Base class for PorousFlow relative permeability materials.
Real d2RelativePermeabilityNW(Real seff, Real m)
Second derivative of relative permeability for a non-wetting phase with respect to effective saturati...
Real dRelativePermeability(Real seff, Real m)
Derivative of relative permeability with respect to effective saturation.
Real dRelativePermeability(Real s, Real c, Real sn, Real ss, Real kn, Real ks)
Derivative of relative permeability with respect to saturation.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
T relativePermeability(const T &seff, Real m)
Relative permeability as a function of effective saturation.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
PorousFlowRelativePermeabilityVGTempl(const InputParameters &parameters)
typename Moose::GenericType< Real, is_ad > GenericReal
Real dRelativePermeabilityNW(Real seff, Real m)
Derivative of relative permeability for a non-wetting phase with respect to effective saturation...