https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowTemperature.C
Go to the documentation of this file.
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
11
14
15template <bool is_ad>
18{
20 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 params.addPrivateParam<std::string>("pf_material_type", "temperature");
25 params.addClassDescription("Material to provide temperature at the quadpoints or nodes and "
26 "derivatives of it with respect to the PorousFlow variables");
27 return params;
28}
29
30template <bool is_ad>
32 : PorousFlowMaterial(parameters),
33
34 _num_pf_vars(_dictator.numVariables()),
35 _is_temp_nodal(isCoupled("temperature") ? getFieldVar("temperature", 0)->isNodal() : false),
36 _temperature_var(_nodal_material && _is_temp_nodal
37 ? coupledGenericDofValue<is_ad>("temperature")
38 : coupledGenericValue<is_ad>("temperature")),
39 _grad_temperature_var(_nodal_material ? nullptr
40 : &coupledGenericGradient<is_ad>("temperature")),
41 _temperature_is_PF(_dictator.isPorousFlowVariable(coupled("temperature"))),
42 _t_var_num(_temperature_is_PF ? _dictator.porousFlowVariableNum(coupled("temperature")) : 0),
43
44 _temperature(_nodal_material
45 ? declareGenericProperty<Real, is_ad>("PorousFlow_temperature_nodal")
46 : declareGenericProperty<Real, is_ad>("PorousFlow_temperature_qp")),
47 _dtemperature_dvar(
48 is_ad ? nullptr
49 : _nodal_material
50 ? &declareProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")
51 : &declareProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")),
52 _grad_temperature((_nodal_material) ? nullptr
53 : &declareGenericProperty<RealGradient, is_ad>(
54 "PorousFlow_grad_temperature_qp")),
55 _dgrad_temperature_dgradv(
56 (_nodal_material || is_ad)
57 ? nullptr
58 : &declareProperty<std::vector<Real>>("dPorousFlow_grad_temperature_qp_dgradvar")),
59 _dgrad_temperature_dv((_nodal_material || is_ad) ? nullptr
60 : &declareProperty<std::vector<RealGradient>>(
61 "dPorousFlow_grad_temperature_qp_dvar"))
62{
63 // A non-nodal temperature is supported when it is merely a coupled variable: _is_temp_nodal above
64 // falls back to the quadpoint values, which is how an isothermal simulation can supply
65 // temperature as a CONSTANT MONOMIAL AuxVariable. That fallback is not enough when temperature
66 // is itself a PorousFlow variable, because then this nodal Material also supplies the
67 // temperature derivatives that the nodal Jacobian assembly indexes per node. See #33370.
69 this->checkNodalVariables({"temperature"});
70}
71
72template <bool is_ad>
73void
78
79template <bool is_ad>
80void
82{
83 _temperature[_qp] = _temperature_var[_qp];
84
85 if (!_nodal_material)
86 (*_grad_temperature)[_qp] = (*_grad_temperature_var)[_qp];
87
88 if (!is_ad)
89 {
90 (*_dtemperature_dvar)[_qp].assign(_num_pf_vars, 0.0);
91 if (_temperature_is_PF)
92 // _temperature is a PorousFlow variable
93 (*_dtemperature_dvar)[_qp][_t_var_num] = 1.0;
94
95 if (!_nodal_material)
96 {
97 (*_dgrad_temperature_dgradv)[_qp].assign(_num_pf_vars, 0.0);
98 (*_dgrad_temperature_dv)[_qp].assign(_num_pf_vars, RealGradient());
99 if (_temperature_is_PF)
100 (*_dgrad_temperature_dgradv)[_qp][_t_var_num] = 1.0;
101 }
102 }
103}
104
registerMooseObject("PorousFlowApp", PorousFlowTemperature)
void addPrivateParam(const std::string &name, const T &value)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
PorousFlowMaterial is the base class for all PorousFlow Materials It allows users to specify that the...
static InputParameters validParams()
const bool _nodal_material
Whether the derived class holds nodal values.
void checkNodalVariables(const std::vector< std::string > &coupled_var_params) const
Error if this is a nodal Material but a variable supplied to one of the named coupled-variable parame...
Creates temperature Materials.
virtual void initQpStatefulProperties() override
virtual void computeQpProperties() override
const bool _temperature_is_PF
Whether the temperature coupled variable is a PorousFlow variable.
PorousFlowTemperatureTempl(const InputParameters &parameters)
static InputParameters validParams()