LCOV - code coverage report
Current view: top level - src/materials - PorousFlowPermeabilityKozenyCarmanBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #32971 (54bef8) with base c6cf66 Lines: 36 37 97.3 %
Date: 2026-05-29 20:38:56 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          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         538 : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>::validParams()
      15             : {
      16         538 :   InputParameters params = PorousFlowPermeabilityBase::validParams();
      17        1076 :   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        1076 :   params.addRequiredRangeCheckedParam<Real>("n", "n >= 0", "Porosity exponent");
      23        1076 :   params.addRequiredRangeCheckedParam<Real>("m", "m >= 0", "(1-porosity) exponent");
      24         538 :   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         538 :   return params;
      31           0 : }
      32             : 
      33             : template <bool is_ad>
      34         416 : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>::PorousFlowPermeabilityKozenyCarmanBaseTempl(
      35             :     const InputParameters & parameters)
      36             :   : PorousFlowPermeabilityBaseTempl<is_ad>(parameters),
      37         416 :     _m(this->template getParam<Real>("m")),
      38         832 :     _n(this->template getParam<Real>("n")),
      39         736 :     _k_anisotropy(parameters.isParamValid("k_anisotropy")
      40         832 :                       ? 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         416 :     _porosity_qp(this->template getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp")),
      43         416 :     _dporosity_qp_dvar(is_ad ? nullptr
      44         386 :                              : &this->template getMaterialProperty<std::vector<Real>>(
      45             :                                    "dPorousFlow_porosity_qp_dvar")),
      46         416 :     _dporosity_qp_dgradvar(is_ad ? nullptr
      47         386 :                                  : &this->template getMaterialProperty<std::vector<RealGradient>>(
      48         416 :                                        "dPorousFlow_porosity_qp_dgradvar"))
      49             : {
      50             :   // Make sure that derivatives are included in the Jacobian calculations
      51         416 :   _dictator.usePermDerivs(true);
      52         416 : }
      53             : 
      54             : template <bool is_ad>
      55             : void
      56      429780 : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>::computeQpProperties()
      57             : {
      58             :   using std::pow;
      59             : 
      60      429780 :   Real A = computeA();
      61      429994 :   _permeability_qp[_qp] =
      62      429994 :       _k_anisotropy * A * pow(_porosity_qp[_qp], _n) / pow(1.0 - _porosity_qp[_qp], _m);
      63             : 
      64             :   if constexpr (!is_ad)
      65             :   {
      66      429562 :     (*_dpermeability_qp_dvar)[_qp].resize(_num_var, RealTensorValue());
      67     1307942 :     for (unsigned int v = 0; v < _num_var; ++v)
      68      878380 :       (*_dpermeability_qp_dvar)[_qp][v] = (*_dporosity_qp_dvar)[_qp][v] * _permeability_qp[_qp] *
      69      878380 :                                           (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
      70             : 
      71      429562 :     (*_dpermeability_qp_dgradvar)[_qp].resize(LIBMESH_DIM);
      72     1718248 :     for (const auto i : make_range(Moose::dim))
      73             :     {
      74     1288686 :       (*_dpermeability_qp_dgradvar)[_qp][i].resize(_num_var, RealTensorValue());
      75     3923826 :       for (unsigned int v = 0; v < _num_var; ++v)
      76     2635140 :         (*_dpermeability_qp_dgradvar)[_qp][i][v] =
      77     2635140 :             (*_dporosity_qp_dgradvar)[_qp][v](i) * _permeability_qp[_qp] *
      78     2635140 :             (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
      79             :     }
      80             :   }
      81      429778 : }
      82             : 
      83             : template class PorousFlowPermeabilityKozenyCarmanBaseTempl<false>;
      84             : template class PorousFlowPermeabilityKozenyCarmanBaseTempl<true>;

Generated by: LCOV version 1.14