https://mooseframework.inl.gov
PorousFlowPermeabilityExponential.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 
14 
15 template <bool is_ad>
18 {
20  MooseEnum poroperm_function("log_k ln_k exp_k", "exp_k");
21  params.addParam<MooseEnum>("poroperm_function",
22  poroperm_function,
23  "Form of the function relating porosity and permeability. The options "
24  "are: log_k (log k = A phi + B); ln_k (ln k = A phi + B); exp_k (k = "
25  "B exp(A phi)); where k is permeability, phi is porosity, A and B are "
26  "empirical constants.");
27  params.addParam<RealTensorValue>("k_anisotropy",
28  "A tensor to multiply the calculated scalar "
29  "permeability, in order to obtain anisotropy if "
30  "required. Defaults to isotropic permeability "
31  "if not specified.");
32  params.addRequiredParam<Real>("A", "Empirical constant; see poroperm_function.");
33  params.addRequiredParam<Real>("B", "Empirical constant; see poroperm_function.");
34  params.addClassDescription(
35  "This Material calculates the permeability tensor from an exponential function of porosity: "
36  "k = k_ijk * BB exp(AA phi), where k_ijk is a tensor providing the anisotropy, phi is "
37  "porosity, and AA and BB are empirical constants. The user can provide input for the "
38  "function expressed in ln k, log k or exponential forms (see poroperm_function).");
39  return params;
40 }
41 
42 template <bool is_ad>
44  const InputParameters & parameters)
45  : PorousFlowPermeabilityBaseTempl<is_ad>(parameters),
46  _A(this->template getParam<Real>("A")),
47  _B(this->template getParam<Real>("B")),
48  _k_anisotropy(parameters.isParamValid("k_anisotropy")
49  ? this->template getParam<RealTensorValue>("k_anisotropy")
50  : RealTensorValue(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)),
51  _porosity_qp(this->template getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp")),
52  _dporosity_qp_dvar(is_ad ? nullptr
53  : &this->template getMaterialProperty<std::vector<Real>>(
54  "dPorousFlow_porosity_qp_dvar")),
55  _dporosity_qp_dgradvar(is_ad ? nullptr
56  : &this->template getMaterialProperty<std::vector<RealGradient>>(
57  "dPorousFlow_porosity_qp_dgradvar")),
58  _poroperm_function(this->template getParam<MooseEnum>("poroperm_function")
59  .template getEnum<PoropermFunction>())
60 {
61  switch (_poroperm_function)
62  {
64  _AA = _A * std::log(10.0);
65  _BB = std::pow(10.0, _B);
66  break;
67 
69  _AA = _A;
70  _BB = std::exp(_B);
71  break;
72 
74  _AA = _A;
75  _BB = _B;
76  break;
77  }
78 
79  // Make sure that derivatives are included in the Jacobian calculations
80  _dictator.usePermDerivs(true);
81 }
82 
83 template <bool is_ad>
84 void
86 {
87  _permeability_qp[_qp] = _k_anisotropy * _BB * std::exp(_porosity_qp[_qp] * _AA);
88 
89  if constexpr (!is_ad)
90  {
91  (*_dpermeability_qp_dvar)[_qp].resize(_num_var, RealTensorValue());
92  for (unsigned int v = 0; v < _num_var; ++v)
93  (*_dpermeability_qp_dvar)[_qp][v] =
94  _AA * _permeability_qp[_qp] * (*_dporosity_qp_dvar)[_qp][v];
95 
96  (*_dpermeability_qp_dgradvar)[_qp].resize(LIBMESH_DIM);
97  for (const auto i : make_range(Moose::dim))
98  {
99  (*_dpermeability_qp_dgradvar)[_qp][i].resize(_num_var, RealTensorValue());
100  for (unsigned int v = 0; v < _num_var; ++v)
101  (*_dpermeability_qp_dgradvar)[_qp][i][v] =
102  _AA * _permeability_qp[_qp] * (*_dporosity_qp_dgradvar)[_qp][v](i);
103  }
104  }
105 }
106 
Material designed to provide the permeability tensor which is calculated from porosity using the equa...
Real _AA
Empirical constant AA in k = k_ijk * BB * exp(AA * phi)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
registerMooseObject("PorousFlowApp", PorousFlowPermeabilityExponential)
Real _BB
Empirical constant BB in k = k_ijk * BB * exp(AA * phi)
static constexpr std::size_t dim
Base class Material designed to provide the permeability tensor.
PorousFlowPermeabilityExponentialTempl(const InputParameters &parameters)
enum PorousFlowPermeabilityExponentialTempl::PoropermFunction _poroperm_function
void addRequiredParam(const std::string &name, const std::string &doc_string)
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)
PoropermFunction
Name of porosity-permeability relationship.