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