https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private 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.
 
MooseVariableBasemooseVariableBase () const
 Get the variable that this object is using.
 
MooseVariableField< T > & mooseVariableField ()
 Return the MooseVariableField object that this interface acts on.
 
MooseVariableFE< T > * mooseVariable () const
 Return the MooseVariableFE object that this interface acts on.
 
MooseVariableFV< T > * mooseVariableFV () const
 Return the MooseVariableFV object that this interface acts on.
 
MooseLinearVariableFV< T > * mooseLinearVariableFV () const
 Return the MooseLinearVariableFV object that this interface acts on.
 
virtual ~MooseVariableInterface ()
 

Protected Member Functions

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

Protected Attributes

bool _nodal
 Whether or not this object is acting only at nodes.
 
MooseVariableBase_var = nullptr
 The variable this object is acting on.
 
MooseVariableFE< T > * _variable = nullptr
 
MooseVariableFV< T > * _fv_variable = nullptr
 
MooseLinearVariableFV< T > * _linear_fv_variable = nullptr
 
MooseVariableField< T > * _field_variable = nullptr
 
Assembly_mvi_assembly
 

Private Attributes

const MooseObject_moose_object
 

Detailed Description

template<typename T>
class MooseVariableInterface< T >

Interface for objects that need to get values of MooseVariables.

Definition at line 30 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 23 of file MooseVariableInterface.C.

28 : _nodal(nodal), _moose_object(*moose_object)
29{
30 const InputParameters & parameters = _moose_object.parameters();
31
32 SubProblem & problem = *parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
33
34 THREAD_ID tid = parameters.get<THREAD_ID>("_tid");
35
36 _var = &problem.getVariable(tid,
37 parameters.varName(var_param_name, moose_object->name()),
38 expected_var_type,
39 expected_var_field_type);
40 if (!(_variable = dynamic_cast<MooseVariableFE<T> *>(_var)))
41 if (!(_fv_variable = dynamic_cast<MooseVariableFV<T> *>(_var)))
43 if (!(_field_variable = dynamic_cast<MooseVariableField<T> *>(_var)))
44 mooseError("The variable supplied to the variable interface is not of field type");
45
47 &problem.assembly(tid, (_var->kind() == Moose::VAR_SOLVER) ? _var->sys().number() : 0);
48}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int THREAD_ID
Definition MooseTypes.h:237
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::string varName(const std::string &var_param_name, const std::string &moose_object_with_var_param_name) const
Determine the actual variable name from the given variable \emph parameter name.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
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.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
This class provides variable solution interface for linear finite volume problems.
SystemBase & sys()
Get the system this variable is part of.
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)
Class for stuff related to variables.
This class provides variable solution values for other classes/objects to bind to when looping over f...
Class for stuff related to variables.
MooseVariableFE< T > * _variable
MooseVariableField< T > * _field_variable
MooseVariableFV< T > * _fv_variable
const MooseObject & _moose_object
bool _nodal
Whether or not this object is acting only at nodes.
MooseVariableBase * _var
The variable this object is acting on.
MooseLinearVariableFV< T > * _linear_fv_variable
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
virtual const MooseVariableFieldBase & getVariable(const 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) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
unsigned int number() const
Gets the number of this system.
@ VAR_SOLVER
Definition MooseTypes.h:770

◆ ~MooseVariableInterface()

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

Definition at line 51 of file MooseVariableInterface.C.

52{
53}

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 148 of file MooseVariableInterface.C.

149{
150 if (_nodal)
151 return _variable->dofValuesDot();
152 else
153 return _variable->uDot();
154}
const DofValues & dofValuesDot() const override
const FieldVariableValue & uDot() const
element dots

◆ 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 158 of file MooseVariableInterface.C.

159{
160 if (_nodal)
161 return _variable->dofValuesDotDot();
162 else
163 return _variable->uDotDot();
164}
const FieldVariableValue & uDotDot() const
const DofValues & dofValuesDotDot() const override

◆ 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 238 of file MooseVariableInterface.C.

239{
240 if (_nodal)
242 else
243 return _variable->duDotDotDu();
244}
const VariableValue & duDotDotDu() const
const MooseArray< libMesh::Number > & dofValuesDuDotDotDu() const override

