www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MooseVariableInterface< T > Class Template Reference

Interface for objects that need to get values of MooseVariables. More...

#include <MooseVariableInterface.h>

Inheritance diagram for MooseVariableInterface< T >:
[legend]

Public Member Functions

 MooseVariableInterface (const MooseObject *moose_object, bool nodal, std::string var_param_name="variable", Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY)
 Constructing the object. More...
 
MooseVariableFE< T > * mooseVariable () const
 Get the variable that this object is using. More...
 
virtual ~MooseVariableInterface ()
 

Protected Member Functions

virtual const OutputTools< T >::VariableValuevalue ()
 The value of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableValuevalueOld ()
 The old value of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableValuevalueOlder ()
 The older value of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableValuedot ()
 The time derivative of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableValuedotDot ()
 The second time derivative of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableValuedotOld ()
 The old time derivative of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableValuedotDotOld ()
 The old second time derivative of the variable this object is operating on. More...
 
virtual const VariableValuedotDu ()
 The derivative of the time derivative of the variable this object is operating on with respect to this variable's coefficients. More...
 
virtual const VariableValuedotDotDu ()
 The derivative of the second time derivative of the variable this object is operating on with respect to this variable's coefficients. More...
 
virtual const OutputTools< T >::VariableGradientgradient ()
 The gradient of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableGradientgradientOld ()
 The old gradient of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableGradientgradientOlder ()
 The older gradient of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableSecondsecond ()
 The second derivative of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableSecondsecondOld ()
 The old second derivative of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableSecondsecondOlder ()
 The older second derivative of the variable this object is operating on. More...
 
virtual const OutputTools< T >::VariableTestSecondsecondTest ()
 The second derivative of the test function. More...
 
virtual const OutputTools< T >::VariableTestSecondsecondTestFace ()
 The second derivative of the test function on the current face. More...
 
virtual const OutputTools< T >::VariablePhiSecondsecondPhi ()
 The second derivative of the trial function. More...
 
virtual const OutputTools< T >::VariablePhiSecondsecondPhiFace ()
 The second derivative of the trial function on the current face. More...
 

Protected Attributes

bool _nodal
 Whether or not this object is acting only at nodes. More...
 
MooseVariableFE< T > * _variable
 The variable this object is acting on. More...
 
Assembly_mvi_assembly
 

Detailed Description

template<typename T>
class MooseVariableInterface< T >

Interface for objects that need to get values of MooseVariables.

Definition at line 25 of file MooseVariableInterface.h.

Constructor & Destructor Documentation

◆ MooseVariableInterface()

template<typename T >
MooseVariableInterface< T >::MooseVariableInterface ( const MooseObject moose_object,
bool  nodal,
std::string  var_param_name = "variable",
Moose::VarKindType  expected_var_type = Moose::VarKindType::VAR_ANY,
Moose::VarFieldType  expected_var_field_type = Moose::VarFieldType::VAR_FIELD_ANY 
)

Constructing the object.

Parameters
parametersParameters that come from constructing the object
nodaltrue if the variable is nodal
var_param_namethe parameter name where we will find the coupled variable name

Definition at line 20 of file MooseVariableInterface.C.

25  : _nodal(nodal)
26 {
27  const InputParameters & parameters = moose_object->parameters();
28 
29  SubProblem & problem = *parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
30 
31  THREAD_ID tid = parameters.get<THREAD_ID>("_tid");
32 
33  // Try the scalar version first
34  std::string variable_name = parameters.getMooseType(var_param_name);
35  if (variable_name == "")
36  {
37  auto vec = parameters.getVecMooseType(var_param_name);
38 
39  // Catch the (very unlikely) case where a user specifies
40  // variable = '' (the empty string)
41  // in their input file. This could happen if e.g. something goes
42  // wrong with dollar bracket expression expansion.
43  if (vec.empty())
44  mooseError("Error constructing object '",
45  moose_object->name(),
46  "' while retrieving value for '",
47  var_param_name,
48  "' parameter! Did you set ",
49  var_param_name,
50  " = '' (empty string) by accident?");
51 
52  // When using vector variables, we are only going to use the first one in the list at the
53  // interface level...
54  variable_name = vec[0];
55  }
56 
57  _variable = &dynamic_cast<MooseVariableFE<T> &>(
58  problem.getVariable(tid, variable_name, expected_var_type, expected_var_field_type));
59 
60  _mvi_assembly = &problem.assembly(tid);
61 }
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
virtual MooseVariableFEBase & getVariable(THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY)=0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual Assembly & assembly(THREAD_ID tid)=0
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool _nodal
Whether or not this object is acting only at nodes.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:57
MooseVariableFE< T > * _variable
The variable this object is acting on.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:51
std::vector< std::string > getVecMooseType(const std::string &name) const
unsigned int THREAD_ID
Definition: MooseTypes.h:97

◆ ~MooseVariableInterface()

template<typename T >
MooseVariableInterface< T >::~MooseVariableInterface ( )
virtual

Definition at line 64 of file MooseVariableInterface.C.

65 {
66 }

