LCOV - code coverage report
Current view: top level - src/materials - PorousFlowVariableBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 67 68 98.5 %
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 "PorousFlowVariableBase.h"
      11             : 
      12             : template <bool is_ad>
      13             : InputParameters
      14       67298 : PorousFlowVariableBaseTempl<is_ad>::validParams()
      15             : {
      16       67298 :   InputParameters params = PorousFlowMaterial::validParams();
      17      134596 :   params.addPrivateParam<std::string>("pf_material_type", "pressure_saturation");
      18       67298 :   params.addClassDescription("Base class for thermophysical variable materials. Provides pressure "
      19             :                              "and saturation material properties for all phases as required");
      20       67298 :   return params;
      21           0 : }
      22             : 
      23             : template <bool is_ad>
      24       52634 : PorousFlowVariableBaseTempl<is_ad>::PorousFlowVariableBaseTempl(const InputParameters & parameters)
      25             :   : DerivativeMaterialInterface<PorousFlowMaterial>(parameters),
      26             : 
      27      105268 :     _num_phases(_dictator.numPhases()),
      28       52634 :     _num_components(_dictator.numComponents()),
      29       52634 :     _num_pf_vars(_dictator.numVariables()),
      30             : 
      31      105268 :     _porepressure(
      32       52634 :         _nodal_material
      33       20296 :             ? declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_nodal")
      34      117310 :             : declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp")),
      35      103540 :     _dporepressure_dvar(is_ad             ? nullptr
      36       50906 :                         : _nodal_material ? &declareProperty<std::vector<std::vector<Real>>>(
      37             :                                                 "dPorousFlow_porepressure_nodal_dvar")
      38       81516 :                                           : &declareProperty<std::vector<std::vector<Real>>>(
      39             :                                                 "dPorousFlow_porepressure_qp_dvar")),
      40       52634 :     _gradp_qp(_nodal_material ? nullptr
      41       84972 :                               : &declareGenericProperty<std::vector<RealGradient>, is_ad>(
      42             :                                     "PorousFlow_grad_porepressure_qp")),
      43      103540 :     _dgradp_qp_dgradv((_nodal_material || is_ad)
      44       50906 :                           ? nullptr
      45       50906 :                           : &declareProperty<std::vector<std::vector<Real>>>(
      46             :                                 "dPorousFlow_grad_porepressure_qp_dgradvar")),
      47      103540 :     _dgradp_qp_dv((_nodal_material || is_ad)
      48       50906 :                       ? nullptr
      49       50906 :                       : &declareProperty<std::vector<std::vector<RealGradient>>>(
      50             :                             "dPorousFlow_grad_porepressure_qp_dvar")),
      51             : 
      52      105268 :     _saturation(
      53       52634 :         _nodal_material
      54       20296 :             ? declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_nodal")
      55      117310 :             : declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_qp")),
      56       52634 :     _dsaturation_dvar(
      57       50906 :         is_ad ? nullptr
      58       50906 :         : _nodal_material
      59       20296 :             ? &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_nodal_dvar")
      60       81516 :             : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_qp_dvar")),
      61       52634 :     _grads_qp(_nodal_material ? nullptr
      62       84972 :                               : &declareGenericProperty<std::vector<RealGradient>, is_ad>(
      63             :                                     "PorousFlow_grad_saturation_qp")),
      64       52634 :     _dgrads_qp_dgradv((_nodal_material || is_ad) ? nullptr
      65       50906 :                                                  : &declareProperty<std::vector<std::vector<Real>>>(
      66             :                                                        "dPorousFlow_grad_saturation_qp_dgradvar")),
      67      103540 :     _dgrads_qp_dv((_nodal_material || is_ad)
      68       50906 :                       ? nullptr
      69       50906 :                       : &declareProperty<std::vector<std::vector<RealGradient>>>(
      70       52634 :                             "dPorousFlow_grad_saturation_qp_dvar"))
      71             : {
      72       52634 : }
      73             : 
      74             : template <bool is_ad>
      75             : void
      76     5305315 : PorousFlowVariableBaseTempl<is_ad>::initQpStatefulProperties()
      77             : {
      78     5305315 :   _porepressure[_qp].resize(_num_phases);
      79     5305315 :   _saturation[_qp].resize(_num_phases);
      80             :   // the porepressure and saturation values get set by derived classes
      81     5305315 : }
      82             : 
      83             : template <bool is_ad>
      84             : void
      85    94389210 : PorousFlowVariableBaseTempl<is_ad>::computeQpProperties()
      86             : {
      87             :   // do we really need this stuff here?  it seems very inefficient to keep resizing everything!
      88    94389210 :   _porepressure[_qp].resize(_num_phases);
      89    94389210 :   _saturation[_qp].resize(_num_phases);
      90             : 
      91             :   if (!is_ad)
      92             :   {
      93    93606751 :     (*_dporepressure_dvar)[_qp].resize(_num_phases);
      94    93606751 :     (*_dsaturation_dvar)[_qp].resize(_num_phases);
      95             :   }
      96             : 
      97    94389210 :   if (!_nodal_material)
      98             :   {
      99    51709684 :     (*_gradp_qp)[_qp].resize(_num_phases);
     100    51709684 :     (*_grads_qp)[_qp].resize(_num_phases);
     101             : 
     102             :     if (!is_ad)
     103             :     {
     104    50927225 :       (*_dgradp_qp_dgradv)[_qp].resize(_num_phases);
     105    50927225 :       (*_dgradp_qp_dv)[_qp].resize(_num_phases);
     106             : 
     107    50927225 :       (*_dgrads_qp_dgradv)[_qp].resize(_num_phases);
     108    50927225 :       (*_dgrads_qp_dv)[_qp].resize(_num_phases);
     109             :     }
     110             :   }
     111             : 
     112             :   // Prepare the derivative matrices with zeroes
     113             :   if (!is_ad)
     114   194509620 :     for (unsigned phase = 0; phase < _num_phases; ++phase)
     115             :     {
     116             : 
     117   100902869 :       (*_dporepressure_dvar)[_qp][phase].assign(_num_pf_vars, 0.0);
     118   100902869 :       (*_dsaturation_dvar)[_qp][phase].assign(_num_pf_vars, 0.0);
     119   100902869 :       if (!_nodal_material)
     120             :       {
     121    54593279 :         (*_dgradp_qp_dgradv)[_qp][phase].assign(_num_pf_vars, 0.0);
     122    54593279 :         (*_dgradp_qp_dv)[_qp][phase].assign(_num_pf_vars, RealGradient());
     123    54593279 :         (*_dgrads_qp_dgradv)[_qp][phase].assign(_num_pf_vars, 0.0);
     124    54593279 :         (*_dgrads_qp_dv)[_qp][phase].assign(_num_pf_vars, RealGradient());
     125             :       }
     126             :     }
     127    94389210 : }
     128             : 
     129             : template class PorousFlowVariableBaseTempl<false>;
     130             : template class PorousFlowVariableBaseTempl<true>;

Generated by: LCOV version 1.14