www.mooseframework.org
RichardsVarNames.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 Richards variables (porepressure, saturations) and the variable number used
9 // by MOOSE.
10 //
11 #include "RichardsVarNames.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<GeneralUserObject>();
18  params.addClassDescription("Holds information on the porepressure variable names");
19  params.addRequiredCoupledVar("richards_vars",
20  "List of variables that represent the porepressures or "
21  "(porepressure, saturations). In single-phase models you will just "
22  "have one (eg \'pressure\'), in two-phase models you will have two "
23  "(eg \'p_water p_gas\', or \'p_water s_water\', etc. These names "
24  "must also be used in your kernels and material.");
25  MooseEnum var_types("pppp", "pppp");
26  params.addParam<MooseEnum>(
27  "var_types",
28  var_types,
29  "Variable types for the problem. Eg, 'pppp' means all the variables are pressure variables");
30 
31  return params;
32 }
33 
34 RichardsVarNames::RichardsVarNames(const InputParameters & parameters)
35  : GeneralUserObject(parameters),
36  Coupleable(this, false),
37  ZeroInterface(parameters),
38  _num_v(coupledComponents("richards_vars")),
39  _var_types(getParam<MooseEnum>("var_types"))
40 {
41  unsigned int max_moose_var_num_seen = 0;
42 
43  _moose_var_num.resize(_num_v);
44  _moose_var_value.resize(_num_v);
48  _moose_grad_var.resize(_num_v);
49  for (unsigned int i = 0; i < _num_v; ++i)
50  {
51  _moose_var_num[i] = coupled("richards_vars", i);
52  max_moose_var_num_seen =
53  (max_moose_var_num_seen > _moose_var_num[i] ? max_moose_var_num_seen : _moose_var_num[i]);
54  _moose_var_value[i] = &coupledValue("richards_vars", i); // coupledValue returns a reference (an
55  // alias) to a VariableValue, and the &
56  // turns it into a pointer
57  _moose_var_value_old[i] = (_is_transient ? &coupledValueOld("richards_vars", i) : &_zero);
58  _moose_nodal_var_value[i] = &coupledNodalValue("richards_vars", i); // coupledNodalValue returns
59  // a reference (an alias) to
60  // a VariableValue, and the
61  // & turns it into a pointer
63  (_is_transient ? &coupledNodalValueOld("richards_vars", i) : &_zero);
64  _moose_grad_var[i] = &coupledGradient("richards_vars", i);
65  }
66 
67  _ps_var_num.resize(max_moose_var_num_seen + 1);
68  for (unsigned int i = 0; i < max_moose_var_num_seen + 1; ++i)
69  _ps_var_num[i] = _num_v; // NOTE: indicates that i is not a richards variable
70  for (unsigned int i = 0; i < _num_v; ++i)
72 }
73 
74 void
76 {
77 }
78 
79 void
81 {
82 }
83 
84 void
86 {
87 }
88 
89 unsigned int
91 {
92  return _num_v;
93 }
94 
95 unsigned int
96 RichardsVarNames::richards_var_num(unsigned int moose_var_num) const
97 {
98  if (moose_var_num >= _ps_var_num.size() || _ps_var_num[moose_var_num] == _num_v)
99  mooseError("The moose variable with number ",
100  moose_var_num,
101  " is not a richards according to the RichardsVarNames UserObject");
102  return _ps_var_num[moose_var_num];
103 }
104 
105 bool
106 RichardsVarNames::not_richards_var(unsigned int moose_var_num) const
107 {
108  if (moose_var_num >= _ps_var_num.size() || _ps_var_num[moose_var_num] == _num_v)
109  return true;
110  return false;
111 }
112 
113 const VariableValue *
115 {
116  return _moose_var_value[richards_var_num]; // moose_var_value is a vector of pointers to
117  // VariableValuees
118 }
119 
120 const VariableValue *
122 {
124 }
125 
126 const VariableGradient *
128 {
130 }
131 
132 std::string
134 {
135  return _var_types;
136 }
137 
138 const VariableValue *
140 {
142 }
143 
144 const VariableValue *
146 {
148 }
const VariableValue * nodal_var_old(unsigned int richards_var_num) const
The old nodal variable values for the given richards_var_num.
InputParameters validParams< RichardsVarNames >()
std::vector< const VariableValue * > _moose_nodal_var_value
moose_var_value[i] = values of richards variable i
std::vector< const VariableValue * > _moose_nodal_var_value_old
moose_var_value_old[i] = old values of richards variable i
std::vector< unsigned int > _moose_var_num
_moose_var_num[i] = the moose variable number corresponding to richards variable i ...
const VariableValue * nodal_var(unsigned int richards_var_num) const
The nodal variable values for the given richards_var_num To extract a the value of pressure variable ...
bool not_richards_var(unsigned int moose_var_num) const
returns true if moose_var_num is not a richards var
std::vector< const VariableValue * > _moose_var_value
moose_var_value[i] = values of richards variable i
unsigned int num_v() const
the number of porepressure variables
const VariableGradient * grad_var(unsigned int richards_var_num) const
a vector of pointers to grad(Variable)
std::vector< unsigned int > _ps_var_num
_pressure_var_num[i] = the richards variable corresponding to moose variable i
std::string var_types() const
return the _var_types string
const VariableValue * richards_vals(unsigned int richards_var_num) const
a vector of pointers to VariableValues
std::vector< const VariableGradient * > _moose_grad_var
moose_grad_var[i] = gradient values of richards variable i
RichardsVarNames(const InputParameters &parameters)
MooseEnum _var_types
physical meaning of the variables. Eg &#39;pppp&#39; means &#39;all variables are pressure variables&#39; ...
unsigned int _num_v
number of richards variables
const VariableValue * richards_vals_old(unsigned int richards_var_num) const
a vector of pointers to old VariableValues
unsigned int richards_var_num(unsigned int moose_var_num) const
the richards variable number
std::vector< const VariableValue * > _moose_var_value_old
moose_var_value_old[i] = old values of richards variable i