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