Line data Source code
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 : 10 : #include "PorousFlowPermeabilityKozenyCarmanBase.h" 11 : 12 : template <bool is_ad> 13 : InputParameters 14 1042 : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>::validParams() 15 : { 16 1042 : InputParameters params = PorousFlowPermeabilityBase::validParams(); 17 2084 : 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 2084 : params.addRequiredRangeCheckedParam<Real>("n", "n >= 0", "Porosity exponent"); 23 2084 : params.addRequiredRangeCheckedParam<Real>("m", "m >= 0", "(1-porosity) exponent"); 24 1042 : 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 1042 : return params; 31 0 : } 32 : 33 : template <bool is_ad> 34 812 : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>::PorousFlowPermeabilityKozenyCarmanBaseTempl( 35 : const InputParameters & parameters) 36 : : PorousFlowPermeabilityBaseTempl<is_ad>(parameters), 37 812 : _m(this->template getParam<Real>("m")), 38 1624 : _n(this->template getParam<Real>("n")), 39 1456 : _k_anisotropy(parameters.isParamValid("k_anisotropy") 40 1624 : ? 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 812 : _porosity_qp(this->template getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp")), 43 812 : _dporosity_qp_dvar(is_ad ? nullptr 44 746 : : &this->template getMaterialProperty<std::vector<Real>>( 45 : "dPorousFlow_porosity_qp_dvar")), 46 812 : _dporosity_qp_dgradvar(is_ad ? nullptr 47 746 : : &this->template getMaterialProperty<std::vector<RealGradient>>( 48 812 : "dPorousFlow_porosity_qp_dgradvar")) 49 : { 50 : // Make sure that derivatives are included in the Jacobian calculations 51 812 : _dictator.usePermDerivs(true); 52 812 : } 53 : 54 : template <bool is_ad> 55 : void 56 610690 : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>::computeQpProperties() 57 : { 58 610690 : Real A = computeA(); 59 611012 : _permeability_qp[_qp] = 60 611012 : _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 610364 : (*_dpermeability_qp_dvar)[_qp].resize(_num_var, RealTensorValue()); 65 1853066 : for (unsigned int v = 0; v < _num_var; ++v) 66 1242702 : (*_dpermeability_qp_dvar)[_qp][v] = (*_dporosity_qp_dvar)[_qp][v] * _permeability_qp[_qp] * 67 1242702 : (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp])); 68 : 69 610364 : (*_dpermeability_qp_dgradvar)[_qp].resize(LIBMESH_DIM); 70 2441456 : for (const auto i : make_range(Moose::dim)) 71 : { 72 1831092 : (*_dpermeability_qp_dgradvar)[_qp][i].resize(_num_var, RealTensorValue()); 73 5559198 : for (unsigned int v = 0; v < _num_var; ++v) 74 3728106 : (*_dpermeability_qp_dgradvar)[_qp][i][v] = 75 3728106 : (*_dporosity_qp_dgradvar)[_qp][v](i) * _permeability_qp[_qp] * 76 3728106 : (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp])); 77 : } 78 : } 79 610688 : } 80 : 81 : template class PorousFlowPermeabilityKozenyCarmanBaseTempl<false>; 82 : template class PorousFlowPermeabilityKozenyCarmanBaseTempl<true>;