LCOV - code coverage report
Current view: top level - src/materials - PorousFlowEffectiveFluidPressure.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #32971 (54bef8) with base c6cf66 Lines: 43 44 97.7 %
Date: 2026-05-29 20:38:56 Functions: 7 8 87.5 %
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 "PorousFlowEffectiveFluidPressure.h"
      11             : 
      12             : registerMooseObject("PorousFlowApp", PorousFlowEffectiveFluidPressure);
      13             : registerMooseObject("PorousFlowApp", ADPorousFlowEffectiveFluidPressure);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17        7540 : PorousFlowEffectiveFluidPressureTempl<is_ad>::validParams()
      18             : {
      19        7540 :   InputParameters params = PorousFlowMaterialVectorBase::validParams();
      20        7540 :   params.set<std::string>("pf_material_type") = "effective_pressure";
      21        7540 :   params.addClassDescription("This Material calculates an effective fluid pressure: "
      22             :                              "effective_stress = total_stress + "
      23             :                              "biot_coeff*effective_fluid_pressure.  The effective_fluid_pressure = "
      24             :                              "sum_{phases}(S_phase * P_phase)");
      25        7540 :   return params;
      26           0 : }
      27             : 
      28             : template <bool is_ad>
      29        5817 : PorousFlowEffectiveFluidPressureTempl<is_ad>::PorousFlowEffectiveFluidPressureTempl(
      30             :     const InputParameters & parameters)
      31             :   : PorousFlowMaterialVectorBase(parameters),
      32        5817 :     _porepressure(
      33        5817 :         _nodal_material
      34        2187 :             ? getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_nodal")
      35        9447 :             : getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp")),
      36       11544 :     _dporepressure_dvar(is_ad             ? nullptr
      37        5727 :                         : _nodal_material ? &getMaterialProperty<std::vector<std::vector<Real>>>(
      38             :                                                 "dPorousFlow_porepressure_nodal_dvar")
      39       12807 :                                           : &getMaterialProperty<std::vector<std::vector<Real>>>(
      40             :                                                 "dPorousFlow_porepressure_qp_dvar")),
      41        5817 :     _saturation(
      42        5817 :         _nodal_material
      43        5817 :             ? getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_nodal")
      44        9447 :             : getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_qp")),
      45       11544 :     _dsaturation_dvar(is_ad             ? nullptr
      46        5727 :                       : _nodal_material ? &getMaterialProperty<std::vector<std::vector<Real>>>(
      47             :                                               "dPorousFlow_saturation_nodal_dvar")
      48       12807 :                                         : &getMaterialProperty<std::vector<std::vector<Real>>>(
      49             :                                               "dPorousFlow_saturation_qp_dvar")),
      50        5817 :     _pf(_nodal_material
      51        2187 :             ? declareGenericProperty<Real, is_ad>("PorousFlow_effective_fluid_pressure_nodal")
      52       13077 :             : declareGenericProperty<Real, is_ad>("PorousFlow_effective_fluid_pressure_qp")),
      53        5817 :     _dpf_dvar(
      54        5727 :         is_ad ? nullptr
      55        5727 :         : _nodal_material
      56        2187 :             ? &declareProperty<std::vector<Real>>("dPorousFlow_effective_fluid_pressure_nodal_dvar")
      57       15084 :             : &declareProperty<std::vector<Real>>("dPorousFlow_effective_fluid_pressure_qp_dvar"))
      58             : {
      59        5817 : }
      60             : 
      61             : template <bool is_ad>
      62             : void
      63     2054771 : PorousFlowEffectiveFluidPressureTempl<is_ad>::initQpStatefulProperties()
      64             : {
      65     2054771 :   _pf[_qp] = 0.0;
      66     4112958 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      67     2058187 :     _pf[_qp] += _saturation[_qp][ph] * _porepressure[_qp][ph];
      68     2054771 : }
      69             : 
      70             : template <bool is_ad>
      71             : void
      72    28863698 : PorousFlowEffectiveFluidPressureTempl<is_ad>::computeQpProperties()
      73             : {
      74    28863698 :   _pf[_qp] = 0.0;
      75             : 
      76             :   if (!is_ad)
      77    28863050 :     (*_dpf_dvar)[_qp].assign(_num_var, 0.0);
      78             : 
      79    57771692 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      80             :   {
      81    28908642 :     _pf[_qp] += _saturation[_qp][ph] * _porepressure[_qp][ph];
      82             : 
      83             :     if constexpr (!is_ad)
      84   104996183 :       for (unsigned int v = 0; v < _num_var; ++v)
      85    76088837 :         (*_dpf_dvar)[_qp][v] += (*_dsaturation_dvar)[_qp][ph][v] * _porepressure[_qp][ph] +
      86    76088837 :                                 _saturation[_qp][ph] * (*_dporepressure_dvar)[_qp][ph][v];
      87             :   }
      88    28863698 : }

Generated by: LCOV version 1.14