www.mooseframework.org
PorousFlowSinglePhaseBase.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 
11 
12 #include "FEProblem.h"
13 #include "Conversion.h"
14 #include "libmesh/string_to_enum.h"
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<PorousFlowActionBase>();
21  params.addParam<bool>("add_darcy_aux", true, "Add AuxVariables that record Darcy velocity");
22  params.addParam<bool>("add_stress_aux", true, "Add AuxVariables that record effective stress");
23  params.addParam<bool>("use_brine", false, "Use PorousFlowBrine material for the fluid phase");
24  params.addRequiredParam<VariableName>("porepressure", "The name of the porepressure variable");
25  MooseEnum coupling_type("Hydro ThermoHydro HydroMechanical ThermoHydroMechanical", "Hydro");
26  params.addParam<MooseEnum>("coupling_type",
27  coupling_type,
28  "The type of simulation. For simulations involving Mechanical "
29  "deformations, you will need to supply the correct Biot coefficient. "
30  "For simulations involving Thermal flows, you will need an associated "
31  "ConstantThermalExpansionCoefficient Material");
32  MooseEnum simulation_type_choice("steady transient", "transient");
33  params.addDeprecatedParam<MooseEnum>(
34  "simulation_type",
35  simulation_type_choice,
36  "Whether a transient or steady-state simulation is being performed",
37  "The execution type is now determined automatically. This parameter should no longer be "
38  "used");
39  params.addParam<UserObjectName>("fp",
40  "use_brine_material",
41  "The name of the user object for fluid "
42  "properties. Not required if use_brine is true.");
43  params.addCoupledVar("mass_fraction_vars",
44  "List of variables that represent the mass fractions. With only one fluid "
45  "component, this may be left empty. With N fluid components, the format is "
46  "'f_0 f_1 f_2 ... f_(N-1)'. That is, the N^th component need not be "
47  "specified because f_N = 1 - (f_0 + f_1 + ... + f_(N-1)). It is best "
48  "numerically to choose the N-1 mass fraction variables so that they "
49  "represent the fluid components with small concentrations. This Action "
50  "will associated the i^th mass fraction variable to the equation for the "
51  "i^th fluid component, and the pressure variable to the N^th fluid "
52  "component.");
53  params.addParam<unsigned>("nacl_index",
54  0,
55  "Index of NaCl variable in mass_fraction_vars, for "
56  "calculating brine properties. Only required if use_brine is true.");
57  params.addParam<Real>(
58  "biot_coefficient",
59  1.0,
60  "The Biot coefficient (relevant only for mechanically-coupled simulations)");
61  params.addClassDescription("Base class for single-phase simulations");
62  return params;
63 }
64 
66  : PorousFlowActionBase(params),
67  _pp_var(getParam<VariableName>("porepressure")),
68  _coupling_type(getParam<MooseEnum>("coupling_type").getEnum<CouplingTypeEnum>()),
69  _thermal(_coupling_type == CouplingTypeEnum::ThermoHydro ||
70  _coupling_type == CouplingTypeEnum::ThermoHydroMechanical),
71  _mechanical(_coupling_type == CouplingTypeEnum::HydroMechanical ||
72  _coupling_type == CouplingTypeEnum::ThermoHydroMechanical),
73  _fp(getParam<UserObjectName>("fp")),
74  _biot_coefficient(getParam<Real>("biot_coefficient")),
75  _add_darcy_aux(getParam<bool>("add_darcy_aux")),
76  _add_stress_aux(getParam<bool>("add_stress_aux")),
77  _use_brine(getParam<bool>("use_brine")),
78  _nacl_index(getParam<unsigned>("nacl_index"))
79 {
80  if (_thermal && _temperature_var.size() != 1)
81  mooseError("PorousFlowSinglePhaseBase: You need to specify a temperature variable to perform "
82  "non-isothermal simulations");
83 
84  if (_use_brine && !params.isParamValid("mass_fraction_vars"))
85  mooseError("PorousFlowSinglePhaseBase: You need to specify at least one component in "
86  "mass_fraction_vars if use_brine is true");
87 
89  mooseError(
90  "PorousFlowSinglePhaseBase: nacl_index must be less than length of mass_fraction_vars");
91 
92  if (!_use_brine && _fp == "use_brine_material")
93  mooseError("PorousFlowSinglePhaseBase: You need to specify fp if use_brine is false");
94 }
95 
96 void
98 {
100 
101  // Add necessary objects to list of PorousFlow objects added by this action
102  if (_mechanical)
103  {
104  _included_objects.push_back("StressDivergenceTensors");
105  _included_objects.push_back("Gravity");
106  _included_objects.push_back("PorousFlowEffectiveStressCoupling");
107  }
108 
109  if (_thermal)
110  {
111  _included_objects.push_back("PorousFlowHeatConduction");
112  if (_transient)
113  _included_objects.push_back("PorousFlowEnergyTimeDerivative");
114  }
115 
116  if (_thermal && _mechanical && _transient)
117  _included_objects.push_back("PorousFlowHeatVolumetricExpansion");
118 
119  if (_add_darcy_aux)
120  _included_objects.push_back("PorousFlowDarcyVelocityComponent");
121 
123  _included_objects.push_back("StressAux");
124 }
125 
126 void
128 {
130 
131  if (_mechanical)
132  {
133  for (unsigned i = 0; i < _ndisp; ++i)
134  {
135  std::string kernel_name = "PorousFlowUnsaturated_grad_stress" + Moose::stringify(i);
136  std::string kernel_type = "StressDivergenceTensors";
137  if (_coord_system == Moose::COORD_RZ)
138  kernel_type = "StressDivergenceRZTensors";
139  InputParameters params = _factory.getValidParams(kernel_type);
140  params.set<NonlinearVariableName>("variable") = _displacements[i];
141  params.set<std::vector<VariableName>>("displacements") = _coupled_displacements;
142  if (_thermal)
143  {
144  params.set<std::vector<VariableName>>("temperature") = _temperature_var;
145  params.set<std::string>("thermal_eigenstrain_name") =
146  getParam<std::string>("thermal_eigenstrain_name");
147  }
148  params.set<unsigned>("component") = i;
149  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
150  _problem->addKernel(kernel_type, kernel_name, params);
151 
152  if (_gravity(i) != 0)
153  {
154  kernel_name = "PorousFlowUnsaturated_gravity" + Moose::stringify(i);
155  kernel_type = "Gravity";
156  params = _factory.getValidParams(kernel_type);
157  params.set<NonlinearVariableName>("variable") = _displacements[i];
158  params.set<Real>("value") = _gravity(i);
159  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
160  _problem->addKernel(kernel_type, kernel_name, params);
161  }
162 
163  kernel_name = "PorousFlowUnsaturated_EffStressCoupling" + Moose::stringify(i);
164  kernel_type = "PorousFlowEffectiveStressCoupling";
165  params = _factory.getValidParams(kernel_type);
166  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
167  params.set<NonlinearVariableName>("variable") = _displacements[i];
168  params.set<Real>("biot_coefficient") = _biot_coefficient;
169  params.set<unsigned>("component") = i;
170  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
171  _problem->addKernel(kernel_type, kernel_name, params);
172  }
173  }
174 
175  if (_thermal)
176  {
177  std::string kernel_name = "PorousFlowUnsaturated_HeatConduction";
178  std::string kernel_type = "PorousFlowHeatConduction";
179  InputParameters params = _factory.getValidParams(kernel_type);
180  params.set<NonlinearVariableName>("variable") = _temperature_var[0];
181  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
182  _problem->addKernel(kernel_type, kernel_name, params);
183 
184  if (_transient)
185  {
186  kernel_name = "PorousFlowUnsaturated_EnergyTimeDerivative";
187  kernel_type = "PorousFlowEnergyTimeDerivative";
188  params = _factory.getValidParams(kernel_type);
189  params.set<NonlinearVariableName>("variable") = _temperature_var[0];
190  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
191  _problem->addKernel(kernel_type, kernel_name, params);
192  }
193  }
194 
195  if (_thermal && _mechanical && _transient)
196  {
197  std::string kernel_name = "PorousFlowUnsaturated_HeatVolumetricExpansion";
198  std::string kernel_type = "PorousFlowHeatVolumetricExpansion";
199  InputParameters params = _factory.getValidParams(kernel_type);
200  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
201  params.set<NonlinearVariableName>("variable") = _temperature_var[0];
202  _problem->addKernel(kernel_type, kernel_name, params);
203  }
204 }
205 
206 void
208 {
210 
211  if (_add_darcy_aux)
213 
215  addStressAux();
216 }
217 
218 void
220 {
222 
223  // add Materials
224  if (_deps.dependsOn(_included_objects, "temperature_qp"))
225  addTemperatureMaterial(false);
226 
227  if (_deps.dependsOn(_included_objects, "temperature_nodal"))
229 
230  if (_deps.dependsOn(_included_objects, "mass_fraction_qp"))
232 
233  if (_deps.dependsOn(_included_objects, "mass_fraction_nodal"))
235 
236  const bool compute_rho_mu_qp = _deps.dependsOn(_included_objects, "density_qp") ||
237  _deps.dependsOn(_included_objects, "viscosity_qp");
238  const bool compute_e_qp = _deps.dependsOn(_included_objects, "internal_energy_qp");
239  const bool compute_h_qp = _deps.dependsOn(_included_objects, "enthalpy_qp");
240 
241  if (compute_rho_mu_qp || compute_e_qp || compute_h_qp)
242  {
243  if (_use_brine)
244  {
245  const std::string nacl_name = _mass_fraction_vars[_nacl_index];
246  addBrineMaterial(nacl_name, false, 0, compute_rho_mu_qp, compute_e_qp, compute_h_qp);
247  }
248  else
249  addSingleComponentFluidMaterial(false, 0, compute_rho_mu_qp, compute_e_qp, compute_h_qp, _fp);
250  }
251 
252  const bool compute_rho_mu_nodal = _deps.dependsOn(_included_objects, "density_nodal") ||
253  _deps.dependsOn(_included_objects, "viscosity_nodal");
254  const bool compute_e_nodal = _deps.dependsOn(_included_objects, "internal_energy_nodal");
255  const bool compute_h_nodal = _deps.dependsOn(_included_objects, "enthalpy_nodal");
256 
257  if (compute_rho_mu_nodal || compute_e_nodal || compute_h_nodal)
258  {
259  if (_use_brine)
260  {
261  const std::string nacl_name = _mass_fraction_vars[_nacl_index];
262  addBrineMaterial(nacl_name, true, 0, compute_rho_mu_nodal, compute_e_nodal, compute_h_nodal);
263  }
264  else
266  true, 0, compute_rho_mu_nodal, compute_e_nodal, compute_h_nodal, _fp);
267  }
268 
269  if (_deps.dependsOn(_included_objects, "effective_pressure_qp"))
271 
272  if (_deps.dependsOn(_included_objects, "effective_pressure_nodal"))
274 }
275 
276 void
278 {
279  const std::string uo_name = _dictator_name;
280  const std::string uo_type = "PorousFlowDictator";
281  InputParameters params = _factory.getValidParams(uo_type);
282  std::vector<VariableName> pf_vars = _mass_fraction_vars;
283  pf_vars.push_back(_pp_var);
284  if (_thermal)
285  pf_vars.push_back(_temperature_var[0]);
286  if (_mechanical)
287  pf_vars.insert(pf_vars.end(), _coupled_displacements.begin(), _coupled_displacements.end());
288  params.set<std::vector<VariableName>>("porous_flow_vars") = pf_vars;
289  params.set<unsigned int>("number_fluid_phases") = 1;
290  params.set<unsigned int>("number_fluid_components") = _num_mass_fraction_vars + 1;
291  params.set<unsigned int>("number_aqueous_equilibrium") = _num_aqueous_equilibrium;
292  params.set<unsigned int>("number_aqueous_kinetic") = _num_aqueous_kinetic;
293  _problem->addUserObject(uo_type, uo_name, params);
294 }
PorousFlowActionBase::_num_mass_fraction_vars
const unsigned _num_mass_fraction_vars
Number of mass-fraction variables.
Definition: PorousFlowActionBase.h:69
PorousFlowActionBase::_coord_system
Moose::CoordinateSystemType _coord_system
Coordinate system of the simulation (eg RZ, XYZ, etc)
Definition: PorousFlowActionBase.h:89
PorousFlowActionBase::addAuxObjects
virtual void addAuxObjects()
Add all AuxVariables and AuxKernels.
Definition: PorousFlowActionBase.C:180
PorousFlowActionBase::_transient
bool _transient
Flag to denote if the simulation is transient.
Definition: PorousFlowActionBase.h:92
PorousFlowActionBase::addMaterials
virtual void addMaterials()
Add all Materials.
Definition: PorousFlowActionBase.C:190
PorousFlowActionBase::addStressAux
void addStressAux()
Add AuxVariables and AuxKernels to compute effective stress.
Definition: PorousFlowActionBase.C:258
PorousFlowActionBase::_displacements
const std::vector< VariableName > & _displacements
Displacement NonlinearVariable names (if any)
Definition: PorousFlowActionBase.h:75
PorousFlowSinglePhaseBase::_nacl_index
const unsigned _nacl_index
Index of NaCl in list of fluid components.
Definition: PorousFlowSinglePhaseBase.h:65
PorousFlowSinglePhaseBase::_mechanical
const bool _mechanical
Definition: PorousFlowSinglePhaseBase.h:47
PorousFlowSinglePhaseBase::addAuxObjects
virtual void addAuxObjects() override
Add all AuxVariables and AuxKernels.
Definition: PorousFlowSinglePhaseBase.C:207
PorousFlowSinglePhaseBase::PorousFlowSinglePhaseBase
PorousFlowSinglePhaseBase(const InputParameters &params)
Definition: PorousFlowSinglePhaseBase.C:65
PorousFlowSinglePhaseBase::CouplingTypeEnum
CouplingTypeEnum
Determines the coupling type.
Definition: PorousFlowSinglePhaseBase.h:38
PorousFlowSinglePhaseBase::_biot_coefficient
const Real _biot_coefficient
Fluid specific heat capacity at constant volume.
Definition: PorousFlowSinglePhaseBase.h:53
PorousFlowSinglePhaseBase::_add_stress_aux
const bool _add_stress_aux
Add AuxVariables for stress.
Definition: PorousFlowSinglePhaseBase.h:59
PorousFlowSinglePhaseBase::_use_brine
const bool _use_brine
Use PorousFlowBrine material.
Definition: PorousFlowSinglePhaseBase.h:62
PorousFlowActionBase::addKernels
virtual void addKernels()
Add all Kernels.
Definition: PorousFlowActionBase.C:185
PorousFlowSinglePhaseBase::_pp_var
const VariableName _pp_var
Porepressure NonlinearVariable name.
Definition: PorousFlowSinglePhaseBase.h:35
validParams< PorousFlowSinglePhaseBase >
InputParameters validParams< PorousFlowSinglePhaseBase >()
Definition: PorousFlowSinglePhaseBase.C:18
PorousFlowActionBase::_coupled_displacements
std::vector< VariableName > _coupled_displacements
Displacement Variable names.
Definition: PorousFlowActionBase.h:81
validParams< PorousFlowActionBase >
InputParameters validParams< PorousFlowActionBase >()
Definition: PorousFlowActionBase.C:22
PorousFlowActionBase::_mass_fraction_vars
const std::vector< VariableName > & _mass_fraction_vars
Name of the mass-fraction variables (if any)
Definition: PorousFlowActionBase.h:66
PorousFlowDependencies::_deps
DependencyResolver< std::string > _deps
All dependencies of kernels, auxkernels, materials, etc, are stored in _dependencies.
Definition: PorousFlowDependencies.h:37
PorousFlowSinglePhaseBase::_fp
const UserObjectName & _fp
Name of the fluid-properties UserObject.
Definition: PorousFlowSinglePhaseBase.h:50
PorousFlowSinglePhaseBase.h
PorousFlowSinglePhaseBase::addKernels
virtual void addKernels() override
Add all Kernels.
Definition: PorousFlowSinglePhaseBase.C:127
PorousFlowActionBase::_ndisp
const unsigned _ndisp
Number of displacement variables supplied.
Definition: PorousFlowActionBase.h:78
PorousFlowActionBase::addDarcyAux
void addDarcyAux(const RealVectorValue &gravity)
Add AuxVariables and AuxKernels to calculate Darcy velocity.
Definition: PorousFlowActionBase.C:220
PorousFlowActionBase::addTemperatureMaterial
void addTemperatureMaterial(bool at_nodes)
Adds a nodal and a quadpoint Temperature material.
Definition: PorousFlowActionBase.C:339
PorousFlowActionBase::_gravity
const RealVectorValue _gravity
Gravity.
Definition: PorousFlowActionBase.h:63
PorousFlowActionBase::_num_aqueous_kinetic
const unsigned int _num_aqueous_kinetic
Number of aqeuous-kinetic secondary species that are involved in mineralisation.
Definition: PorousFlowActionBase.h:60
PorousFlowActionBase::_num_aqueous_equilibrium
const unsigned int _num_aqueous_equilibrium
Number of aqueous-equilibrium secondary species.
Definition: PorousFlowActionBase.h:57
PorousFlowActionBase::addSingleComponentFluidMaterial
void addSingleComponentFluidMaterial(bool at_nodes, unsigned phase, bool compute_density_and_viscosity, bool compute_internal_energy, bool compute_enthalpy, const UserObjectName &fp)
Adds a single-component fluid Material.
Definition: PorousFlowActionBase.C:424
PorousFlowSinglePhaseBase::addMaterialDependencies
virtual void addMaterialDependencies() override
Add all material dependencies so that the correct version of each material can be added.
Definition: PorousFlowSinglePhaseBase.C:97
PorousFlowActionBase::_temperature_var
const std::vector< VariableName > & _temperature_var
Name of the temperature variable (if any)
Definition: PorousFlowActionBase.h:72
PorousFlowActionBase::addMassFractionMaterial
void addMassFractionMaterial(bool at_nodes)
Adds a nodal and a quadpoint MassFraction material.
Definition: PorousFlowActionBase.C:363
PorousFlowSinglePhaseBase::addMaterials
virtual void addMaterials() override
Add all Materials.
Definition: PorousFlowSinglePhaseBase.C:219
PorousFlowSinglePhaseBase::addDictator
virtual void addDictator() override
Add the PorousFlowDictator object.
Definition: PorousFlowSinglePhaseBase.C:277
PorousFlowActionBase::_dictator_name
const std::string _dictator_name
The name of the PorousFlowDictator object to be added.
Definition: PorousFlowActionBase.h:54
PorousFlowSinglePhaseBase::_thermal
const bool _thermal
Flags to indicate whether thermal or mechanical effects are included.
Definition: PorousFlowSinglePhaseBase.h:46
PorousFlowActionBase::addBrineMaterial
void addBrineMaterial(const VariableName xnacl, bool at_nodes, unsigned phase, bool compute_density_and_viscosity, bool compute_internal_energy, bool compute_enthalpy)
Adds a brine fluid Material.
Definition: PorousFlowActionBase.C:453
PorousFlowSinglePhaseBase::_add_darcy_aux
const bool _add_darcy_aux
Add a AuxVariables to record Darcy velocity.
Definition: PorousFlowSinglePhaseBase.h:56
PorousFlowActionBase::_included_objects
std::vector< std::string > _included_objects
List of Kernels, AuxKernels, Materials, etc, that are added in this input file.
Definition: PorousFlowActionBase.h:51
PorousFlowActionBase
Base class for PorousFlow actions.
Definition: PorousFlowActionBase.h:35
PorousFlowActionBase::addEffectiveFluidPressureMaterial
void addEffectiveFluidPressureMaterial(bool at_nodes)
Adds a nodal and a quadpoint effective fluid pressure material.
Definition: PorousFlowActionBase.C:388
PorousFlowActionBase::addMaterialDependencies
virtual void addMaterialDependencies()
Add all material dependencies so that the correct version of each material can be added.
Definition: PorousFlowActionBase.C:152