Member Function Documentation

◆ dot()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::dot ( )
protectedvirtual

The time derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 137 of file MooseVariableInterface.C.

138 {
139  if (_nodal)
140  return _variable->dofValuesDot();
141  else
142  return _variable->uDot();
143 }
const MooseArray< Number > & dofValuesDot() override
Returns time derivative of degrees of freedom.
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableValue & uDot()

◆ dotDot()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::dotDot ( )
protectedvirtual

The second time derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 147 of file MooseVariableInterface.C.

148 {
149  if (_nodal)
150  return _variable->dofValuesDotDot();
151  else
152  return _variable->uDotDot();
153 }
const MooseArray< Number > & dofValuesDotDot() override
Returns second time derivative of degrees of freedom.
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableValue & uDotDot()

◆ dotDotDu()

template<typename T >
const VariableValue & MooseVariableInterface< T >::dotDotDu ( )
protectedvirtual

The derivative of the second time derivative of the variable this object is operating on with respect to this variable's coefficients.

This is useful for creating Jacobian entries for residual statements that use _u_dotdot

Returns
The reference to be stored off and used later.

Definition at line 227 of file MooseVariableInterface.C.

228 {
229  if (_nodal)
230  return _variable->dofValuesDuDotDotDu();
231  else
232  return _variable->duDotDotDu();
233 }
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const MooseArray< Number > & dofValuesDuDotDotDu() override
Returns derivative of second time derivative of degrees of freedom.
const VariableValue & duDotDotDu()

◆ dotDotOld()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::dotDotOld ( )
protectedvirtual

The old second time derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 167 of file MooseVariableInterface.C.

168 {
169  if (_nodal)
170  return _variable->dofValuesDotDotOld();
171  else
172  return _variable->uDotDotOld();
173 }
bool _nodal
Whether or not this object is acting only at nodes.
const MooseArray< Number > & dofValuesDotDotOld() override
Returns old second time derivative of degrees of freedom.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableValue & uDotDotOld()

◆ dotDu()

template<typename T >
const VariableValue & MooseVariableInterface< T >::dotDu ( )
protectedvirtual

The derivative of the time derivative of the variable this object is operating on with respect to this variable's coefficients.

This is useful for creating Jacobian entries for residual statements that use _u_dot

Returns
The reference to be stored off and used later.

Definition at line 217 of file MooseVariableInterface.C.

218 {
219  if (_nodal)
220  return _variable->dofValuesDuDotDu();
221  else
222  return _variable->duDotDu();
223 }
const VariableValue & duDotDu()
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const MooseArray< Number > & dofValuesDuDotDu() override
Returns derivative of time derivative of degrees of freedom.

◆ dotOld()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::dotOld ( )
protectedvirtual

The old time derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 157 of file MooseVariableInterface.C.

158 {
159  if (_nodal)
160  return _variable->dofValuesDotOld();
161  else
162  return _variable->uDotOld();
163 }
const MooseArray< Number > & dofValuesDotOld() override
Returns old time derivative of degrees of freedom.
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableValue & uDotOld()

◆ gradient()

template<typename T >
const OutputTools< T >::VariableGradient & MooseVariableInterface< T >::gradient ( )
protectedvirtual

The gradient of the variable this object is operating on.

This is computed by default and should already be available as _grad_u

Returns
The reference to be stored off and used later.

Definition at line 237 of file MooseVariableInterface.C.

238 {
239  if (_nodal)
240  mooseError("gradients are not defined at nodes");
241 
242  return _variable->gradSln();
243 }
const FieldVariableGradient & gradSln()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ gradientOld()

template<typename T >
const OutputTools< T >::VariableGradient & MooseVariableInterface< T >::gradientOld ( )
protectedvirtual

The old gradient of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 247 of file MooseVariableInterface.C.

248 {
249  if (_nodal)
250  mooseError("gradients are not defined at nodes");
251 
252  return _variable->gradSlnOld();
253 }
const FieldVariableGradient & gradSlnOld()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ gradientOlder()

template<typename T >
const OutputTools< T >::VariableGradient & MooseVariableInterface< T >::gradientOlder ( )
protectedvirtual

The older gradient of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 257 of file MooseVariableInterface.C.

258 {
259  if (_nodal)
260  mooseError("gradients are not defined at nodes");
261 
262  return _variable->gradSlnOlder();
263 }
const FieldVariableGradient & gradSlnOlder()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ mooseVariable()

template<typename T >
MooseVariableFE< T > * MooseVariableInterface< T >::mooseVariable ( ) const

Get the variable that this object is using.

Returns
The variable this object is using.

Definition at line 70 of file MooseVariableInterface.C.

71 {
72  return _variable;
73 }
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ second()

template<typename T >
const OutputTools< T >::VariableSecond & MooseVariableInterface< T >::second ( )
protectedvirtual

The second derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 267 of file MooseVariableInterface.C.

