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 28645 : PorousFlowTemperatureTempl<is_ad>::validParams() 18 : { 19 28645 : InputParameters params = PorousFlowMaterial::validParams(); 20 57290 : 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 57290 : params.addPrivateParam<std::string>("pf_material_type", "temperature"); 25 28645 : params.addClassDescription("Material to provide temperature at the quadpoints or nodes and " 26 : "derivatives of it with respect to the PorousFlow variables"); 27 28645 : return params; 28 0 : } 29 : 30 : template <bool is_ad> 31 22227 : PorousFlowTemperatureTempl<is_ad>::PorousFlowTemperatureTempl(const InputParameters & parameters) 32 : : PorousFlowMaterial(parameters), 33 : 34 44454 : _num_pf_vars(_dictator.numVariables()), 35 27489 : _is_temp_nodal(isCoupled("temperature") ? getFieldVar("temperature", 0)->isNodal() : false), 36 10212 : _temperature_var(_nodal_material && _is_temp_nodal 37 24780 : ? coupledGenericDofValue<is_ad>("temperature") 38 41901 : : coupledGenericValue<is_ad>("temperature")), 39 22227 : _grad_temperature_var(_nodal_material ? nullptr 40 22227 : : &coupledGenericGradient<is_ad>("temperature")), 41 22227 : _temperature_is_PF(_dictator.isPorousFlowVariable(coupled("temperature"))), 42 22227 : _t_var_num(_temperature_is_PF ? _dictator.porousFlowVariableNum(coupled("temperature")) : 0), 43 : 44 22227 : _temperature(_nodal_material 45 10212 : ? declareGenericProperty<Real, is_ad>("PorousFlow_temperature_nodal") 46 46257 : : declareGenericProperty<Real, is_ad>("PorousFlow_temperature_qp")), 47 22227 : _dtemperature_dvar( 48 21633 : is_ad ? nullptr 49 21633 : : _nodal_material 50 10212 : ? &declareProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar") 51 33054 : : &declareProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")), 52 22227 : _grad_temperature((_nodal_material) ? nullptr 53 34242 : : &declareGenericProperty<RealGradient, is_ad>( 54 : "PorousFlow_grad_temperature_qp")), 55 22227 : _dgrad_temperature_dgradv( 56 21633 : (_nodal_material || is_ad) 57 21633 : ? nullptr 58 21633 : : &declareProperty<std::vector<Real>>("dPorousFlow_grad_temperature_qp_dgradvar")), 59 22227 : _dgrad_temperature_dv((_nodal_material || is_ad) ? nullptr 60 21633 : : &declareProperty<std::vector<RealGradient>>( 61 22227 : "dPorousFlow_grad_temperature_qp_dvar")) 62 : { 63 22227 : } 64 : 65 : template <bool is_ad> 66 : void 67 3085464 : PorousFlowTemperatureTempl<is_ad>::initQpStatefulProperties() 68 : { 69 3085464 : computeQpProperties(); 70 3085464 : } 71 : 72 : template <bool is_ad> 73 : void 74 66821626 : PorousFlowTemperatureTempl<is_ad>::computeQpProperties() 75 : { 76 66821626 : _temperature[_qp] = _temperature_var[_qp]; 77 : 78 66821626 : if (!_nodal_material) 79 36449535 : (*_grad_temperature)[_qp] = (*_grad_temperature_var)[_qp]; 80 : 81 : if (!is_ad) 82 : { 83 66272836 : (*_dtemperature_dvar)[_qp].assign(_num_pf_vars, 0.0); 84 66272836 : if (_temperature_is_PF) 85 : // _temperature is a PorousFlow variable 86 8875923 : (*_dtemperature_dvar)[_qp][_t_var_num] = 1.0; 87 : 88 66272836 : if (!_nodal_material) 89 : { 90 35900745 : (*_dgrad_temperature_dgradv)[_qp].assign(_num_pf_vars, 0.0); 91 35900745 : (*_dgrad_temperature_dv)[_qp].assign(_num_pf_vars, RealGradient()); 92 35900745 : if (_temperature_is_PF) 93 4791150 : (*_dgrad_temperature_dgradv)[_qp][_t_var_num] = 1.0; 94 : } 95 : } 96 66821626 : } 97 : 98 : template class PorousFlowTemperatureTempl<false>; 99 : template class PorousFlowTemperatureTempl<true>;