◆ 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 178 of file MooseVariableInterface.C.

179{
180 if (_nodal)
182 else
183 return _variable->uDotDotOld();
184}
const DofValues & dofValuesDotDotOld() const override
const FieldVariableValue & uDotDotOld() const

◆ 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 228 of file MooseVariableInterface.C.

229{
230 if (_nodal)
231 return _variable->dofValuesDuDotDu();
232 else
233 return _variable->duDotDu();
234}
const MooseArray< libMesh::Number > & dofValuesDuDotDu() const override
const VariableValue & duDotDu() const

◆ 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 168 of file MooseVariableInterface.C.

169{
170 if (_nodal)
171 return _variable->dofValuesDotOld();
172 else
173 return _variable->uDotOld();
174}
const FieldVariableValue & uDotOld() const
const DofValues & dofValuesDotOld() const override

◆ 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 248 of file MooseVariableInterface.C.

249{
250 if (_nodal)
251 mooseError("gradients are not defined at nodes");
252
253 return _variable->gradSln();
254}
const FieldVariableGradient & gradSln() const override
element gradients

Referenced by DiffusionFluxAux::computeValue().

◆ 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 258 of file MooseVariableInterface.C.

259{
260 if (_nodal)
261 mooseError("gradients are not defined at nodes");
262
263 return _variable->gradSlnOld();
264}
const FieldVariableGradient & gradSlnOld() const override

◆ 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 268 of file MooseVariableInterface.C.

269{
270 if (_nodal)
271 mooseError("gradients are not defined at nodes");
272
273 return _variable->gradSlnOlder();
274}
const FieldVariableGradient & gradSlnOlder() const

◆ mooseLinearVariableFV()

template<typename T >
MooseLinearVariableFV< T > * MooseVariableInterface< T >::mooseLinearVariableFV ( ) const

Return the MooseLinearVariableFV object that this interface acts on.

Definition at line 68 of file MooseVariableInterface.C.

69{
72 "The variable defined in ", _moose_object.name(), " is not a MooseLinearVariableFV!");
74}

◆ mooseVariable()

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

◆ mooseVariableBase()

template<typename T >
MooseVariableBase * MooseVariableInterface< T >::mooseVariableBase ( ) const
inline

Get the variable that this object is using.

Returns
The variable this object is using.

Definition at line 50 of file MooseVariableInterface.h.

50{ return _var; };

Referenced by ElementAdaptivityLevelAux::ElementAdaptivityLevelAux(), ElementLpNormAux::ElementLpNormAux(), and VolumeAux::VolumeAux().

◆ mooseVariableField()

template<typename T >
MooseVariableField< T > & MooseVariableInterface< T >::mooseVariableField ( )

Return the MooseVariableField object that this interface acts on.

Definition at line 354 of file MooseVariableInterface.C.

355{
356 return *_field_variable;
357}

Referenced by DiracKernelTempl< T >::DiracKernelTempl(), and InternalSideIndicatorTempl< ComputeValueType >::InternalSideIndicatorTempl().

◆ mooseVariableFV()

template<typename T >
MooseVariableFV< T > * MooseVariableInterface< T >::mooseVariableFV ( ) const

Return the MooseVariableFV object that this interface acts on.

Definition at line 57 of file MooseVariableInterface.C.

58{
59 if (!_fv_variable)
60 mooseError("_fv_variable is null in ",
62 ". Did you forget to set fv = true in the Variables block?");
63 return _fv_variable;
64}

◆ 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 278 of file MooseVariableInterface.C.

279{
280 if (_nodal)
281 mooseError("second derivatives are not defined at nodes");
282
283 return _variable->secondSln();
284}
const FieldVariableSecond & secondSln() const
element seconds

Referenced by MooseVariableFV< OutputType >::getDirichletBoundaryFaceValue().

◆ 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 288 of file MooseVariableInterface.C.

289{
290 if (_nodal)
291 mooseError("second derivatives are not defined at nodes");
292
293 return _variable->secondSlnOld();
294}
const FieldVariableSecond & secondSlnOld() const

