www.mooseframework.org
PorousFlowUnsaturated.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 #include "FEProblem.h"
10 #include "Conversion.h"
11 #include "libmesh/string_to_enum.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<PorousFlowSinglePhaseBase>();
18  params.addParam<bool>("add_saturation_aux", true, "Add an AuxVariable that records saturation");
19  params.addRangeCheckedParam<Real>(
20  "van_genuchten_alpha",
21  1.0E-6,
22  "van_genuchten_alpha > 0.0",
23  "Van Genuchten alpha parameter used to determine saturation from porepressure");
24  params.addRangeCheckedParam<Real>(
25  "van_genuchten_m",
26  0.6,
27  "van_genuchten_m > 0 & van_genuchten_m < 1",
28  "Van Genuchten m parameter used to determine saturation from porepressure");
29  MooseEnum relperm_type_choice("FLAC Corey", "FLAC");
30  params.addParam<MooseEnum>("relative_permeability_type",
31  relperm_type_choice,
32  "Type of relative-permeability function. FLAC relperm = (1+m)S^m - "
33  "mS^(1+m). Corey relperm = S^m. m is the exponent. Here S = "
34  "(saturation - residual)/(1 - residual)");
35  params.addRangeCheckedParam<Real>("relative_permeability_exponent",
36  3.0,
37  "relative_permeability_exponent>=0",
38  "Relative permeability exponent");
39  params.addRangeCheckedParam<Real>(
40  "residual_saturation",
41  0.0,
42  "residual_saturation>=0.0 & residual_saturation<1.0",
43  "Residual saturation to use in the relative permeability expression");
44  params.addClassDescription("Adds Kernels and fluid-property Materials necessary to simulate a "
45  "single-phase saturated-unsaturated flow problem. The saturation is "
46  "computed using van Genuchten's expression. No Kernels for diffusion "
47  "and dispersion of fluid components are added. To run a simulation "
48  "you will also need to provide various other Materials for each mesh "
49  "block, depending on your simulation type, viz: permeability, "
50  "porosity, elasticity tensor, strain calculator, stress calculator, "
51  "matrix internal energy, thermal conductivity, diffusivity");
52  return params;
53 }
54 
55 PorousFlowUnsaturated::PorousFlowUnsaturated(const InputParameters & params)
56  : PorousFlowSinglePhaseBase(params),
57  _add_saturation_aux(getParam<bool>("add_saturation_aux")),
58  _van_genuchten_alpha(getParam<Real>("van_genuchten_alpha")),
59  _van_genuchten_m(getParam<Real>("van_genuchten_m")),
60  _relperm_type(
61  getParam<MooseEnum>("relative_permeability_type").getEnum<RelpermTypeChoiceEnum>()),
62  _relative_permeability_exponent(getParam<Real>("relative_permeability_exponent")),
63  _s_res(getParam<Real>("residual_saturation"))
64 {
65  _objects_to_add.push_back("PorousFlowAdvectiveFlux");
67  _objects_to_add.push_back("PorousFlowMassTimeDerivative");
71  _objects_to_add.push_back("PorousFlowMassVolumetricExpansion");
74  _objects_to_add.push_back("PorousFlowHeatAdvection");
76  _objects_to_add.push_back("SaturationAux");
77 }
78 
79 void
81 {
83 
84  // add the kernels
85  if (_current_task == "add_kernel")
86  {
87  std::string kernel_name = "PorousFlowUnsaturated_AdvectiveFlux";
88  std::string kernel_type = "PorousFlowAdvectiveFlux";
89  InputParameters params = _factory.getValidParams(kernel_type);
90  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
91  params.set<RealVectorValue>("gravity") = _gravity;
92 
93  for (unsigned i = 0; i < _num_mass_fraction_vars; ++i)
94  {
95  kernel_name = "PorousFlowUnsaturated_AdvectiveFlux" + Moose::stringify(i);
96  params.set<unsigned int>("fluid_component") = i;
97  params.set<NonlinearVariableName>("variable") = _mass_fraction_vars[i];
98  _problem->addKernel(kernel_type, kernel_name, params);
99  }
100  kernel_name = "PorousFlowUnsaturated_AdvectiveFlux" + Moose::stringify(_num_mass_fraction_vars);
101  params.set<unsigned int>("fluid_component") = _num_mass_fraction_vars;
102  params.set<NonlinearVariableName>("variable") = _pp_var;
103  _problem->addKernel(kernel_type, kernel_name, params);
104  }
105  if (_current_task == "add_kernel" && _simulation_type == SimulationTypeChoiceEnum::TRANSIENT)
106  {
107  std::string kernel_name = "PorousFlowUnsaturated_MassTimeDerivative";
108  std::string kernel_type = "PorousFlowMassTimeDerivative";
109  InputParameters params = _factory.getValidParams(kernel_type);
110  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
111 
112  for (unsigned i = 0; i < _num_mass_fraction_vars; ++i)
113  {
114  kernel_name = "PorousFlowUnsaturated_MassTimeDerivative" + Moose::stringify(i);
115  params.set<unsigned int>("fluid_component") = i;
116  params.set<NonlinearVariableName>("variable") = _mass_fraction_vars[i];
117  _problem->addKernel(kernel_type, kernel_name, params);
118  }
119  kernel_name =
120  "PorousFlowUnsaturated_MassTimeDerivative" + Moose::stringify(_num_mass_fraction_vars);
121  params.set<unsigned int>("fluid_component") = _num_mass_fraction_vars;
122  params.set<NonlinearVariableName>("variable") = _pp_var;
123  _problem->addKernel(kernel_type, kernel_name, params);
124  }
125 
128  _current_task == "add_kernel" && _simulation_type == SimulationTypeChoiceEnum::TRANSIENT)
129  {
130  std::string kernel_name = "PorousFlowUnsaturated_MassVolumetricExpansion";
131  std::string kernel_type = "PorousFlowMassVolumetricExpansion";
132  InputParameters params = _factory.getValidParams(kernel_type);
133  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
134  for (unsigned i = 0; i < _num_mass_fraction_vars; ++i)
135  {
136  kernel_name = "PorousFlowUnsaturated_MassVolumetricExpansion" + Moose::stringify(i);
137  params.set<unsigned>("fluid_component") = i;
138  params.set<NonlinearVariableName>("variable") = _mass_fraction_vars[i];
139  _problem->addKernel(kernel_type, kernel_name, params);
140  }
141  kernel_name =
142  "PorousFlowUnsaturated_MassVolumetricExpansion" + Moose::stringify(_num_mass_fraction_vars);
143  params.set<unsigned>("fluid_component") = _num_mass_fraction_vars;
144  params.set<NonlinearVariableName>("variable") = _pp_var;
145  _problem->addKernel(kernel_type, kernel_name, params);
146  }
147 
150  _current_task == "add_kernel")
151  {
152  std::string kernel_name = "PorousFlowUnsaturated_HeatAdvection";
153  std::string kernel_type = "PorousFlowHeatAdvection";
154  InputParameters params = _factory.getValidParams(kernel_type);
155  params.set<NonlinearVariableName>("variable") = _temperature_var[0];
156  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
157  params.set<RealVectorValue>("gravity") = _gravity;
158  _problem->addKernel(kernel_type, kernel_name, params);
159  }
160 
161  // Add the capillary pressure UserObject
162  std::string capillary_pressure_name = "PorousFlowUnsaturated_CapillaryPressureVG";
164 
165  if (_deps.dependsOn(_objects_to_add, "PorousFlowPS_qp") && _current_task == "add_material")
166  {
167  std::string material_type = "PorousFlow1PhaseP";
168  InputParameters params = _factory.getValidParams(material_type);
169 
170  std::string material_name = "PorousFlowUnsaturated_1PhaseP_VG_qp";
171  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
172  params.set<std::vector<VariableName>>("porepressure") = {_pp_var};
173  params.set<UserObjectName>("capillary_pressure") = capillary_pressure_name;
174  _problem->addMaterial(material_type, material_name, params);
175  }
176  if (_deps.dependsOn(_objects_to_add, "PorousFlowPS_nodal") && _current_task == "add_material")
177  {
178  std::string material_type = "PorousFlow1PhaseP";
179  InputParameters params = _factory.getValidParams(material_type);
180 
181  std::string material_name = "PorousFlowUnsaturated_1PhaseP_VG_nodal";
182  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
183  params.set<std::vector<VariableName>>("porepressure") = {_pp_var};
184  params.set<UserObjectName>("capillary_pressure") = capillary_pressure_name;
185  params.set<bool>("at_nodes") = true;
186  _problem->addMaterial(material_type, material_name, params);
187  }
188 
189  if (_deps.dependsOn(_objects_to_add, "PorousFlowRelativePermeability_qp"))
190  {
193  else
195  }
196  if (_deps.dependsOn(_objects_to_add, "PorousFlowRelativePermeability_nodal"))
197  {
200  else
202  }
203 
204  if (_deps.dependsOn(_objects_to_add, "PorousFlowVolumetricStrain_qp") ||
205  _deps.dependsOn(_objects_to_add, "PorousFlowVolumetricStrain_nodal"))
207 
208  // add relevant AuxVariables and AuxKernels
210  addSaturationAux(0);
211 }
const std::vector< VariableName > & _mass_fraction_vars
Name of the mass-fraction variables (if any)
void addSaturationAux(unsigned phase)
Add an AuxVariable and AuxKernel to calculate saturation.
void addRelativePermeabilityCorey(bool at_nodes, unsigned phase, Real n, Real s_res, Real sum_s_res)
Adds a relative-permeability Material of the Corey variety.
const Real _van_genuchten_m
Van Genuchten m parameter.
virtual void act() override
const bool _add_saturation_aux
Add an Aux Variable to record saturation.
std::vector< VariableName > _coupled_displacements
displacement Variable names
RelpermTypeChoiceEnum
Fluid relative permeability type (FLAC or Corey)
const Real _van_genuchten_alpha
Van Genuchten alpha parameter.
const Real _s_res
Residual saturation to use in the relative permeability expressions.
void addCapillaryPressureVG(Real m, Real alpha, std::string userobject_name)
Adds a van Genuchten capillary pressure UserObject.
InputParameters validParams< PorousFlowSinglePhaseBase >()
std::vector< std::string > _objects_to_add
List of Kernels, AuxKernels, Materials, etc, to be added.
Base class for actions involving a single fluid phase.
const NonlinearVariableName _pp_var
porepressure NonlinearVariable name
const RealVectorValue _gravity
gravity
const std::vector< VariableName > & _temperature_var
Name of the temperature variable (if any)
InputParameters validParams< PorousFlowUnsaturated >()
const Real _relative_permeability_exponent
Relative permeability exponent.
enum PorousFlowSinglePhaseBase::SimulationTypeChoiceEnum _simulation_type
enum PorousFlowUnsaturated::RelpermTypeChoiceEnum _relperm_type
PorousFlowUnsaturated(const InputParameters &params)
const std::string _dictator_name
The name of the PorousFlowDictator object to be added.
const unsigned _num_mass_fraction_vars
Number of mass-fraction variables.
void addRelativePermeabilityFLAC(bool at_nodes, unsigned phase, Real m, Real s_res, Real sum_s_res)
Adds a relative-permeability Material of the FLAC variety.
void addVolumetricStrainMaterial(const std::vector< VariableName > &displacements, bool consistent_with_displaced_mesh)
Adds a quadpoint volumetric strain material.
enum PorousFlowSinglePhaseBase::CouplingTypeEnum _coupling_type
DependencyResolver< std::string > _deps
All dependencies of kernels, auxkernels, materials, etc, are stored in _dependencies.