LCOV - code coverage report
Current view: top level - src/materials - PorousFlowPermeabilityKozenyCarman.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 57 59 96.6 %
Date: 2017-11-17 17:48:31 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************/
       2             : /* MOOSE - Multiphysics Object Oriented Simulation Environment  */
       3             : /*                                                              */
       4             : /*          All contents are licensed under LGPL V2.1           */
       5             : /*             See LICENSE for full restrictions                */
       6             : /****************************************************************/
       7             : 
       8             : #include "PorousFlowPermeabilityKozenyCarman.h"
       9             : 
      10             : template <>
      11             : InputParameters
      12           5 : validParams<PorousFlowPermeabilityKozenyCarman>()
      13             : {
      14           5 :   InputParameters params = validParams<PorousFlowPermeabilityBase>();
      15          15 :   MooseEnum poroperm_function("kozeny_carman_fd2=0 kozeny_carman_phi0=1", "kozeny_carman_fd2");
      16          15 :   params.addParam<MooseEnum>(
      17             :       "poroperm_function",
      18             :       poroperm_function,
      19             :       "Function relating porosity and permeability. The options are: kozeny_carman_fd2 = f d^2 "
      20             :       "phi^n/(1-phi)^m (where phi is porosity, f is a scalar constant with typical values "
      21             :       "0.01-0.001, and d is grain size). kozeny_carman_phi0 = k0 (1-phi0)^m/phi0^n * "
      22           5 :       "phi^n/(1-phi)^m (where phi is porosity, and k0 is the permeability at porosity phi0)");
      23          20 :   params.addRangeCheckedParam<Real>("k0",
      24             :                                     "k0 > 0",
      25             :                                     "The permeability scalar value (usually in "
      26             :                                     "m^2) at the reference porosity, required for "
      27           5 :                                     "kozeny_carman_phi0");
      28          15 :   params.addParam<RealTensorValue>("k_anisotropy",
      29             :                                    "A tensor to multiply the calculated scalar "
      30             :                                    "permeability, in order to obtain anisotropy if "
      31             :                                    "required. Defaults to isotropic permeability "
      32           5 :                                    "if not specified.");
      33          20 :   params.addRangeCheckedParam<Real>(
      34           5 :       "phi0", "phi0 > 0 & phi0 < 1", "The reference porosity, required for kozeny_carman_phi0");
      35          20 :   params.addRangeCheckedParam<Real>(
      36           5 :       "f", "f > 0", "The multiplying factor, required for kozeny_carman_fd2");
      37          20 :   params.addRangeCheckedParam<Real>(
      38           5 :       "d", "d > 0", "The grain diameter, required for kozeny_carman_fd2");
      39          20 :   params.addRequiredRangeCheckedParam<Real>("n", "n >= 0", "Porosity exponent");
      40          20 :   params.addRequiredRangeCheckedParam<Real>("m", "m >= 0", "(1-porosity) exponent");
      41          10 :   params.addClassDescription(
      42             :       "This Material calculates the permeability tensor from a form of the Kozeny-Carman equation, "
      43             :       "k = k_ijk * A * phi^n / (1 - phi)^m, where k_ijk is a tensor providing the anisotropy, phi "
      44             :       "is porosity, n and m are positive scalar constants and A is given in one of the following "
      45             :       "forms: A = k0 * (1 - phi0)^m / phi0^n (where k0 and phi0 are a reference permeability and "
      46           5 :       "porosity) or A = f * d^2 (where f is a scalar constant and d is grain diameter.");
      47           5 :   return params;
      48             : }
      49             : 
      50          15 : PorousFlowPermeabilityKozenyCarman::PorousFlowPermeabilityKozenyCarman(
      51          15 :     const InputParameters & parameters)
      52             :   : PorousFlowPermeabilityBase(parameters),
      53          57 :     _k0(parameters.isParamValid("k0") ? getParam<Real>("k0") : -1),
      54          57 :     _phi0(parameters.isParamValid("phi0") ? getParam<Real>("phi0") : -1),
      55          63 :     _f(parameters.isParamValid("f") ? getParam<Real>("f") : -1),
      56          63 :     _d(parameters.isParamValid("d") ? getParam<Real>("d") : -1),
      57          45 :     _m(getParam<Real>("m")),
      58          45 :     _n(getParam<Real>("n")),
      59          30 :     _k_anisotropy(parameters.isParamValid("k_anisotropy")
      60          45 :                       ? getParam<RealTensorValue>("k_anisotropy")
      61             :                       : RealTensorValue(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)),
      62          30 :     _porosity_qp(getMaterialProperty<Real>("PorousFlow_porosity_qp")),
      63          30 :     _dporosity_qp_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_qp_dvar")),
      64             :     _dporosity_qp_dgradvar(
      65          30 :         getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_qp_dgradvar")),
      66         225 :     _poroperm_function(getParam<MooseEnum>("poroperm_function").getEnum<PoropermFunction>())
      67             : {
      68          15 :   switch (_poroperm_function)
      69             :   {
      70             :     case PoropermFunction::kozeny_carman_fd2:
      71          27 :       if (!(parameters.isParamValid("f") && parameters.isParamValid("d")))
      72             :         mooseError("You must specify f and d in order to use kozeny_carman_fd2 in "
      73           0 :                    "PorousFlowPermeabilityKozenyCarman");
      74           9 :       _A = _f * _d * _d;
      75           9 :       break;
      76             : 
      77             :     case PoropermFunction::kozeny_carman_phi0:
      78          18 :       if (!(parameters.isParamValid("k0") && parameters.isParamValid("phi0")))
      79             :         mooseError("You must specify k0 and phi0 in order to use kozeny_carman_phi0 in "
      80           0 :                    "PorousFlowPermeabilityKozenyCarman");
      81           6 :       _A = _k0 * std::pow(1.0 - _phi0, _m) / std::pow(_phi0, _n);
      82           6 :       break;
      83             :   }
      84          15 : }
      85             : 
      86             : void
      87        2052 : PorousFlowPermeabilityKozenyCarman::computeQpProperties()
      88             : {
      89        4104 :   _permeability_qp[_qp] =
      90        6156 :       _k_anisotropy * _A * std::pow(_porosity_qp[_qp], _n) / std::pow(1.0 - _porosity_qp[_qp], _m);
      91             : 
      92        4104 :   _dpermeability_qp_dvar[_qp].resize(_num_var, RealTensorValue());
      93       11244 :   for (unsigned int v = 0; v < _num_var; ++v)
      94       22980 :     _dpermeability_qp_dvar[_qp][v] = _dporosity_qp_dvar[_qp][v] * _permeability_qp[_qp] *
      95        9192 :                                      (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
      96             : 
      97        4104 :   _dpermeability_qp_dgradvar[_qp].resize(LIBMESH_DIM);
      98       14364 :   for (unsigned i = 0; i < LIBMESH_DIM; ++i)
      99             :   {
     100       12312 :     _dpermeability_qp_dgradvar[_qp][i].resize(_num_var, RealTensorValue());
     101       33732 :     for (unsigned int v = 0; v < _num_var; ++v)
     102       27576 :       _dpermeability_qp_dgradvar[_qp][i][v] =
     103       41364 :           _dporosity_qp_dgradvar[_qp][v](i) * _permeability_qp[_qp] *
     104       27576 :           (_n / _porosity_qp[_qp] + _m / (1.0 - _porosity_qp[_qp]));
     105             :   }
     106        4551 : }

Generated by: LCOV version 1.11