LCOV - code coverage report
Current view: top level - src/materials - PorousFlow1PhaseP.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 40 43 93.0 %
Date: 2025-09-04 07:55:56 Functions: 10 10 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 "PorousFlow1PhaseP.h"
      11             : #include "PorousFlowCapillaryPressure.h"
      12             : 
      13             : registerMooseObject("PorousFlowApp", PorousFlow1PhaseP);
      14             : registerMooseObject("PorousFlowApp", ADPorousFlow1PhaseP);
      15             : 
      16             : template <bool is_ad>
      17             : InputParameters
      18       23784 : PorousFlow1PhasePTempl<is_ad>::validParams()
      19             : {
      20       23784 :   InputParameters params = PorousFlowVariableBase::validParams();
      21       47568 :   params.addRequiredCoupledVar("porepressure",
      22             :                                "Variable that represents the porepressure of the single phase");
      23       47568 :   params.addRequiredParam<UserObjectName>("capillary_pressure",
      24             :                                           "Name of the UserObject defining the capillary pressure");
      25       23784 :   params.addClassDescription("This Material is used for the partially saturated single-phase "
      26             :                              "situation where porepressure is the primary variable");
      27       23784 :   return params;
      28           0 : }
      29             : 
      30             : template <bool is_ad>
      31       18669 : PorousFlow1PhasePTempl<is_ad>::PorousFlow1PhasePTempl(const InputParameters & parameters)
      32             :   : PorousFlowVariableBaseTempl<is_ad>(parameters),
      33        9060 :     _porepressure_var(_nodal_material ? this->template coupledGenericDofValue<is_ad>("porepressure")
      34       28278 :                                       : this->template coupledGenericValue<is_ad>("porepressure")),
      35       18669 :     _gradp_qp_var(this->template coupledGenericGradient<is_ad>("porepressure")),
      36       18669 :     _porepressure_varnum(coupled("porepressure")),
      37       18669 :     _p_var_num(_dictator.isPorousFlowVariable(_porepressure_varnum)
      38       18669 :                    ? _dictator.porousFlowVariableNum(_porepressure_varnum)
      39             :                    : 0),
      40       37338 :     _pc_uo(this->template getUserObject<PorousFlowCapillaryPressure>("capillary_pressure"))
      41             : {
      42       18669 :   if (_num_phases != 1)
      43           0 :     mooseError("The Dictator proclaims that the number of phases is ",
      44           0 :                _dictator.numPhases(),
      45             :                " whereas PorousFlow1PhaseP can only be used for 1-phase simulations.  Be aware "
      46             :                "that the Dictator has noted your mistake.");
      47       18669 : }
      48             : 
      49             : template <bool is_ad>
      50             : void
      51     1154483 : PorousFlow1PhasePTempl<is_ad>::initQpStatefulProperties()
      52             : {
      53     1154483 :   PorousFlowVariableBaseTempl<is_ad>::initQpStatefulProperties();
      54     1154483 :   buildQpPPSS();
      55     1154483 : }
      56             : 
      57             : template <bool is_ad>
      58             : void
      59    42800430 : PorousFlow1PhasePTempl<is_ad>::computeQpProperties()
      60             : {
      61             :   // size stuff correctly and prepare the derivative matrices with zeroes
      62    42800430 :   PorousFlowVariableBaseTempl<is_ad>::computeQpProperties();
      63             : 
      64    42800430 :   buildQpPPSS();
      65             : 
      66    42800430 :   const auto ds = _pc_uo.dSaturation(_porepressure_var[_qp]);
      67             : 
      68    42800430 :   if (!_nodal_material)
      69             :   {
      70    21440462 :     (*_gradp_qp)[_qp][0] = _gradp_qp_var[_qp];
      71    21777214 :     (*_grads_qp)[_qp][0] = ds * _gradp_qp_var[_qp];
      72             :   }
      73             : 
      74             :     // _porepressure is only dependent on _porepressure, and its derivative is 1
      75             :   if constexpr (!is_ad)
      76    42463678 :     if (_dictator.isPorousFlowVariable(_porepressure_varnum))
      77             :     {
      78             :       // _porepressure is a PorousFlow variable
      79    42460848 :       (*_dporepressure_dvar)[_qp][0][_p_var_num] = 1.0;
      80    42460848 :       (*_dsaturation_dvar)[_qp][0][_p_var_num] = ds;
      81             : 
      82    42460848 :       if (!_nodal_material)
      83             :       {
      84    21100880 :         (*_dgradp_qp_dgradv)[_qp][0][_p_var_num] = 1.0;
      85    21100880 :         (*_dgrads_qp_dgradv)[_qp][0][_p_var_num] = ds;
      86    21100880 :         (*_dgrads_qp_dv)[_qp][0][_p_var_num] =
      87    21100880 :             _pc_uo.d2Saturation(_porepressure_var[_qp]) * _gradp_qp_var[_qp];
      88             :       }
      89             :     }
      90    42800430 : }
      91             : 
      92             : template <bool is_ad>
      93             : void
      94    43954913 : PorousFlow1PhasePTempl<is_ad>::buildQpPPSS()
      95             : {
      96    43954913 :   _porepressure[_qp][0] = _porepressure_var[_qp];
      97    43954913 :   _saturation[_qp][0] = _pc_uo.saturation(_porepressure_var[_qp]);
      98    43954913 : }
      99             : 
     100             : template class PorousFlow1PhasePTempl<false>;
     101             : template class PorousFlow1PhasePTempl<true>;

Generated by: LCOV version 1.14