www.mooseframework.org
PorousFlowDictator.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 // Holds maps between PorousFlow variables (porepressure, saturations) and the variable number used
11 // by MOOSE.
12 #include "PorousFlowDictator.h"
13 #include "NonlinearSystem.h"
14 
15 registerMooseObject("PorousFlowApp", PorousFlowDictator);
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<GeneralUserObject>();
22  params.addClassDescription("Holds information on the PorousFlow variable names");
23  params.addRequiredCoupledVar("porous_flow_vars",
24  "List of primary variables that are used in the PorousFlow "
25  "simulation. Jacobian entries involving derivatives wrt these "
26  "variables will be computed. In single-phase models you will just "
27  "have one (eg \'pressure\'), in two-phase models you will have two "
28  "(eg \'p_water p_gas\', or \'p_water s_water\'), etc.");
29  params.addRequiredParam<unsigned int>("number_fluid_phases",
30  "The number of fluid phases in the simulation");
31  params.addRequiredParam<unsigned int>("number_fluid_components",
32  "The number of fluid components in the simulation");
33  params.addParam<unsigned int>("number_aqueous_equilibrium",
34  0,
35  "The number of secondary species in the aqueous-equilibrium "
36  "reaction system. (Leave as zero if the simulation does not "
37  "involve chemistry)");
38  params.addParam<unsigned int>("number_aqueous_kinetic",
39  0,
40  "The number of secondary species in the aqueous-kinetic reaction "
41  "system involved in precipitation and dissolution. (Leave as zero "
42  "if the simulation does not involve chemistry)");
43  params.addParam<unsigned int>("aqueous_phase_number",
44  0,
45  "The fluid phase number of the aqueous phase in which the "
46  "equilibrium and kinetic chemical reactions occur");
47  return params;
48 }
49 
50 PorousFlowDictator::PorousFlowDictator(const InputParameters & parameters)
51  : GeneralUserObject(parameters),
52  Coupleable(this, false),
53  _num_variables(coupledComponents("porous_flow_vars")),
54  _num_phases(getParam<unsigned int>("number_fluid_phases")),
55  _num_components(getParam<unsigned int>("number_fluid_components")),
56  _num_aqueous_equilibrium(getParam<unsigned int>("number_aqueous_equilibrium")),
57  _num_aqueous_kinetic(getParam<unsigned int>("number_aqueous_kinetic")),
58  _aqueous_phase_number(getParam<unsigned int>("aqueous_phase_number")),
59  _consistent_fe_type(false),
60  _fe_type(0)
61 {
63  for (unsigned int i = 0; i < _num_variables; ++i)
64  _moose_var_num[i] = coupled("porous_flow_vars", i);
65 
66  if (_num_variables > 0)
67  {
68  _consistent_fe_type = true;
69  _fe_type = FEType(getVar("porous_flow_vars", 0)->feType());
70  for (unsigned int i = 1; i < _num_variables; ++i)
71  if (getVar("porous_flow_vars", i)->feType() != _fe_type)
72  _consistent_fe_type = false;
73  }
74 
75  _pf_var_num.assign(_fe_problem.getNonlinearSystemBase().nVariables(),
76  _num_variables); // Note: the _num_variables assignment indicates that "this is
77  // not a PorousFlow variable"
78  for (unsigned int i = 0; i < _num_variables; ++i)
79  if (_moose_var_num[i] < _pf_var_num.size())
81  else
82  // should not couple AuxVariables to the Dictator (Jacobian entries are not calculated for
83  // them)
84  mooseError("PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator "
85  "for this is against specification #1984. Variable number ",
86  i,
87  " is an AuxVariable.");
88 
90  mooseError("PorousflowDictator: The aqueous phase number must be less than the number of fluid "
91  "phases. The Dictator does not appreciate jokes.");
92 
93  // Don't include permeabiity derivatives in the Jacobian by default (overwrite using
94  // usePermDerivs()) when necessary in permeabiity material classes
95  _perm_derivs = false;
96 }
97 
98 unsigned int
100 {
101  return _num_variables;
102 }
103 
104 unsigned int
106 {
107  return _num_phases;
108 }
109 
110 unsigned int
112 {
113  return _num_components;
114 }
115 
116 unsigned int
118 {
120 }
121 
122 unsigned int
124 {
125  return _num_aqueous_kinetic;
126 }
127 
128 unsigned int
130 {
131  return _aqueous_phase_number;
132 }
133 
134 unsigned int
135 PorousFlowDictator::porousFlowVariableNum(unsigned int moose_var_num) const
136 {
137  if (moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables)
138  mooseError("The Dictator proclaims that the moose variable with number ",
139  moose_var_num,
140  " is not a PorousFlow variable. Exiting with error code 1984.");
141  return _pf_var_num[moose_var_num];
142 }
143 
144 unsigned int
145 PorousFlowDictator::mooseVariableNum(unsigned int porous_flow_var_num) const
146 {
147  if (porous_flow_var_num >= _num_variables)
148  mooseError("The Dictator proclaims that there is no such PorousFlow variable with number ",
149  porous_flow_var_num,
150  ". Exiting with error code 1984.");
151  return _moose_var_num[porous_flow_var_num];
152 }
153 
154 bool
155 PorousFlowDictator::isPorousFlowVariable(unsigned int moose_var_num) const
156 {
157  return !notPorousFlowVariable(moose_var_num);
158 }
159 
160 bool
161 PorousFlowDictator::notPorousFlowVariable(unsigned int moose_var_num) const
162 {
163  return moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables;
164 }
165 
166 bool
168 {
169  return _consistent_fe_type;
170 }
171 
172 FEType
174 {
175  return _fe_type;
176 }
PorousFlowDictator::mooseVariableNum
unsigned int mooseVariableNum(unsigned int porous_flow_var_num) const
The Moose variable number.
Definition: PorousFlowDictator.C:145
PorousFlowDictator.h
PorousFlowDictator::_pf_var_num
std::vector< unsigned int > _pf_var_num
_pf_var_num[i] = the porous flow variable corresponding to moose variable i
Definition: PorousFlowDictator.h:196
PorousFlowDictator::numAqueousKinetic
unsigned int numAqueousKinetic() const
The number of aqueous kinetic secondary species.
Definition: PorousFlowDictator.C:123
PorousFlowDictator::_num_phases
const unsigned int _num_phases
Number of fluid phases.
Definition: PorousFlowDictator.h:168
PorousFlowDictator::_num_aqueous_equilibrium
const unsigned int _num_aqueous_equilibrium
Number of aqueous-equilibrium secondary species.
Definition: PorousFlowDictator.h:174
PorousFlowDictator::_num_aqueous_kinetic
const unsigned int _num_aqueous_kinetic
Number of aqeuous-kinetic secondary species that are involved in mineralisation.
Definition: PorousFlowDictator.h:177
validParams< PorousFlowDictator >
InputParameters validParams< PorousFlowDictator >()
Definition: PorousFlowDictator.C:19
PorousFlowDictator::isPorousFlowVariable
bool isPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is a porous flow variable.
Definition: PorousFlowDictator.C:155
PorousFlowDictator::notPorousFlowVariable
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
Definition: PorousFlowDictator.C:161
PorousFlowDictator::_num_variables
const unsigned int _num_variables
Number of PorousFlow variables.
Definition: PorousFlowDictator.h:161
PorousFlowDictator::_fe_type
FEType _fe_type
FE type used by the PorousFlow variables.
Definition: PorousFlowDictator.h:190
PorousFlowDictator::numAqueousEquilibrium
unsigned int numAqueousEquilibrium() const
The number of aqueous equilibrium secondary species.
Definition: PorousFlowDictator.C:117
PorousFlowDictator::_moose_var_num
std::vector< unsigned int > _moose_var_num
_moose_var_num[i] = the moose variable number corresponding to porous flow variable i
Definition: PorousFlowDictator.h:193
PorousFlowDictator::porousFlowVariableNum
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
Definition: PorousFlowDictator.C:135
PorousFlowDictator
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
Definition: PorousFlowDictator.h:71
PorousFlowDictator::numPhases
unsigned int numPhases() const
The number of fluid phases.
Definition: PorousFlowDictator.C:105
PorousFlowDictator::feType
FEType feType() const
The FEType of the first porous_flow_variable.
Definition: PorousFlowDictator.C:173
PorousFlowDictator::_consistent_fe_type
bool _consistent_fe_type
Whether the porous_flow_vars all have the same fe_type.
Definition: PorousFlowDictator.h:187
PorousFlowDictator::numVariables
unsigned int numVariables() const
The number of PorousFlow variables.
Definition: PorousFlowDictator.C:99
PorousFlowDictator::_aqueous_phase_number
const unsigned int _aqueous_phase_number
Aqueous phase number.
Definition: PorousFlowDictator.h:180
PorousFlowDictator::_num_components
const unsigned int _num_components
Number of fluid components.
Definition: PorousFlowDictator.h:171
PorousFlowDictator::numComponents
unsigned int numComponents() const
The number of fluid components.
Definition: PorousFlowDictator.C:111
PorousFlowDictator::PorousFlowDictator
PorousFlowDictator(const InputParameters &parameters)
Definition: PorousFlowDictator.C:50
PorousFlowDictator::aqueousPhaseNumber
unsigned int aqueousPhaseNumber() const
The aqueous phase number.
Definition: PorousFlowDictator.C:129
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlowDictator)
PorousFlowDictator::_perm_derivs
bool _perm_derivs
Indicates whether the simulation includes derivatives of permeability.
Definition: PorousFlowDictator.h:183
PorousFlowDictator::consistentFEType
bool consistentFEType() const
Whether the porous_flow_vars all have the same FEType or if no porous_flow_vars were provided.
Definition: PorousFlowDictator.C:167