https://mooseframework.inl.gov
Public Member Functions | Private Attributes | List of all members
Moose::Kokkos::VariableValue Class Reference

The Kokkos wrapper classes for MOOSE-like variable value access. More...

#include <KokkosVariableValue.h>

Public Member Functions

 VariableValue ()=default
 Default constructor. More...
 
 VariableValue (Variable var, bool dof=false)
 Constructor. More...
 
 VariableValue (const MooseVariableBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
 Constructor. More...
 
KOKKOS_FUNCTION operator bool () const
 Get whether the variable was coupled. More...
 
KOKKOS_FUNCTION Real operator() (Datum &datum, unsigned int qp, unsigned int comp=0) const
 Get the current variable value. More...
 

Private Attributes

Variable _var
 Coupled Kokkos variable. More...
 
bool _dof = false
 Flag whether DOF values are requested. More...
 

Detailed Description

The Kokkos wrapper classes for MOOSE-like variable value access.

Definition at line 120 of file KokkosVariableValue.h.

Constructor & Destructor Documentation

◆ VariableValue() [1/3]

Moose::Kokkos::VariableValue::VariableValue ( )
default

Default constructor.

◆ VariableValue() [2/3]

Moose::Kokkos::VariableValue::VariableValue ( Variable  var,
bool  dof = false 
)
inline

Constructor.

Parameters
varThe Kokkos variable
dofWhether to get DOF values

Definition at line 132 of file KokkosVariableValue.h.

132 : _var(var), _dof(dof) {}
Variable _var
Coupled Kokkos variable.
bool _dof
Flag whether DOF values are requested.

◆ VariableValue() [3/3]

Moose::Kokkos::VariableValue::VariableValue ( const MooseVariableBase var,
const TagName &  tag = Moose::SOLUTION_TAG,
bool  dof = false 
)
inline

Constructor.

Parameters
varThe MOOSE variable
tagThe vector tag name
dofWhether to get DOF values

Definition at line 139 of file KokkosVariableValue.h.

142  : _var(var, tag), _dof(dof)
143  {
144  }
Variable _var
Coupled Kokkos variable.
bool _dof
Flag whether DOF values are requested.

Member Function Documentation

◆ operator bool()

KOKKOS_FUNCTION Moose::Kokkos::VariableValue::operator bool ( ) const
inline

Get whether the variable was coupled.

Returns
Whether the variable was coupled

Definition at line 150 of file KokkosVariableValue.h.

150 { return _var.coupled(); }
Variable _var
Coupled Kokkos variable.
KOKKOS_FUNCTION bool coupled() const
Get whether the variable is coupled.

◆ operator()()

KOKKOS_FUNCTION Real Moose::Kokkos::VariableValue::operator() ( Datum datum,
unsigned int  qp,
unsigned int  comp = 0 
) const
inline

Get the current variable value.

Parameters
datumThe Datum object of the current thread
qpThe local quadrature point index
compThe variable component
Returns
The variable value

Definition at line 218 of file KokkosVariableValue.h.

219 {
220  KOKKOS_ASSERT(_var.initialized());
221 
222  if (_var.coupled())
223  {
224  auto & sys = datum.system(_var.sys(comp));
225  auto var = _var.var(comp);
226  auto tag = _var.tag();
227 
228  if (_dof)
229  {
230  unsigned int dof;
231 
232  if (datum.isNodal())
233  {
234  auto node = datum.node();
235  dof = sys.getNodeLocalDofIndex(node, 0, var);
236  }
237  else
238  {
239  auto elem = datum.elem().id;
240  dof = sys.getElemLocalDofIndex(elem, idx, var);
241  }
242 
243  return sys.getVectorDofValue(dof, tag);
244  }
245  else
246  {
247  auto & elem = datum.elem();
248  auto side = datum.side();
249  auto offset = datum.qpOffset();
250 
251  return side == libMesh::invalid_uint ? sys.getVectorQpValue(elem, offset + idx, var, tag)
252  : sys.getVectorQpValueFace(elem, side, idx, var, tag);
253  }
254  }
255  else
256  return _var.value(comp);
257 }
KOKKOS_FUNCTION TagID tag() const
Get the vector tag ID.
Variable _var
Coupled Kokkos variable.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
const unsigned int invalid_uint
KOKKOS_FUNCTION bool initialized() const
Get whether the variable is initialized.
KOKKOS_FUNCTION bool coupled() const
Get whether the variable is coupled.
KOKKOS_FUNCTION unsigned int side() const
Get the side index.
Definition: KokkosDatum.h:90
KOKKOS_FUNCTION ContiguousNodeID node() const
Get the contiguous node ID.
Definition: KokkosDatum.h:95
KOKKOS_FUNCTION Real value(unsigned int comp=0) const
Get the default value of a component.
KOKKOS_FUNCTION bool isNodal() const
Get whether the current datum is on a node.
Definition: KokkosDatum.h:115
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
Definition: KokkosDatum.h:80
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
KOKKOS_FUNCTION const System & system(unsigned int sys) const
Get the Kokkos system.
Definition: KokkosDatum.h:74
KOKKOS_FUNCTION dof_id_type qpOffset() const
Get the starting offset into the global quadrature point index.
Definition: KokkosDatum.h:105
bool _dof
Flag whether DOF values are requested.
ContiguousElementID id
Contiguous element ID.
Definition: KokkosMesh.h:44

Member Data Documentation

◆ _dof

bool Moose::Kokkos::VariableValue::_dof = false
private

Flag whether DOF values are requested.

Definition at line 169 of file KokkosVariableValue.h.

Referenced by operator()().

◆ _var

Variable Moose::Kokkos::VariableValue::_var
private

Coupled Kokkos variable.

Definition at line 165 of file KokkosVariableValue.h.

Referenced by operator bool(), and operator()().


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