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 "PorousFlowPermeabilityExponential.h" 11 : 12 : registerMooseObject("PorousFlowApp", PorousFlowPermeabilityExponential); 13 : registerMooseObject("PorousFlowApp", ADPorousFlowPermeabilityExponential); 14 : 15 : template <bool is_ad> 16 : InputParameters 17 156 : PorousFlowPermeabilityExponentialTempl<is_ad>::validParams() 18 : { 19 156 : InputParameters params = PorousFlowPermeabilityBase::validParams(); 20 312 : MooseEnum poroperm_function("log_k ln_k exp_k", "exp_k"); 21 312 : 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 312 : 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 312 : params.addRequiredParam<Real>("A", "Empirical constant; see poroperm_function."); 33 312 : params.addRequiredParam<Real>("B", "Empirical constant; see poroperm_function."); 34 156 : 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 156 : return params; 40 156 : } 41 : 42 : template <bool is_ad> 43 120 : PorousFlowPermeabilityExponentialTempl<is_ad>::PorousFlowPermeabilityExponentialTempl( 44 : const InputParameters & parameters) 45 : : PorousFlowPermeabilityBaseTempl<is_ad>(parameters), 46 120 : _A(this->template getParam<Real>("A")), 47 240 : _B(this->template getParam<Real>("B")), 48 240 : _k_anisotropy(parameters.isParamValid("k_anisotropy") 49 240 : ? 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 120 : _porosity_qp(this->template getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp")), 52 120 : _dporosity_qp_dvar(is_ad ? nullptr 53 90 : : &this->template getMaterialProperty<std::vector<Real>>( 54 : "dPorousFlow_porosity_qp_dvar")), 55 120 : _dporosity_qp_dgradvar(is_ad ? nullptr 56 90 : : &this->template getMaterialProperty<std::vector<RealGradient>>( 57 : "dPorousFlow_porosity_qp_dgradvar")), 58 240 : _poroperm_function(this->template getParam<MooseEnum>("poroperm_function") 59 120 : .template getEnum<PoropermFunction>()) 60 : { 61 120 : switch (_poroperm_function) 62 : { 63 30 : case PoropermFunction::log_k: 64 30 : _AA = _A * std::log(10.0); 65 30 : _BB = std::pow(10.0, _B); 66 30 : break; 67 : 68 30 : case PoropermFunction::ln_k: 69 30 : _AA = _A; 70 30 : _BB = std::exp(_B); 71 30 : break; 72 : 73 60 : case PoropermFunction::exp_k: 74 60 : _AA = _A; 75 60 : _BB = _B; 76 60 : break; 77 : } 78 : 79 : // Make sure that derivatives are included in the Jacobian calculations 80 120 : _dictator.usePermDerivs(true); 81 120 : } 82 : 83 : template <bool is_ad> 84 : void 85 864 : PorousFlowPermeabilityExponentialTempl<is_ad>::computeQpProperties() 86 : { 87 : using std::exp; 88 : 89 1296 : _permeability_qp[_qp] = _k_anisotropy * _BB * exp(_porosity_qp[_qp] * _AA); 90 : 91 : if constexpr (!is_ad) 92 : { 93 648 : (*_dpermeability_qp_dvar)[_qp].resize(_num_var, RealTensorValue()); 94 1296 : for (unsigned int v = 0; v < _num_var; ++v) 95 648 : (*_dpermeability_qp_dvar)[_qp][v] = 96 648 : _AA * _permeability_qp[_qp] * (*_dporosity_qp_dvar)[_qp][v]; 97 : 98 648 : (*_dpermeability_qp_dgradvar)[_qp].resize(LIBMESH_DIM); 99 2592 : for (const auto i : make_range(Moose::dim)) 100 : { 101 1944 : (*_dpermeability_qp_dgradvar)[_qp][i].resize(_num_var, RealTensorValue()); 102 3888 : for (unsigned int v = 0; v < _num_var; ++v) 103 1944 : (*_dpermeability_qp_dgradvar)[_qp][i][v] = 104 1944 : _AA * _permeability_qp[_qp] * (*_dporosity_qp_dgradvar)[_qp][v](i); 105 : } 106 : } 107 864 : } 108 : 109 : template class PorousFlowPermeabilityExponentialTempl<false>; 110 : template class PorousFlowPermeabilityExponentialTempl<true>;