https://mooseframework.inl.gov
PorousFlowPermeabilityKozenyCarmanBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
12 template <bool is_ad>
15 {
17  params.addParam<RealTensorValue>("k_anisotropy",
18  "A tensor to multiply the calculated scalar "
19  "permeability, in order to obtain anisotropy if "
20  "required. Defaults to isotropic permeability "
21  "if not specified.");
22  params.addRequiredRangeCheckedParam<Real>("n", "n >= 0", "Porosity exponent");
23  params.addRequiredRangeCheckedParam<Real>("m", "m >= 0", "(1-porosity) exponent");
24  params.addClassDescription(
25  "Base class for material that calculates the permeability tensor from a form of the "
26  "Kozeny-Carman equation, "
27  "k = k_ijk * A * phi^n / (1 - phi)^m, where k_ijk is a tensor providing the anisotropy, phi "
28  "is porosity, n and m are positive scalar constants. Method for computing A is given in the "
29  "derived classes.");
30  return params;
31 }
32 
33 template <bool is_ad>
35  const InputParameters & parameters)
36  : PorousFlowPermeabilityBaseTempl<is_ad>(parameters),
37  _m(this->template getParam<Real>("m")),
38  _n(this->template getParam<Real>("n")),
39  _k_anisotropy(parameters.isParamValid("k_anisotropy")
40  ? this->template getParam<RealTensorValue>("k_anisotropy")
41  : RealTensorValue(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)),
42  _porosity_qp(this->template getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp")),
43  _dporosity_qp_dvar(is_ad ? nullptr
44  : &this->template getMaterialProperty<std::vector<Real>>(
45  "dPorousFlow_porosity_qp_dvar")),
46  _dporosity_qp_dgradvar(is_ad ? nullptr
47  : &this->template getMaterialProperty<std::vector<RealGradient>>(
48  "dPorousFlow_porosity_qp_dgradvar"))
49 {
50  // Make sure that derivatives are included in the Jacobian calculations
51  _dictator.usePermDerivs(true);
52 }
53 
54 template <bool is_ad>
55 void
57 {
58  Real A = computeA();
59  _permeability_qp[_qp] =
60  _k_anisotropy * A * std::pow(_porosity_qp[_qp], _n) / std::pow(1.0 - _porosity_qp[_qp], _m);
61 
62  if constexpr (!is_ad)
63  {
64  (*_dpermeability_qp_dvar)[_qp].resize(_num_var, RealTensorValue());
65  for (unsigned int v = 0; v < _num_var; ++v)
66  (*_dpermeability_qp_dvar)[_qp][v] = (*_dporosity_qp_dvar)[_qp][v] * _permeability_qp[_qp] *
67  (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
68 
69  (*_dpermeability_qp_dgradvar)[_qp].resize(LIBMESH_DIM);
70  for (const auto i : make_range(Moose::dim))
71  {
72  (*_dpermeability_qp_dgradvar)[_qp][i].resize(_num_var, RealTensorValue());
73  for (unsigned int v = 0; v < _num_var; ++v)
74  (*_dpermeability_qp_dgradvar)[_qp][i][v] =
75  (*_dporosity_qp_dgradvar)[_qp][v](i) * _permeability_qp[_qp] *
76  (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
77  }
78  }
79 }
80 
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Base class for material designed to provide the permeability tensor which is calculated from porosity...
PorousFlowPermeabilityKozenyCarmanBaseTempl(const InputParameters &parameters)
static constexpr std::size_t dim
Base class Material designed to provide the permeability tensor.
TensorValue< Real > RealTensorValue
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
IntRange< T > make_range(T beg, T end)
void addClassDescription(const std::string &doc_string)
MooseUnits pow(const MooseUnits &, int)