www.mooseframework.org
PorousFlowDictator.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 /****************************************************************/
7 
8 // Holds maps between PorousFlow variables (porepressure, saturations) and the variable number used
9 // by MOOSE.
10 #include "PorousFlowDictator.h"
11 #include "NonlinearSystem.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<GeneralUserObject>();
18  params.addClassDescription("Holds information on the PorousFlow variable names");
19  params.addRequiredCoupledVar("porous_flow_vars",
20  "List of primary variables that are used in the PorousFlow "
21  "simulation. Jacobian entries involving derivatives wrt these "
22  "variables will be computed. In single-phase models you will just "
23  "have one (eg \'pressure\'), in two-phase models you will have two "
24  "(eg \'p_water p_gas\', or \'p_water s_water\'), etc.");
25  params.addRequiredParam<unsigned int>("number_fluid_phases",
26  "The number of fluid phases in the simulation");
27  params.addRequiredParam<unsigned int>("number_fluid_components",
28  "The number of fluid components in the simulation");
29  return params;
30 }
31 
32 PorousFlowDictator::PorousFlowDictator(const InputParameters & parameters)
33  : GeneralUserObject(parameters),
34  Coupleable(this, false),
35  ZeroInterface(parameters),
36  _num_variables(coupledComponents("porous_flow_vars")),
37  _num_phases(getParam<unsigned int>("number_fluid_phases")),
38  _num_components(getParam<unsigned int>("number_fluid_components"))
39 {
41  for (unsigned int i = 0; i < _num_variables; ++i)
42  _moose_var_num[i] = coupled("porous_flow_vars", i);
43 
44  _pf_var_num.assign(_fe_problem.getNonlinearSystemBase().nVariables(),
45  _num_variables); // Note: the _num_variables assignment indicates that "this is
46  // not a PorousFlow variable"
47  for (unsigned int i = 0; i < _num_variables; ++i)
48  if (_moose_var_num[i] < _pf_var_num.size())
50  else
51  // should not couple AuxVariables to the Dictator (Jacobian entries are not calculated for
52  // them)
53  mooseError("PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator "
54  "for this is against specification #1984. Variable number ",
55  i,
56  " is an AuxVariable.");
57 }
58 
59 unsigned int
61 {
62  return _num_variables;
63 }
64 
65 unsigned int
67 {
68  return _num_phases;
69 }
70 
71 unsigned int
73 {
74  return _num_components;
75 }
76 
77 unsigned int
78 PorousFlowDictator::porousFlowVariableNum(unsigned int moose_var_num) const
79 {
80  if (moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables)
81  mooseError("The Dictator proclaims that the moose variable with number ",
82  moose_var_num,
83  " is not a PorousFlow variable. Exiting with error code 1984.");
84  return _pf_var_num[moose_var_num];
85 }
86 
87 bool
88 PorousFlowDictator::isPorousFlowVariable(unsigned int moose_var_num) const
89 {
90  return !notPorousFlowVariable(moose_var_num);
91 }
92 
93 bool
94 PorousFlowDictator::notPorousFlowVariable(unsigned int moose_var_num) const
95 {
96  return moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables;
97 }
98 
99 const VariableName
101 {
102  return "pressure_variable_dummy";
103 }
104 
105 const VariableName
107 {
108  return "saturation_variable_dummy";
109 }
110 
111 const VariableName
113 {
114  return "temperature_variable_dummy";
115 }
116 
117 const VariableName
119 {
120  return "mass_fraction_variable_dummy";
121 }
const VariableName pressureVariableNameDummy() const
Dummy pressure variable name for use in derivatives using the DerivativeMaterialInterface.
const unsigned int _num_components
number of fluid components
const unsigned int _num_variables
number of porousflow variables
unsigned int numComponents() const
the number of fluid components
const VariableName massFractionVariableNameDummy() const
Dummy mass fraction variable name for use in derivatives using the DerivativeMaterialInterface.
PorousFlowDictator(const InputParameters &parameters)
std::vector< unsigned int > _pf_var_num
_pf_var_num[i] = the porous flow variable corresponding to moose variable i
const VariableName temperatureVariableNameDummy() const
Dummy temperature variable name for use in derivatives using the DerivativeMaterialInterface.
const VariableName saturationVariableNameDummy() const
Dummy saturation variable name for use in derivatives using the DerivativeMaterialInterface.
unsigned int numPhases() const
the number of fluid phases
std::vector< unsigned int > _moose_var_num
_moose_var_num[i] = the moose variable number corresponding to porous flow variable i ...
bool isPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is a porous flow variable
unsigned int numVariables() const
The number of PorousFlow variables.
InputParameters validParams< PorousFlowDictator >()
bool notPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is not a porous flow variabe
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number
const unsigned int _num_phases
number of fluid phases