https://mooseframework.inl.gov
PorousFlowBasicTHM.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 
10 #include "PorousFlowBasicTHM.h"
11 
12 #include "FEProblem.h"
13 #include "Conversion.h"
14 #include "libmesh/string_to_enum.h"
15 
16 registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_user_object");
17 
18 registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_kernel");
19 
20 registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_material");
21 
22 registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_aux_variable");
23 
24 registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_aux_kernel");
25 
28 {
30  params.addParam<bool>("multiply_by_density",
31  false,
32  "If true, then the Kernels for fluid flow are multiplied by "
33  "the fluid density. If false, this multiplication is not "
34  "performed, which means the problem linearises, but that care "
35  "must be taken when using other PorousFlow objects.");
36  params.addClassDescription("Adds Kernels and fluid-property Materials necessary to simulate a "
37  "single-phase, single-component fully-saturated flow problem. No "
38  "upwinding and no mass lumping of the fluid mass are used (the "
39  "stabilization input parameter is ignored). The "
40  "fluid-mass time derivative is close to linear, and is perfectly "
41  "linear if multiply_by_density=false. These features mean the "
42  "results may differ slightly from the "
43  "Unsaturated Action case. To run a simulation "
44  "you will also need to provide various other Materials for each mesh "
45  "block, depending on your simulation type, viz: permeability, "
46  "constant Biot modulus, constant thermal expansion coefficient, "
47  "porosity, elasticity tensor, strain calculator, stress calculator, "
48  "matrix internal energy, thermal conductivity, diffusivity");
49  return params;
50 }
51 
53  : PorousFlowSinglePhaseBase(params), _multiply_by_density(getParam<bool>("multiply_by_density"))
54 {
55  if (_num_mass_fraction_vars != 0)
56  mooseError("PorousFlowBasicTHM can only be used for a single-component fluid, so that no "
57  "mass-fraction variables should be provided");
58 }
59 
60 void
62 {
64 
65  // Add necessary objects to list of PorousFlow objects added by this action
66  _included_objects.push_back("PorousFlowFullySaturatedDarcyBase");
67 
68  if (_transient)
69  _included_objects.push_back("PorousFlowFullySaturatedMassTimeDerivative");
70 
71  if (_thermal)
72  _included_objects.push_back("PorousFlowFullySaturatedHeatAdvection");
73 }
74 
75 void
77 {
79 
80  std::string kernel_name = "PorousFlowBasicTHM_DarcyFlow";
81  std::string kernel_type = "PorousFlowFullySaturatedDarcyBase";
82  InputParameters params = _factory.getValidParams(kernel_type);
84  params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
85  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
86  params.set<RealVectorValue>("gravity") = _gravity;
87  params.set<bool>("multiply_by_density") = _multiply_by_density;
88  params.set<NonlinearVariableName>("variable") = _pp_var;
89  _problem->addKernel(kernel_type, kernel_name, params);
90 
91  if (_transient)
92  {
93  std::string kernel_name = "PorousFlowBasicTHM_MassTimeDerivative";
94  std::string kernel_type = "PorousFlowFullySaturatedMassTimeDerivative";
95  InputParameters params = _factory.getValidParams(kernel_type);
97  params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
98  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
99  params.set<NonlinearVariableName>("variable") = _pp_var;
100  params.set<Real>("biot_coefficient") = _biot_coefficient;
101  params.set<bool>("multiply_by_density") = _multiply_by_density;
102  params.set<MooseEnum>("coupling_type") = parameters().get<MooseEnum>("coupling_type");
103  if (_save_component_rate_in.size() != 0)
104  params.set<std::vector<AuxVariableName>>("save_in") = _save_component_rate_in;
105  params.set<NonlinearVariableName>("variable") = _pp_var;
106  _problem->addKernel(kernel_type, kernel_name, params);
107  }
108 
109  if (_thermal)
110  {
111  std::string kernel_name = "PorousFlowBasicTHM_HeatAdvection";
112  std::string kernel_type = "PorousFlowFullySaturatedHeatAdvection";
113  InputParameters params = _factory.getValidParams(kernel_type);
115  params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
116  params.set<NonlinearVariableName>("variable") = _temperature_var[0];
117  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
118  params.set<RealVectorValue>("gravity") = _gravity;
119  _problem->addKernel(kernel_type, kernel_name, params);
120  }
121 }
122 
123 void
125 {
127 
128  if (_deps.dependsOn(_included_objects, "pressure_saturation_qp"))
129  {
130  std::string material_type = "PorousFlow1PhaseFullySaturated";
131  std::string material_name = "PorousFlowBasicTHM_1PhaseP_qp";
132  InputParameters params = _factory.getValidParams(material_type);
134  params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
135  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
136  params.set<std::vector<VariableName>>("porepressure") = {_pp_var};
137  params.set<bool>("at_nodes") = false;
138  _problem->addMaterial(material_type, material_name, params);
139  }
140 
141  if (_deps.dependsOn(_included_objects, "pressure_saturation_nodal"))
142  {
143  std::string material_type = "PorousFlow1PhaseFullySaturated";
144  std::string material_name = "PorousFlowBasicTHM_1PhaseP";
145  InputParameters params = _factory.getValidParams(material_type);
147  params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
148  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
149  params.set<std::vector<VariableName>>("porepressure") = {_pp_var};
150  params.set<bool>("at_nodes") = true;
151  _problem->addMaterial(material_type, material_name, params);
152  }
153 
154  if ((_deps.dependsOn(_included_objects, "volumetric_strain_qp") ||
155  _deps.dependsOn(_included_objects, "volumetric_strain_nodal")) &&
156  _mechanical)
158 
159  // Relative permeability might be needed by Darcy-velocity Aux, so add a material
160  // setting kr=1
161  if (_deps.dependsOn(_included_objects, "relative_permeability_qp"))
162  addRelativePermeabilityConst(false, 0, 1.0);
163 
164  // Some obects not added by this action might have a use_mobility = true param,
165  // which needs a nodal relative permeability
166  if (_deps.dependsOn(_included_objects, "relative_permeability_nodal"))
167  addRelativePermeabilityConst(true, 0, 1.0);
168 }
static InputParameters validParams()
Action for simulation involving a single phase, single component, fully saturated fluid...
virtual void addKernels() override
Add all Kernels.
virtual void addMaterials() override
Add all Materials.
const bool _subdomain_names_set
indicates, if the vector of subdomain names is set (dont set block restrictions, if not) ...
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Real _biot_coefficient
Fluid specific heat capacity at constant volume.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
virtual void addMaterialDependencies() override
Add all material dependencies so that the correct version of each material can be added...
registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_user_object")
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
bool dependsOn(const std::string &key, const std::string &value)
void addRelativePermeabilityConst(bool at_nodes, unsigned phase, Real kr)
Adds a relative-permeability Material of the constant variety (primarily to add kr = 1 in actions tha...
const VariableName _pp_var
Porepressure NonlinearVariable name.
std::vector< VariableName > _coupled_displacements
Displacement Variable names.
std::vector< std::string > _included_objects
List of Kernels, AuxKernels, Materials, etc, that are added in this input file.
const std::vector< AuxVariableName > _save_component_rate_in
Name of the variables (if any) that will record the fluid-components&#39; rate of change.
const bool _thermal
Flags to indicate whether thermal or mechanical effects are included.
Factory & _factory
std::vector< SubdomainName > _subdomain_names
if this vector is not empty the variables, kernels and materials are restricted to these subdomains ...
virtual void addMaterials() override
Add all Materials.
const bool _multiply_by_density
Base class for actions involving a single fluid phase.
virtual void addKernels() override
Add all Kernels.
static InputParameters validParams()
const RealVectorValue _gravity
Gravity.
PorousFlowBasicTHM(const InputParameters &params)
const std::vector< VariableName > _temperature_var
Name of the temperature variable (if any)
bool _transient
Flag to denote if the simulation is transient.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void addMaterialDependencies() override
Add all material dependencies so that the correct version of each material can be added...
const std::string _dictator_name
The name of the PorousFlowDictator object to be added.
void addVolumetricStrainMaterial(const std::vector< VariableName > &displacements, const std::string &base_name)
Adds a quadpoint volumetric strain material.
const unsigned _num_mass_fraction_vars
Number of mass-fraction variables.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const
const std::string _base_name
base_name used in the TensorMechanics strain calculator
DependencyResolver< std::string > _deps
All dependencies of kernels, auxkernels, materials, etc, are stored in _dependencies.