◆ 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 298 of file MooseVariableInterface.C.

299{
300 if (_nodal)
301 mooseError("second derivatives are not defined at nodes");
302
303 return _variable->secondSlnOlder();
304}
const FieldVariableSecond & secondSlnOlder() const

◆ 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 328 of file MooseVariableInterface.C.

329{
330 if (_nodal)
331 mooseError("second derivatives are not defined at nodes");
332
334 mooseError("second order shape function derivatives not available for linear FV variables");
335
337}
const VariablePhiSecond & secondPhi() const
Definition Assembly.h:1329

◆ 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 341 of file MooseVariableInterface.C.

342{
343 if (_nodal)
344 mooseError("second derivatives are not defined at nodes");
345
347 mooseError("second order shape function derivatives not available for linear FV variables");
348
350}
const VariablePhiSecond & secondPhiFace(const MooseVariableField< Real > &) const
Definition Assembly.h:1342

◆ 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 308 of file MooseVariableInterface.C.

309{
310 if (_nodal)
311 mooseError("second derivatives are not defined at nodes");
312
313 return _variable->secondPhi();
314}
const FieldVariablePhiSecond & secondPhi() const override final
Return the rank-2 tensor of second derivatives of the variable's elemental shape functions.

◆ 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 318 of file MooseVariableInterface.C.

319{
320 if (_nodal)
321 mooseError("second derivatives are not defined at nodes");
322
323 return _variable->secondPhiFace();
324}
const FieldVariablePhiSecond & secondPhiFace() const override final
Return the rank-2 tensor of second derivatives of the variable's shape functions on an element face.

◆ 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 88 of file MooseVariableInterface.C.

89{
90 if (_nodal)
91 return _variable->dofValues();
92 else
93 return _variable->sln();
94}
const DofValues & dofValues() const override
dof values getters
const FieldVariableValue & sln() const override
element solutions

Referenced by NodalConstraint::computeJacobian(), ConservativeAdvectionBCTempl< is_ad >::computeQpResidual(), BodyForceTempl< is_ad >::computeQpResidual(), ArrayBodyForce::computeQpResidual(), ElementUOAux::computeValue(), MeshDivisionAux::computeValue(), and ParsedVectorAux::computeValue().

◆ 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 108 of file MooseVariableInterface.C.

109{
110 if (_nodal)
111 return _variable->dofValuesOld();
112 else
113 return _variable->slnOld();
114}
const FieldVariableValue & slnOld() const override
const DofValues & dofValuesOld() const override

◆ 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 128 of file MooseVariableInterface.C.

129{
130 if (_nodal)
131 return _variable->dofValuesOlder();
132 else
133 return _variable->slnOlder();
134}
const FieldVariableValue & slnOlder() const override
const DofValues & dofValuesOlder() const override

Member Data Documentation

◆ _field_variable

template<typename T >
MooseVariableField<T>* MooseVariableInterface< T >::_field_variable = nullptr
protected

Definition at line 230 of file MooseVariableInterface.h.

◆ _fv_variable

template<typename T >
MooseVariableFV<T>* MooseVariableInterface< T >::_fv_variable = nullptr
protected

Definition at line 228 of file MooseVariableInterface.h.

◆ _linear_fv_variable

template<typename T >
MooseLinearVariableFV<T>* MooseVariableInterface< T >::_linear_fv_variable = nullptr
protected

Definition at line 229 of file MooseVariableInterface.h.

◆ _moose_object

template<typename T >
const MooseObject& MooseVariableInterface< T >::_moose_object
private

◆ _mvi_assembly

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

Definition at line 233 of file MooseVariableInterface.h.

◆ _nodal

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

Whether or not this object is acting only at nodes.

Definition at line 223 of file MooseVariableInterface.h.

◆ _var

template<typename T >
MooseVariableBase* MooseVariableInterface< T >::_var = nullptr
protected

The variable this object is acting on.

Definition at line 226 of file MooseVariableInterface.h.

Referenced by MooseVariableInterface< T >::mooseVariableBase(), and MooseVariableInterface< T >::MooseVariableInterface().

◆ _variable

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

Definition at line 227 of file MooseVariableInterface.h.


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