LCOV - code coverage report
Current view: top level - src/materials - PorousFlowTemperature.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 50 51 98.0 %
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 "PorousFlowTemperature.h"
      11             : 
      12             : registerMooseObject("PorousFlowApp", PorousFlowTemperature);
      13             : registerMooseObject("PorousFlowApp", ADPorousFlowTemperature);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17       56988 : PorousFlowTemperatureTempl<is_ad>::validParams()
      18             : {
      19       56988 :   InputParameters params = PorousFlowMaterial::validParams();
      20      113976 :   params.addCoupledVar("temperature",
      21             :                        293.0,
      22             :                        "Fluid temperature variable.  Note, the default is suitable if your "
      23             :                        "simulation is using Kelvin units, but probably not for Celsius");
      24      113976 :   params.addPrivateParam<std::string>("pf_material_type", "temperature");
      25       56988 :   params.addClassDescription("Material to provide temperature at the quadpoints or nodes and "
      26             :                              "derivatives of it with respect to the PorousFlow variables");
      27       56988 :   return params;
      28           0 : }
      29             : 
      30             : template <bool is_ad>
      31       44628 : PorousFlowTemperatureTempl<is_ad>::PorousFlowTemperatureTempl(const InputParameters & parameters)
      32             :   : PorousFlowMaterial(parameters),
      33             : 
      34       89256 :     _num_pf_vars(_dictator.numVariables()),
      35       54930 :     _is_temp_nodal(isCoupled("temperature") ? getFieldVar("temperature", 0)->isNodal() : false),
      36       20334 :     _temperature_var(_nodal_material && _is_temp_nodal
      37       49467 :                          ? coupledGenericDofValue<is_ad>("temperature")
      38       84417 :                          : coupledGenericValue<is_ad>("temperature")),
      39       44628 :     _grad_temperature_var(_nodal_material ? nullptr
      40       44628 :                                           : &coupledGenericGradient<is_ad>("temperature")),
      41       44628 :     _temperature_is_PF(_dictator.isPorousFlowVariable(coupled("temperature"))),
      42       44628 :     _t_var_num(_temperature_is_PF ? _dictator.porousFlowVariableNum(coupled("temperature")) : 0),
      43             : 
      44       44628 :     _temperature(_nodal_material
      45       20334 :                      ? declareGenericProperty<Real, is_ad>("PorousFlow_temperature_nodal")
      46       93216 :                      : declareGenericProperty<Real, is_ad>("PorousFlow_temperature_qp")),
      47       44628 :     _dtemperature_dvar(
      48       43362 :         is_ad ? nullptr
      49       43362 :         : _nodal_material
      50       20334 :             ? &declareProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")
      51       66390 :             : &declareProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")),
      52       44628 :     _grad_temperature((_nodal_material) ? nullptr
      53       68922 :                                         : &declareGenericProperty<RealGradient, is_ad>(
      54             :                                               "PorousFlow_grad_temperature_qp")),
      55       44628 :     _dgrad_temperature_dgradv(
      56       43362 :         (_nodal_material || is_ad)
      57       43362 :             ? nullptr
      58       43362 :             : &declareProperty<std::vector<Real>>("dPorousFlow_grad_temperature_qp_dgradvar")),
      59       44628 :     _dgrad_temperature_dv((_nodal_material || is_ad) ? nullptr
      60       43362 :                                                      : &declareProperty<std::vector<RealGradient>>(
      61       44628 :                                                            "dPorousFlow_grad_temperature_qp_dvar"))
      62             : {
      63       44628 : }
      64             : 
      65             : template <bool is_ad>
      66             : void
      67     4955783 : PorousFlowTemperatureTempl<is_ad>::initQpStatefulProperties()
      68             : {
      69     4955783 :   computeQpProperties();
      70     4955783 : }
      71             : 
      72             : template <bool is_ad>
      73             : void
      74    98692853 : PorousFlowTemperatureTempl<is_ad>::computeQpProperties()
      75             : {
      76    98692853 :   _temperature[_qp] = _temperature_var[_qp];
      77             : 
      78    98692853 :   if (!_nodal_material)
      79    53887692 :     (*_grad_temperature)[_qp] = (*_grad_temperature_var)[_qp];
      80             : 
      81             :   if (!is_ad)
      82             :   {
      83    97879064 :     (*_dtemperature_dvar)[_qp].assign(_num_pf_vars, 0.0);
      84    97879064 :     if (_temperature_is_PF)
      85             :       // _temperature is a PorousFlow variable
      86    13040196 :       (*_dtemperature_dvar)[_qp][_t_var_num] = 1.0;
      87             : 
      88    97879064 :     if (!_nodal_material)
      89             :     {
      90    53073903 :       (*_dgrad_temperature_dgradv)[_qp].assign(_num_pf_vars, 0.0);
      91    53073903 :       (*_dgrad_temperature_dv)[_qp].assign(_num_pf_vars, RealGradient());
      92    53073903 :       if (_temperature_is_PF)
      93     7086105 :         (*_dgrad_temperature_dgradv)[_qp][_t_var_num] = 1.0;
      94             :     }
      95             :   }
      96    98692853 : }
      97             : 
      98             : template class PorousFlowTemperatureTempl<false>;
      99             : template class PorousFlowTemperatureTempl<true>;

Generated by: LCOV version 1.14