LCOV - code coverage report
Current view: top level - src/materials - PorousFlowMatrixInternalEnergy.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 31 33 93.9 %
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 "PorousFlowMatrixInternalEnergy.h"
      11             : 
      12             : registerMooseObject("PorousFlowApp", PorousFlowMatrixInternalEnergy);
      13             : registerMooseObject("PorousFlowApp", ADPorousFlowMatrixInternalEnergy);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17        4870 : PorousFlowMatrixInternalEnergyTempl<is_ad>::validParams()
      18             : {
      19        4870 :   InputParameters params = PorousFlowMaterialVectorBase::validParams();
      20        9740 :   params.addRequiredParam<Real>("specific_heat_capacity",
      21             :                                 "Specific heat capacity of the rock grains (J/kg/K).");
      22        9740 :   params.addRequiredParam<Real>("density", "Density of the rock grains");
      23        4870 :   params.set<bool>("at_nodes") = is_ad ? false : true;
      24        9740 :   params.addPrivateParam<std::string>("pf_material_type", "matrix_internal_energy");
      25        4870 :   params.addClassDescription("This Material calculates the internal energy of solid rock grains, "
      26             :                              "which is specific_heat_capacity * density * temperature.  Kernels "
      27             :                              "multiply this by (1 - porosity) to find the energy density of the "
      28             :                              "porous rock in a rock-fluid system");
      29        4870 :   return params;
      30           0 : }
      31             : 
      32             : template <bool is_ad>
      33        3816 : PorousFlowMatrixInternalEnergyTempl<is_ad>::PorousFlowMatrixInternalEnergyTempl(
      34             :     const InputParameters & parameters)
      35             :   : PorousFlowMaterialVectorBase(parameters),
      36        3816 :     _cp(getParam<Real>("specific_heat_capacity")),
      37        7632 :     _density(getParam<Real>("density")),
      38        3816 :     _heat_cap(_cp * _density),
      39        3816 :     _temperature(is_ad ? getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_qp")
      40        3618 :                        : getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_nodal")),
      41        3816 :     _dtemperature_dvar(
      42             :         is_ad ? nullptr
      43        3618 :               : &getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")),
      44        7632 :     _energy(declareGenericProperty<Real, is_ad>("PorousFlow_matrix_internal_energy_nodal")),
      45        3816 :     _denergy_dvar(is_ad ? nullptr
      46        3618 :                         : &declareProperty<std::vector<Real>>(
      47        3816 :                               "dPorousFlow_matrix_internal_energy_nodal_dvar"))
      48             : {
      49        3618 :   if (!is_ad && _nodal_material != true)
      50           0 :     mooseError("PorousFlowMatrixInternalEnergy classes are only defined for at_nodes = true");
      51        3816 : }
      52             : 
      53             : template <bool is_ad>
      54             : void
      55      149335 : PorousFlowMatrixInternalEnergyTempl<is_ad>::initQpStatefulProperties()
      56             : {
      57      150805 :   _energy[_qp] = _heat_cap * _temperature[_qp];
      58      149335 : }
      59             : 
      60             : template <bool is_ad>
      61             : void
      62     5892430 : PorousFlowMatrixInternalEnergyTempl<is_ad>::computeQpProperties()
      63             : {
      64     6200310 :   _energy[_qp] = _heat_cap * _temperature[_qp];
      65             : 
      66             :   if constexpr (!is_ad)
      67             :   {
      68     5584550 :     (*_denergy_dvar)[_qp].assign(_num_var, 0.0);
      69    17601232 :     for (unsigned v = 0; v < _num_var; ++v)
      70    12016682 :       (*_denergy_dvar)[_qp][v] = _heat_cap * (*_dtemperature_dvar)[_qp][v];
      71             :   }
      72     5892430 : }
      73             : 
      74             : template class PorousFlowMatrixInternalEnergyTempl<false>;
      75             : template class PorousFlowMatrixInternalEnergyTempl<true>;

Generated by: LCOV version 1.14