LCOV - code coverage report
Current view: top level - src/materials - PorousFlowPermeabilityKozenyCarman.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 48 51 94.1 %
Date: 2025-09-04 07:55:56 Functions: 8 8 100.0 %
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 "PorousFlowPermeabilityKozenyCarman.h"
      11             : 
      12             : registerMooseObject("PorousFlowApp", PorousFlowPermeabilityKozenyCarman);
      13             : registerMooseObject("PorousFlowApp", ADPorousFlowPermeabilityKozenyCarman);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17         946 : PorousFlowPermeabilityKozenyCarmanTempl<is_ad>::validParams()
      18             : {
      19         946 :   InputParameters params = PorousFlowPermeabilityKozenyCarmanBase::validParams();
      20        1892 :   MooseEnum poroperm_function("kozeny_carman_fd2=0 kozeny_carman_phi0=1 kozeny_carman_A=2",
      21             :                               "kozeny_carman_fd2");
      22        1892 :   params.addParam<MooseEnum>(
      23             :       "poroperm_function",
      24             :       poroperm_function,
      25             :       "Function relating porosity and permeability. The options are: kozeny_carman_fd2 = f d^2 "
      26             :       "phi^n/(1-phi)^m (where phi is porosity, f is a scalar constant with typical values "
      27             :       "0.01-0.001, and d is grain size). kozeny_carman_phi0 = k0 (1-phi0)^m/phi0^n * "
      28             :       "phi^n/(1-phi)^m (where phi is porosity, and k0 is the permeability at porosity phi0)  "
      29             :       "kozeny_carman_A = A for directly supplying the permeability multiplying factor.");
      30        1892 :   params.addRangeCheckedParam<Real>("k0",
      31             :                                     "k0 > 0",
      32             :                                     "The permeability scalar value (usually in "
      33             :                                     "m^2) at the reference porosity, required for "
      34             :                                     "kozeny_carman_phi0");
      35        1892 :   params.addParam<RealTensorValue>("k_anisotropy",
      36             :                                    "A tensor to multiply the calculated scalar "
      37             :                                    "permeability, in order to obtain anisotropy if "
      38             :                                    "required. Defaults to isotropic permeability "
      39             :                                    "if not specified.");
      40        1892 :   params.addRangeCheckedParam<Real>(
      41             :       "phi0", "phi0 > 0 & phi0 < 1", "The reference porosity, required for kozeny_carman_phi0");
      42        1892 :   params.addRangeCheckedParam<Real>(
      43             :       "f", "f > 0", "The multiplying factor, required for kozeny_carman_fd2");
      44        1892 :   params.addRangeCheckedParam<Real>(
      45             :       "d", "d > 0", "The grain diameter, required for kozeny_carman_fd2");
      46        1892 :   params.addRangeCheckedParam<Real>(
      47             :       "A", "A > 0", "Kozeny Carman permeability multiplying factor, required for kozeny_carman_A");
      48         946 :   params.addClassDescription("This Material calculates the permeability tensor from a form of the "
      49             :                              "Kozeny-Carman equation based on the spatially constant initial "
      50             :                              "permeability and porosity or grain size.");
      51         946 :   return params;
      52         946 : }
      53             : 
      54             : template <bool is_ad>
      55         737 : PorousFlowPermeabilityKozenyCarmanTempl<is_ad>::PorousFlowPermeabilityKozenyCarmanTempl(
      56             :     const InputParameters & parameters)
      57             :   : PorousFlowPermeabilityKozenyCarmanBaseTempl<is_ad>(parameters),
      58        1475 :     _k0(parameters.isParamValid("k0") ? this->template getParam<Real>("k0") : -1),
      59        1479 :     _phi0(parameters.isParamValid("phi0") ? this->template getParam<Real>("phi0") : -1),
      60        1205 :     _f(parameters.isParamValid("f") ? this->template getParam<Real>("f") : -1),
      61        1205 :     _d(parameters.isParamValid("d") ? this->template getParam<Real>("d") : -1),
      62        1474 :     _poroperm_function(this->template getParam<MooseEnum>("poroperm_function")
      63             :                            .template getEnum<PoropermFunction>()),
      64        1742 :     _A(parameters.isParamValid("A") ? this->template getParam<Real>("A") : -1)
      65             : {
      66         737 :   auto checkForInvalidParams =
      67        2339 :       [&](const std::string & bad_param, const std::string & poroperm_function)
      68             :   {
      69        2341 :     if (parameters.isParamValid(bad_param))
      70           4 :       this->paramError(bad_param, "Not compatible with '" + poroperm_function + "'.");
      71             :   };
      72             : 
      73         737 :   switch (_poroperm_function)
      74             :   {
      75         234 :     case PoropermFunction::kozeny_carman_fd2:
      76         468 :       if (!(parameters.isParamValid("f") && parameters.isParamValid("d")))
      77           0 :         mooseError("You must specify f and d in order to use kozeny_carman_fd2 in "
      78             :                    "PorousFlowPermeabilityKozenyCarman");
      79         468 :       checkForInvalidParams("A", "kozeny_carman_fd2");
      80         468 :       checkForInvalidParams("k0", "kozeny_carman_fd2");
      81         468 :       checkForInvalidParams("phi0", "kozeny_carman_fd2");
      82         234 :       _A = _f * _d * _d;
      83         234 :       break;
      84             : 
      85         369 :     case PoropermFunction::kozeny_carman_phi0:
      86         738 :       if (!(parameters.isParamValid("k0") && parameters.isParamValid("phi0")))
      87           0 :         mooseError("You must specify k0 and phi0 in order to use kozeny_carman_phi0 in "
      88             :                    "PorousFlowPermeabilityKozenyCarman");
      89         738 :       checkForInvalidParams("A", "kozeny_carman_phi0");
      90         738 :       checkForInvalidParams("f", "kozeny_carman_phi0");
      91         738 :       checkForInvalidParams("d", "kozeny_carman_phi0");
      92         369 :       _A = _k0 * std::pow(1.0 - _phi0, this->_m) / std::pow(_phi0, this->_n);
      93         369 :       break;
      94             :     case PoropermFunction::kozeny_carman_A:
      95         268 :       if (!(parameters.isParamValid("A")))
      96           0 :         mooseError("You must specify A in order to use kozeny_carman_A in "
      97             :                    "PorousFlowPermeabilityKozenyCarman");
      98         268 :       checkForInvalidParams("k0", "kozeny_carman_A");
      99         266 :       checkForInvalidParams("phi0", "kozeny_carman_A");
     100         264 :       checkForInvalidParams("f", "kozeny_carman_A");
     101         264 :       checkForInvalidParams("d", "kozeny_carman_A");
     102             : 
     103         132 :       break;
     104             :   }
     105         735 : }
     106             : 
     107             : template <bool is_ad>
     108             : Real
     109      610348 : PorousFlowPermeabilityKozenyCarmanTempl<is_ad>::computeA() const
     110             : {
     111      610348 :   return _A;
     112             : }
     113             : 
     114             : template class PorousFlowPermeabilityKozenyCarmanTempl<false>;
     115             : template class PorousFlowPermeabilityKozenyCarmanTempl<true>;

Generated by: LCOV version 1.14