LCOV - code coverage report
Current view: top level - src/kernels - PorousFlowEffectiveStressCoupling.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #33380 (547b29) with base 8581c3 Lines: 36 40 90.0 %
Date: 2026-07-20 19:40:36 Functions: 8 10 80.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 "PorousFlowEffectiveStressCoupling.h"
      11             : 
      12             : #include "Function.h"
      13             : #include "MooseMesh.h"
      14             : #include "MooseVariable.h"
      15             : 
      16             : registerMooseObject("PorousFlowApp", PorousFlowEffectiveStressCoupling);
      17             : registerMooseObject("PorousFlowApp", ADPorousFlowEffectiveStressCoupling);
      18             : 
      19             : template <bool is_ad>
      20             : InputParameters
      21        2661 : PorousFlowEffectiveStressCouplingTempl<is_ad>::validParams()
      22             : {
      23             :   InputParameters params = GenericKernel<is_ad>::validParams();
      24        2661 :   params.addClassDescription("Implements the weak form of the expression biot_coefficient * "
      25             :                              "grad(effective fluid pressure)");
      26        5322 :   params.addRequiredParam<UserObjectName>(
      27             :       "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
      28        5322 :   params.addRangeCheckedParam<Real>(
      29             :       "biot_coefficient", 1, "biot_coefficient>=0&biot_coefficient<=1", "Biot coefficient");
      30        5322 :   params.addRequiredParam<unsigned int>("component",
      31             :                                         "The component (0 for x, 1 for y and 2 for z) of grad(P)");
      32        2661 :   return params;
      33           0 : }
      34             : 
      35             : template <bool is_ad>
      36        1403 : PorousFlowEffectiveStressCouplingTempl<is_ad>::PorousFlowEffectiveStressCouplingTempl(
      37             :     const InputParameters & parameters)
      38             :   : GenericKernel<is_ad>(parameters),
      39        1403 :     _dictator(this->template getUserObject<PorousFlowDictator>("PorousFlowDictator")),
      40        2806 :     _coefficient(this->template getParam<Real>("biot_coefficient")),
      41        2806 :     _component(this->template getParam<unsigned int>("component")),
      42        2806 :     _pf(this->template getGenericMaterialProperty<Real, is_ad>(
      43             :         "PorousFlow_effective_fluid_pressure_qp")),
      44        1403 :     _dpf_dvar(is_ad ? nullptr
      45        1389 :                     : &this->template getMaterialProperty<std::vector<Real>>(
      46             :                           "dPorousFlow_effective_fluid_pressure_qp_dvar")),
      47        2806 :     _rz(this->getBlockCoordSystem() == Moose::COORD_RZ)
      48             : {
      49        1403 :   if (_component >= this->_mesh.dimension())
      50           0 :     this->paramError("component", "The component cannot be greater than the mesh dimension");
      51        1403 : }
      52             : 
      53             : template <bool is_ad>
      54             : GenericReal<is_ad>
      55    79540992 : PorousFlowEffectiveStressCouplingTempl<is_ad>::computeQpResidual()
      56             : {
      57    79540992 :   if (_rz && _component == 0)
      58       36752 :     return -_coefficient * _pf[_qp] * (_grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0));
      59    79505904 :   return -_coefficient * _pf[_qp] * _grad_test[_i][_qp](_component);
      60             : }
      61             : 
      62             : template <bool is_ad>
      63             : Real
      64   268597504 : PorousFlowEffectiveStressCouplingTempl<is_ad>::computeQpJacobian()
      65             : {
      66             :   if constexpr (!is_ad)
      67             :   {
      68   268597504 :     if (_dictator.notPorousFlowVariable(_var.number()))
      69             :       return 0.0;
      70   253623040 :     const unsigned int pvar = _dictator.porousFlowVariableNum(_var.number());
      71   253623040 :     if (_rz && _component == 0)
      72      106176 :       return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
      73      106176 :              (_grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0));
      74   253516864 :     return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
      75   253516864 :            _grad_test[_i][_qp](_component);
      76             :   }
      77           0 :   return 0.0;
      78             : }
      79             : 
      80             : template <bool is_ad>
      81             : Real
      82   883509248 : PorousFlowEffectiveStressCouplingTempl<is_ad>::computeQpOffDiagJacobian(unsigned int jvar)
      83             : {
      84             :   if constexpr (!is_ad)
      85             :   {
      86   883509248 :     if (_dictator.notPorousFlowVariable(jvar))
      87             :       return 0.0;
      88   853560320 :     const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
      89   853560320 :     if (_rz && _component == 0)
      90      305600 :       return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
      91      305600 :              (_grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0));
      92   853254720 :     return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
      93   853254720 :            _grad_test[_i][_qp](_component);
      94             :   }
      95             :   else
      96             :     libmesh_ignore(jvar);
      97           0 :   return 0.0;
      98             : }
      99             : 
     100             : template class PorousFlowEffectiveStressCouplingTempl<false>;
     101             : template class PorousFlowEffectiveStressCouplingTempl<true>;

Generated by: LCOV version 1.14