LCOV - code coverage report
Current view: top level - src/materials - PorousFlowPorosityHMBiotModulus.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 41 42 97.6 %
Date: 2025-09-04 07:55:56 Functions: 3 3 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 "PorousFlowPorosityHMBiotModulus.h"
      11             : #include "libmesh/utility.h"
      12             : 
      13             : registerMooseObject("PorousFlowApp", PorousFlowPorosityHMBiotModulus);
      14             : 
      15             : InputParameters
      16         680 : PorousFlowPorosityHMBiotModulus::validParams()
      17             : {
      18         680 :   InputParameters params = PorousFlowPorosity::validParams();
      19         680 :   params.set<bool>("mechanical") = true;
      20         680 :   params.set<bool>("fluid") = true;
      21        1360 :   params.addRequiredRangeCheckedParam<Real>("constant_biot_modulus",
      22             :                                             "constant_biot_modulus>0",
      23             :                                             "Biot modulus, which is constant for this Material");
      24        1360 :   params.addRequiredRangeCheckedParam<Real>(
      25             :       "constant_fluid_bulk_modulus",
      26             :       "constant_fluid_bulk_modulus>0",
      27             :       "Fluid bulk modulus, which is constant for this Material");
      28         680 :   params.addClassDescription(
      29             :       "This Material calculates the porosity for hydro-mechanical simulations, assuming that the "
      30             :       "Biot modulus and the fluid bulk modulus are both constant.  This is useful for comparing "
      31             :       "with solutions from poroelasticity theory, but is less accurate than PorousFlowPorosity");
      32         680 :   return params;
      33           0 : }
      34             : 
      35         528 : PorousFlowPorosityHMBiotModulus::PorousFlowPorosityHMBiotModulus(const InputParameters & parameters)
      36             :   : PorousFlowPorosity(parameters),
      37         264 :     _porosity_old(_nodal_material ? getMaterialPropertyOld<Real>("PorousFlow_porosity_nodal")
      38        1056 :                                   : getMaterialPropertyOld<Real>("PorousFlow_porosity_qp")),
      39        1056 :     _biot_modulus(getParam<Real>("constant_biot_modulus")),
      40        1056 :     _fluid_bulk_modulus(getParam<Real>("constant_fluid_bulk_modulus")),
      41        1056 :     _pf_old(_nodal_material
      42         528 :                 ? getMaterialPropertyOld<Real>("PorousFlow_effective_fluid_pressure_nodal")
      43        1056 :                 : getMaterialPropertyOld<Real>("PorousFlow_effective_fluid_pressure_qp")),
      44        1056 :     _vol_strain_qp_old(getMaterialPropertyOld<Real>("PorousFlow_total_volumetric_strain_qp")),
      45        1056 :     _vol_strain_rate_qp(getMaterialProperty<Real>("PorousFlow_volumetric_strain_rate_qp")),
      46        1056 :     _dvol_strain_rate_qp_dvar(getMaterialProperty<std::vector<RealGradient>>(
      47         528 :         "dPorousFlow_volumetric_strain_rate_qp_dvar"))
      48             : {
      49         528 : }
      50             : 
      51             : void
      52     2636844 : PorousFlowPorosityHMBiotModulus::computeQpProperties()
      53             : {
      54             :   // Note that in the following _strain[_qp] is evaluated at q quadpoint
      55             :   // So _porosity_nodal[_qp], which should be the nodal value of porosity
      56             :   // actually uses the strain at a quadpoint.  This
      57             :   // is OK for LINEAR elements, as strain is constant over the element anyway.
      58             : 
      59             :   const unsigned qp_to_use =
      60     2636844 :       (_nodal_material && (_bnd || _strain_at_nearest_qp) ? nearestQP(_qp) : _qp);
      61             : 
      62     2636844 :   const Real denom = (1.0 + _vol_strain_rate_qp[qp_to_use] * _dt + _vol_strain_qp_old[qp_to_use]);
      63     2636844 :   const Real s_p = _porosity_old[_qp] * (1 + _vol_strain_qp_old[qp_to_use]);
      64     2636844 :   _porosity[_qp] = (s_p * std::exp(-((*_pf)[_qp] - _pf_old[_qp]) / _fluid_bulk_modulus) +
      65     2636844 :                     ((*_pf)[_qp] - _pf_old[_qp]) / _biot_modulus +
      66     2636844 :                     _biot * ((*_vol_strain_qp)[qp_to_use] - _vol_strain_qp_old[qp_to_use])) /
      67             :                    denom;
      68             : 
      69     2636844 :   (*_dporosity_dvar)[_qp].resize(_num_var);
      70    13184220 :   for (unsigned int v = 0; v < _num_var; ++v)
      71    10547376 :     (*_dporosity_dvar)[_qp][v] =
      72    10547376 :         (*_dpf_dvar)[_qp][v] *
      73    10547376 :         (-s_p * std::exp(-((*_pf)[_qp] - _pf_old[_qp]) / _fluid_bulk_modulus) /
      74    10547376 :              _fluid_bulk_modulus +
      75    10547376 :          1.0 / _biot_modulus) /
      76             :         denom;
      77             : 
      78     2636844 :   (*_dporosity_dgradvar)[_qp].resize(_num_var);
      79    13184220 :   for (unsigned int v = 0; v < _num_var; ++v)
      80    10547376 :     (*_dporosity_dgradvar)[_qp][v] =
      81    10547376 :         _biot * (*_dvol_strain_qp_dvar)[qp_to_use][v] / denom -
      82    10547376 :         _porosity[_qp] / denom * _dvol_strain_rate_qp_dvar[qp_to_use][v] * _dt;
      83     2636844 : }

Generated by: LCOV version 1.14