268 {
269  if (_nodal)
270  mooseError("second derivatives are not defined at nodes");
271 
272  return _variable->secondSln();
273 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableSecond & secondSln()

◆ secondOld()

template<typename T >
const OutputTools< T >::VariableSecond & MooseVariableInterface< T >::secondOld ( )
protectedvirtual

The old second derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 277 of file MooseVariableInterface.C.

278 {
279  if (_nodal)
280  mooseError("second derivatives are not defined at nodes");
281 
282  return _variable->secondSlnOld();
283 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableSecond & secondSlnOld()

◆ secondOlder()

template<typename T >
const OutputTools< T >::VariableSecond & MooseVariableInterface< T >::secondOlder ( )
protectedvirtual

The older second derivative of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 287 of file MooseVariableInterface.C.

288 {
289  if (_nodal)
290  mooseError("second derivatives are not defined at nodes");
291 
292  return _variable->secondSlnOlder();
293 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableSecond & secondSlnOlder()

◆ secondPhi()

template<typename T >
const OutputTools< T >::VariablePhiSecond & MooseVariableInterface< T >::secondPhi ( )
protectedvirtual

The second derivative of the trial function.

Returns
The reference to be stored off and used later.

Definition at line 317 of file MooseVariableInterface.C.

318 {
319  if (_nodal)
320  mooseError("second derivatives are not defined at nodes");
321 
323 }
const VariablePhiSecond & secondPhi() const
Definition: Assembly.h:652
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ secondPhiFace()

template<typename T >
const OutputTools< T >::VariablePhiSecond & MooseVariableInterface< T >::secondPhiFace ( )
protectedvirtual

The second derivative of the trial function on the current face.

This should be called in e.g. IntegratedBC when you need second derivatives of the trial function function on the boundary.

Returns
The reference to be stored off and used later.

Definition at line 327 of file MooseVariableInterface.C.

328 {
329  if (_nodal)
330  mooseError("second derivatives are not defined at nodes");
331 
333 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
const VariablePhiSecond & secondPhiFace(MooseVariable &) const
Definition: Assembly.h:659
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ secondTest()

template<typename T >
const OutputTools< T >::VariableTestSecond & MooseVariableInterface< T >::secondTest ( )
protectedvirtual

The second derivative of the test function.

Returns
The reference to be stored off and used later.

Definition at line 297 of file MooseVariableInterface.C.

298 {
299  if (_nodal)
300  mooseError("second derivatives are not defined at nodes");
301 
302  return _variable->secondPhi();
303 }
const FieldVariablePhiSecond & secondPhi()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.

◆ secondTestFace()

template<typename T >
const OutputTools< T >::VariableTestSecond & MooseVariableInterface< T >::secondTestFace ( )
protectedvirtual

The second derivative of the test function on the current face.

This should be called in e.g. IntegratedBC when you need second derivatives of the test function function on the boundary.

Returns
The reference to be stored off and used later.

Definition at line 307 of file MooseVariableInterface.C.

308 {
309  if (_nodal)
310  mooseError("second derivatives are not defined at nodes");
311 
312  return _variable->secondPhiFace();
313 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariablePhiSecond & secondPhiFace()

◆ value()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::value ( )
protectedvirtual

The value of the variable this object is operating on.

This is computed by default and should already be available as _u

Returns
The reference to be stored off and used later.

Definition at line 77 of file MooseVariableInterface.C.

78 {
79  if (_nodal)
80  return _variable->dofValues();
81  else
82  return _variable->sln();
83 }
const FieldVariableValue & sln()
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const MooseArray< Number > & dofValues() override
Returns dof solution on element.

◆ valueOld()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::valueOld ( )
protectedvirtual

The old value of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 97 of file MooseVariableInterface.C.

98 {
99  if (_nodal)
100  return _variable->dofValuesOld();
101  else
102  return _variable->slnOld();
103 }
bool _nodal
Whether or not this object is acting only at nodes.
const MooseArray< Number > & dofValuesOld() override
Returns old dof solution on element.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableValue & slnOld()

◆ valueOlder()

template<typename T >
const OutputTools< T >::VariableValue & MooseVariableInterface< T >::valueOlder ( )
protectedvirtual

The older value of the variable this object is operating on.

Returns
The reference to be stored off and used later.

Definition at line 117 of file MooseVariableInterface.C.

118 {
119  if (_nodal)
120  return _variable->dofValuesOlder();
121  else
122  return _variable->slnOlder();
123 }
const MooseArray< Number > & dofValuesOlder() override
Returns older dof solution on element.
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableFE< T > * _variable
The variable this object is acting on.
const FieldVariableValue & slnOlder()

Member Data Documentation

◆ _mvi_assembly

template<typename T>
Assembly* MooseVariableInterface< T >::_mvi_assembly
protected

◆ _nodal

template<typename T>
bool MooseVariableInterface< T >::_nodal
protected

Whether or not this object is acting only at nodes.

Definition at line 198 of file MooseVariableInterface.h.

◆ _variable

template<typename T>
MooseVariableFE<T>* MooseVariableInterface< T >::_variable
protected

The variable this object is acting on.

Definition at line 201 of file MooseVariableInterface.h.

Referenced by MooseVariableInterface< Real >::MooseVariableInterface().


The documentation for this class was generated from the following files: