https://mooseframework.inl.gov
PorousFlowFluidPropertiesBase.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 
12 template <bool is_ad>
15 {
17  MooseEnum unit_choice("Kelvin=0 Celsius=1", "Kelvin");
18  params.addParam<MooseEnum>(
19  "temperature_unit", unit_choice, "The unit of the temperature variable");
20  MooseEnum p_unit_choice("Pa MPa", "Pa");
21  params.addParam<MooseEnum>("pressure_unit",
22  p_unit_choice,
23  "The unit of the pressure variable used everywhere in the input file "
24  "except for in the FluidProperties-module objects");
25  MooseEnum time_unit_choice("seconds hours days years", "seconds");
26  params.addParam<MooseEnum>("time_unit",
27  time_unit_choice,
28  "The unit of time used everywhere in the input file except for in the "
29  "FluidProperties-module objects");
30  params.addParam<bool>(
31  "compute_density_and_viscosity", true, "Compute the fluid density and viscosity");
32  params.addParam<bool>("compute_internal_energy", true, "Compute the fluid internal energy");
33  params.addParam<bool>("compute_enthalpy", true, "Compute the fluid enthalpy");
34  params.addPrivateParam<std::string>("pf_material_type", "fluid_properties");
35  params.addPrivateParam<bool>("is_ad", is_ad);
36  params.addClassDescription("Base class for PorousFlow fluid materials");
37  return params;
38 }
39 
40 template <bool is_ad>
42  const InputParameters & parameters)
43  : PorousFlowMaterialBase(parameters),
44  _porepressure(
45  _nodal_material
46  ? getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_nodal")
47  : getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp")),
48  _temperature(_nodal_material
49  ? getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_nodal")
50  : getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_qp")),
51  _t_c2k(getParam<MooseEnum>("temperature_unit") == 0 ? 0.0 : 273.15),
52  _R(8.3144598),
53  _p_unit(
54  this->template getParam<MooseEnum>("pressure_unit").template getEnum<PressureUnitEnum>()),
55  _pressure_to_Pascals(_p_unit == PressureUnitEnum::Pa ? 1.0 : 1.0E6),
56  _time_unit(this->template getParam<MooseEnum>("time_unit").template getEnum<TimeUnitEnum>()),
57  _time_to_seconds(_time_unit == TimeUnitEnum::seconds ? 1.0
58  : _time_unit == TimeUnitEnum::hours ? 3600.0
59  : _time_unit == TimeUnitEnum::days ? 3600.0 * 24
60  : 3600 * 24 * 365.25),
61  _compute_rho_mu(this->template getParam<bool>("compute_density_and_viscosity")),
62  _compute_internal_energy(this->template getParam<bool>("compute_internal_energy")),
63  _compute_enthalpy(this->template getParam<bool>("compute_enthalpy")),
64  _density(_compute_rho_mu
65  ? (_nodal_material ? &this->template declareGenericProperty<Real, is_ad>(
66  "PorousFlow_fluid_phase_density_nodal" + _phase)
67  : &this->template declareGenericProperty<Real, is_ad>(
68  "PorousFlow_fluid_phase_density_qp" + _phase))
69  : nullptr),
70  _ddensity_dp(
71  (_compute_rho_mu && !is_ad)
72  ? (_nodal_material
73  ? &this->template declarePropertyDerivative<Real>(
74  "PorousFlow_fluid_phase_density_nodal" + _phase, _pressure_variable_name)
75  : &this->template declarePropertyDerivative<Real>(
76  "PorousFlow_fluid_phase_density_qp" + _phase, _pressure_variable_name))
77  : nullptr),
78  _ddensity_dT((_compute_rho_mu && !is_ad)
79  ? (_nodal_material ? &this->template declarePropertyDerivative<Real>(
80  "PorousFlow_fluid_phase_density_nodal" + _phase,
81  _temperature_variable_name)
82  : &this->template declarePropertyDerivative<Real>(
83  "PorousFlow_fluid_phase_density_qp" + _phase,
84  _temperature_variable_name))
85  : nullptr),
86 
87  _viscosity(_compute_rho_mu
88  ? (_nodal_material ? &this->template declareGenericProperty<Real, is_ad>(
89  "PorousFlow_viscosity_nodal" + _phase)
90  : &this->template declareGenericProperty<Real, is_ad>(
91  "PorousFlow_viscosity_qp" + _phase))
92  : nullptr),
93  _dviscosity_dp((_compute_rho_mu && !is_ad)
94  ? (_nodal_material
95  ? &this->template declarePropertyDerivative<Real>(
96  "PorousFlow_viscosity_nodal" + _phase, _pressure_variable_name)
97  : &this->template declarePropertyDerivative<Real>(
98  "PorousFlow_viscosity_qp" + _phase, _pressure_variable_name))
99  : nullptr),
100  _dviscosity_dT(
101  (_compute_rho_mu && !is_ad)
102  ? (_nodal_material
103  ? &this->template declarePropertyDerivative<Real>(
104  "PorousFlow_viscosity_nodal" + _phase, _temperature_variable_name)
105  : &this->template declarePropertyDerivative<Real>(
106  "PorousFlow_viscosity_qp" + _phase, _temperature_variable_name))
107  : nullptr),
108 
109  _internal_energy(_compute_internal_energy
110  ? (_nodal_material
111  ? &this->template declareGenericProperty<Real, is_ad>(
112  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase)
113  : &this->template declareGenericProperty<Real, is_ad>(
114  "PorousFlow_fluid_phase_internal_energy_qp" + _phase))
115  : nullptr),
116  _dinternal_energy_dp((_compute_internal_energy && !is_ad)
117  ? (_nodal_material
118  ? &this->template declarePropertyDerivative<Real>(
119  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
120  _pressure_variable_name)
121  : &this->template declarePropertyDerivative<Real>(
122  "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
123  _pressure_variable_name))
124  : nullptr),
125  _dinternal_energy_dT((_compute_internal_energy && !is_ad)
126  ? (_nodal_material
127  ? &this->template declarePropertyDerivative<Real>(
128  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
129  _temperature_variable_name)
130  : &this->template declarePropertyDerivative<Real>(
131  "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
132  _temperature_variable_name))
133  : nullptr),
134 
135  _enthalpy(_compute_enthalpy
136  ? (_nodal_material ? &this->template declareGenericProperty<Real, is_ad>(
137  "PorousFlow_fluid_phase_enthalpy_nodal" + _phase)
138  : &this->template declareGenericProperty<Real, is_ad>(
139  "PorousFlow_fluid_phase_enthalpy_qp" + _phase))
140  : nullptr),
141  _denthalpy_dp(
142  (_compute_enthalpy && !is_ad)
143  ? (_nodal_material
144  ? &this->template declarePropertyDerivative<Real>(
145  "PorousFlow_fluid_phase_enthalpy_nodal" + _phase, _pressure_variable_name)
146  : &this->template declarePropertyDerivative<Real>(
147  "PorousFlow_fluid_phase_enthalpy_qp" + _phase, _pressure_variable_name))
148  : nullptr),
149  _denthalpy_dT((_compute_enthalpy && !is_ad)
150  ? (_nodal_material ? &this->template declarePropertyDerivative<Real>(
151  "PorousFlow_fluid_phase_enthalpy_nodal" + _phase,
152  _temperature_variable_name)
153  : &this->template declarePropertyDerivative<Real>(
154  "PorousFlow_fluid_phase_enthalpy_qp" + _phase,
155  _temperature_variable_name))
156  : nullptr)
157 {
158 }
159 
160 template <bool is_ad>
161 void
163 {
164  mooseError("computeQpProperties() must be overriden in materials derived from "
165  "PorousFlowFluidPropertiesBase");
166 }
167 
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addPrivateParam(const std::string &name, const T &value)
void mooseError(Args &&... args)
Base class for fluid properties materials.
Base class for all PorousFlow materials that provide phase-dependent properties.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
PorousFlowFluidPropertiesBaseTempl(const InputParameters &parameters)