LCOV - code coverage report
Current view: top level - src/materials - PorousFlowRelativePermeabilityBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 43 45 95.6 %
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 "PorousFlowRelativePermeabilityBase.h"
      11             : 
      12             : template <bool is_ad>
      13             : InputParameters
      14       41659 : PorousFlowRelativePermeabilityBaseTempl<is_ad>::validParams()
      15             : {
      16       41659 :   InputParameters params = PorousFlowMaterialBase::validParams();
      17      124977 :   params.addRangeCheckedParam<Real>(
      18       83318 :       "scaling", 1.0, "scaling>=0", "Relative permeability is multiplied by this factor");
      19       83318 :   params.addRangeCheckedParam<Real>(
      20             :       "s_res",
      21             :       0,
      22             :       "s_res >= 0 & s_res < 1",
      23             :       "The residual saturation of the phase j. Must be between 0 and 1");
      24       83318 :   params.addRangeCheckedParam<Real>(
      25             :       "sum_s_res",
      26             :       0,
      27             :       "sum_s_res >= 0 & sum_s_res < 1",
      28             :       "Sum of residual saturations over all phases.  Must be between 0 and 1");
      29       83318 :   params.addPrivateParam<std::string>("pf_material_type", "relative_permeability");
      30       41659 :   params.addPrivateParam<bool>("is_ad", is_ad);
      31       41659 :   params.addClassDescription("Base class for PorousFlow relative permeability materials");
      32       41659 :   return params;
      33           0 : }
      34             : 
      35             : template <bool is_ad>
      36       32571 : PorousFlowRelativePermeabilityBaseTempl<is_ad>::PorousFlowRelativePermeabilityBaseTempl(
      37             :     const InputParameters & parameters)
      38             :   : PorousFlowMaterialBase(parameters),
      39       32571 :     _scaling(getParam<Real>("scaling")),
      40       32571 :     _saturation(
      41       32571 :         _nodal_material
      42       32571 :             ? getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_nodal")
      43       49380 :             : getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_qp")),
      44       65142 :     _relative_permeability(
      45       32571 :         _nodal_material
      46       15762 :             ? declareGenericProperty<Real, is_ad>("PorousFlow_relative_permeability_nodal" + _phase)
      47       66189 :             : declareGenericProperty<Real, is_ad>("PorousFlow_relative_permeability_qp" + _phase)),
      48       32571 :     _drelative_permeability_ds(
      49       29994 :         is_ad ? nullptr
      50       29994 :         : _nodal_material
      51       61518 :             ? &declarePropertyDerivative<Real>("PorousFlow_relative_permeability_nodal" + _phase,
      52             :                                                _saturation_variable_name)
      53       72690 :             : &declarePropertyDerivative<Real>("PorousFlow_relative_permeability_qp" + _phase,
      54             :                                                _saturation_variable_name)),
      55       65142 :     _s_res(getParam<Real>("s_res")),
      56       65142 :     _sum_s_res(getParam<Real>("sum_s_res")),
      57       32571 :     _dseff_ds(1.0 / (1.0 - _sum_s_res))
      58             : {
      59       32571 :   if (_sum_s_res < _s_res)
      60           0 :     mooseError("Sum of residual saturations sum_s_res cannot be smaller than s_res in ", name());
      61       32571 : }
      62             : 
      63             : template <bool is_ad>
      64             : void
      65    42546494 : PorousFlowRelativePermeabilityBaseTempl<is_ad>::computeQpProperties()
      66             : {
      67             :   // Effective saturation
      68    42546494 :   GenericReal<is_ad> seff = effectiveSaturation(_saturation[_qp][_phase_num]);
      69             :   GenericReal<is_ad> relperm;
      70             :   Real drelperm;
      71             : 
      72    42546494 :   if (seff < 0.0)
      73             :   {
      74             :     // Relative permeability is 0 for saturation less than residual
      75      233856 :     relperm = 0.0;
      76             :     drelperm = 0.0;
      77             :   }
      78    42200905 :   else if (seff >= 0.0 && seff <= 1)
      79             :   {
      80    41881444 :     relperm = relativePermeability(seff);
      81    41881444 :     drelperm = dRelativePermeability(MetaPhysicL::raw_value(seff));
      82             :   }
      83             :   else // seff > 1
      84             :   {
      85             :     // Relative permeability is 1 when fully saturated
      86      233856 :     relperm = 1.0;
      87             :     drelperm = 0.0;
      88             :   }
      89             : 
      90    43605473 :   _relative_permeability[_qp] = relperm * _scaling;
      91             : 
      92             :   if (!is_ad)
      93    41487515 :     (*_drelative_permeability_ds)[_qp] = drelperm * _dseff_ds * _scaling;
      94    42546494 : }
      95             : 
      96             : template <bool is_ad>
      97             : GenericReal<is_ad>
      98    42546494 : PorousFlowRelativePermeabilityBaseTempl<is_ad>::effectiveSaturation(
      99             :     GenericReal<is_ad> saturation) const
     100             : {
     101    42546494 :   return (saturation - _s_res) / (1.0 - _sum_s_res);
     102             : }
     103             : 
     104             : template class PorousFlowRelativePermeabilityBaseTempl<false>;
     105             : template class PorousFlowRelativePermeabilityBaseTempl<true>;

Generated by: LCOV version 1.14