https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12template <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");
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
33template <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
54template <bool is_ad>
55void
57{
58 using std::pow;
59
60 Real A = computeA();
61 _permeability_qp[_qp] =
62 _k_anisotropy * A * pow(_porosity_qp[_qp], _n) / pow(1.0 - _porosity_qp[_qp], _m);
63
64 if constexpr (!is_ad)
65 {
66 (*_dpermeability_qp_dvar)[_qp].resize(_num_var, RealTensorValue());
67 for (unsigned int v = 0; v < _num_var; ++v)
68 (*_dpermeability_qp_dvar)[_qp][v] = (*_dporosity_qp_dvar)[_qp][v] * _permeability_qp[_qp] *
69 (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
70
71 (*_dpermeability_qp_dgradvar)[_qp].resize(LIBMESH_DIM);
72 for (const auto i : make_range(Moose::dim))
73 {
74 (*_dpermeability_qp_dgradvar)[_qp][i].resize(_num_var, RealTensorValue());
75 for (unsigned int v = 0; v < _num_var; ++v)
76 (*_dpermeability_qp_dgradvar)[_qp][i][v] =
77 (*_dporosity_qp_dgradvar)[_qp][v](i) * _permeability_qp[_qp] *
78 (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
79 }
80 }
81}
82
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double v
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)
void addClassDescription(const std::string &doc_string)
Base class Material designed to provide the permeability tensor.
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