www.mooseframework.org
PorousFlowPropertyAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "PorousFlowPropertyAux.h"
11 
14 
15 template <bool is_ad>
18 {
20  params.addRequiredParam<UserObjectName>(
21  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names");
22  MooseEnum property_enum("pressure saturation temperature density viscosity mass_fraction relperm "
23  "capillary_pressure enthalpy internal_energy secondary_concentration "
24  "mineral_concentration mineral_reaction_rate porosity permeability "
25  "hysteresis_order hysteresis_saturation_turning_point hysteretic_info");
27  "property", property_enum, "The fluid property that this auxillary kernel is to calculate");
28  params.addParam<unsigned int>("phase", 0, "The index of the phase this auxillary kernel acts on");
29  params.addParam<unsigned int>(
30  "liquid_phase", 0, "The index of the liquid phase (used for capillary pressure)");
31  params.addParam<unsigned int>(
32  "gas_phase", 1, "The index of the gas phase (used for capillary pressure)");
33  params.addParam<unsigned int>(
34  "fluid_component", 0, "The index of the fluid component this auxillary kernel acts on");
35  params.addParam<unsigned int>("secondary_species", 0, "The secondary chemical species number");
36  params.addParam<unsigned int>("mineral_species", 0, "The mineral chemical species number");
37  params.addParam<unsigned int>(
38  "hysteresis_turning_point", 0, "The hysteresis turning point number");
39  params.addRangeCheckedParam<unsigned int>(
40  "row", 0, "row>=0 & row<=2", "Row of permeability tensor to output");
41  params.addRangeCheckedParam<unsigned int>(
42  "column", 0, "column>=0 & column<=2", "Column of permeability tensor to output");
43  params.addClassDescription("AuxKernel to provide access to properties evaluated at quadpoints. "
44  "Note that elemental AuxVariables must be used, so that these "
45  "properties are integrated over each element.");
46  return params;
47 }
48 
49 template <bool is_ad>
51  : AuxKernel(parameters),
52  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
53  _property_enum(getParam<MooseEnum>("property").template getEnum<PropertyEnum>()),
54  _phase(getParam<unsigned int>("phase")),
55  _liquid_phase(getParam<unsigned int>("liquid_phase")),
56  _gas_phase(getParam<unsigned int>("gas_phase")),
57  _fluid_component(getParam<unsigned int>("fluid_component")),
58  _secondary_species(getParam<unsigned int>("secondary_species")),
59  _mineral_species(getParam<unsigned int>("mineral_species")),
60  _hysteresis_turning_point(getParam<unsigned int>("hysteresis_turning_point")),
61  _k_row(getParam<unsigned int>("row")),
62  _k_col(getParam<unsigned int>("column"))
63 {
64  // Check that the phase and fluid_component are valid
65  if (_phase >= _dictator.numPhases())
66  paramError("phase",
67  "Phase number entered is greater than the number of phases specified in the "
68  "Dictator. Remember that indexing starts at 0");
69 
71  paramError("fluid_component",
72  "Fluid component number entered is greater than the number of fluid components "
73  "specified in the Dictator. Remember that indexing starts at 0");
74 
75  // Check the parameters used to calculate capillary pressure
77  {
79  paramError(
80  "liquid_phase",
81  "Liquid phase number entered is greater than the number of phases specified in the "
82  "Dictator. Remember that indexing starts at 0");
83 
85  paramError("gas_phase",
86  "Gas phase number entered is greater than the number of phases specified in the "
87  "Dictator. Remember that indexing starts at 0");
88 
90  paramError("liquid_phase", "Liquid phase number entered cannot be equal to gas_phase");
91  }
92 
95  paramError("secondary_species",
96  "Secondary species number entered is greater than the number of aqueous equilibrium "
97  "chemical reactions specified in the Dictator. Remember that indexing starts at 0");
98 
102  paramError("mineral_species",
103  "Mineral species number entered is greater than the number of aqueous "
104  "precipitation-dissolution chemical reactions specified in the Dictator. Remember "
105  "that indexing starts at 0");
106 
108  paramError("hysteresis_turning_point",
109  "The maximum number of hysteresis turning points is ",
111 
112  // Only get material properties required by this instance of the AuxKernel
113  switch (_property_enum)
114  {
116  _pressure =
117  &getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp");
118  break;
119 
121  _saturation =
122  &getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_qp");
123  break;
124 
126  _temperature = &getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_qp");
127  break;
128 
130  _fluid_density = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
131  "PorousFlow_fluid_phase_density_qp");
132  break;
133 
136  &getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_viscosity_qp");
137  break;
138 
140  _mass_fractions = &getGenericMaterialProperty<std::vector<std::vector<Real>>, is_ad>(
141  "PorousFlow_mass_frac_qp");
142  break;
143 
145  _relative_permeability = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
146  "PorousFlow_relative_permeability_qp");
147  break;
148 
150  _pressure =
151  &getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp");
152  break;
153 
155  _enthalpy = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
156  "PorousFlow_fluid_phase_enthalpy_qp");
157  break;
158 
160  _internal_energy = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
161  "PorousFlow_fluid_phase_internal_energy_qp");
162  break;
163 
165  _sec_conc = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
166  "PorousFlow_secondary_concentration_qp");
167  break;
168 
170  _mineral_conc = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
171  "PorousFlow_mineral_concentration_qp");
172  break;
173 
175  _mineral_reaction_rate = &getGenericMaterialProperty<std::vector<Real>, is_ad>(
176  "PorousFlow_mineral_reaction_rate_qp");
177  break;
178 
180  _porosity = &getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp");
181  break;
182 
184  _permeability =
185  &getGenericMaterialProperty<RealTensorValue, is_ad>("PorousFlow_permeability_qp");
186  break;
187 
189  _hys_order = &getMaterialProperty<unsigned int>("PorousFlow_hysteresis_order_qp");
190  break;
191 
193  _hys_sat_tps =
194  &getMaterialProperty<std::array<Real, PorousFlowConstants::MAX_HYSTERESIS_ORDER>>(
195  "PorousFlow_hysteresis_saturation_tps_qp");
196  break;
197 
199  _hys_info = &getMaterialProperty<Real>("PorousFlow_hysteretic_info_qp");
200  break;
201  }
202 }
203 
204 template <bool is_ad>
205 Real
207 {
208  Real property = 0.0;
209 
210  switch (_property_enum)
211  {
212  case PropertyEnum::PRESSURE:
213  property = MetaPhysicL::raw_value((*_pressure)[_qp][_phase]);
214  break;
215 
216  case PropertyEnum::SATURATION:
217  property = MetaPhysicL::raw_value((*_saturation)[_qp][_phase]);
218  break;
219 
220  case PropertyEnum::TEMPERATURE:
221  property = MetaPhysicL::raw_value((*_temperature)[_qp]);
222  break;
223 
224  case PropertyEnum::DENSITY:
225  property = MetaPhysicL::raw_value((*_fluid_density)[_qp][_phase]);
226  break;
227 
228  case PropertyEnum::VISCOSITY:
229  property = MetaPhysicL::raw_value((*_fluid_viscosity)[_qp][_phase]);
230  break;
231 
232  case PropertyEnum::MASS_FRACTION:
233  property = MetaPhysicL::raw_value((*_mass_fractions)[_qp][_phase][_fluid_component]);
234  break;
235 
236  case PropertyEnum::RELPERM:
237  property = MetaPhysicL::raw_value((*_relative_permeability)[_qp][_phase]);
238  break;
239 
240  case PropertyEnum::CAPILLARY_PRESSURE:
241  property =
242  MetaPhysicL::raw_value((*_pressure)[_qp][_gas_phase] - (*_pressure)[_qp][_liquid_phase]);
243  break;
244 
245  case PropertyEnum::ENTHALPY:
246  property = MetaPhysicL::raw_value((*_enthalpy)[_qp][_phase]);
247  break;
248 
249  case PropertyEnum::INTERNAL_ENERGY:
250  property = MetaPhysicL::raw_value((*_internal_energy)[_qp][_phase]);
251  break;
252 
253  case PropertyEnum::SECONDARY_CONCENTRATION:
254  property = MetaPhysicL::raw_value((*_sec_conc)[_qp][_secondary_species]);
255  break;
256 
257  case PropertyEnum::MINERAL_CONCENTRATION:
258  property = MetaPhysicL::raw_value((*_mineral_conc)[_qp][_mineral_species]);
259  break;
260 
261  case PropertyEnum::MINERAL_REACTION_RATE:
262  property = MetaPhysicL::raw_value((*_mineral_reaction_rate)[_qp][_mineral_species]);
263  break;
264 
265  case PropertyEnum::POROSITY:
266  property = MetaPhysicL::raw_value((*_porosity)[_qp]);
267  break;
268 
269  case PropertyEnum::PERMEABILITY:
270  property = MetaPhysicL::raw_value((*_permeability)[_qp](_k_row, _k_col));
271  break;
272 
273  case PropertyEnum::HYSTERESIS_ORDER:
274  property = (*_hys_order)[_qp];
275  break;
276 
277  case PropertyEnum::HYSTERESIS_SATURATION_TURNING_POINT:
278  property = (*_hys_sat_tps)[_qp].at(_hysteresis_turning_point);
279  break;
280 
281  case PropertyEnum::HYSTERETIC_INFO:
282  property = (*_hys_info)[_qp];
283  break;
284  }
285 
286  return property;
287 }
288 
289 template class PorousFlowPropertyAuxTempl<false>;
290 template class PorousFlowPropertyAuxTempl<true>;
const unsigned int _mineral_species
Mineral species number.
const MaterialProperty< Real > * _hys_info
Hysteresis info: what this physically represents depends on the PorousFlowHystereticInfo Material...
const GenericMaterialProperty< Real, is_ad > * _temperature
Temperature of the fluid.
const GenericMaterialProperty< std::vector< Real >, is_ad > * _internal_energy
Internal energy of each phase.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const GenericMaterialProperty< std::vector< Real >, is_ad > * _mineral_reaction_rate
Mineral-species reacion rate.
const MaterialProperty< std::array< Real, PorousFlowConstants::MAX_HYSTERESIS_ORDER > > * _hys_sat_tps
Hysteresis saturation turning points.
PorousFlowPropertyAuxTempl(const InputParameters &parameters)
unsigned int numComponents() const
The number of fluid components.
auto raw_value(const Eigen::Map< T > &in)
virtual Real computeValue() override
const GenericMaterialProperty< std::vector< std::vector< Real > >, is_ad > * _mass_fractions
Mass fraction of each component in each phase.
const MaterialProperty< unsigned int > * _hys_order
Hysteresis order.
const GenericMaterialProperty< std::vector< Real >, is_ad > * _pressure
Pressure of each phase.
void addRequiredParam(const std::string &name, const std::string &doc_string)
const unsigned int _gas_phase
Gas phase index.
constexpr unsigned MAX_HYSTERESIS_ORDER
const GenericMaterialProperty< std::vector< Real >, is_ad > * _saturation
Saturation of each phase.
const unsigned int _hysteresis_turning_point
Hysteresis turning point number.
const GenericMaterialProperty< RealTensorValue, is_ad > * _permeability
Permeability of the media.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
const unsigned int _phase
Phase index.
void paramError(const std::string &param, Args... args) const
unsigned int numPhases() const
The number of fluid phases.
const GenericMaterialProperty< std::vector< Real >, is_ad > * _relative_permeability
Relative permeability of each phase.
unsigned int numAqueousKinetic() const
The number of aqueous kinetic secondary species.
enum PorousFlowPropertyAuxTempl::PropertyEnum _property_enum
Provides a simple interface to PorousFlow material properties.
static InputParameters validParams()
const GenericMaterialProperty< std::vector< Real >, is_ad > * _enthalpy
Enthalpy of each phase.
const unsigned int _secondary_species
Secondary species number.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const GenericMaterialProperty< std::vector< Real >, is_ad > * _mineral_conc
Mineral-species concentration.
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
const GenericMaterialProperty< std::vector< Real >, is_ad > * _fluid_viscosity
Viscosity of each phase.
const GenericMaterialProperty< Real, is_ad > * _porosity
Porosity of the media.
const GenericMaterialProperty< std::vector< Real >, is_ad > * _sec_conc
Secondary-species concentration.
const unsigned int _fluid_component
Fluid component index.
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const GenericMaterialProperty< std::vector< Real >, is_ad > * _fluid_density
Fluid density of each phase.
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
registerMooseObject("PorousFlowApp", PorousFlowPropertyAux)
unsigned int numAqueousEquilibrium() const
The number of aqueous equilibrium secondary species.
const unsigned int _liquid_phase
Liquid phase index.
void ErrorVector unsigned int
PropertyEnum
Enum of properties.