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 (Variable var, bool nodal=false)
 Constructor. More...
 
 VariableValue (const MooseVariableBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool nodal=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...
 
const bool _nodal
 Flag whether nodal 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/2]

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

Constructor.

Parameters
varThe Kokkos variable
nodalWhether to get nodal values

Definition at line 128 of file KokkosVariableValue.h.

128  : _var(var), _nodal(nodal)
129  {
130  if (nodal && !var.nodal())
131  mooseError("Cannot get nodal values of a non-nodal variable.");
132  }
Variable _var
Coupled Kokkos variable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
const bool _nodal
Flag whether nodal values are requested.

◆ VariableValue() [2/2]

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

Constructor.

Parameters
varThe MOOSE variable
tagThe vector tag name
nodalWhether to get nodal values

Definition at line 139 of file KokkosVariableValue.h.

142  : _var(var, tag), _nodal(nodal)
143  {
144  if (nodal && !var.isNodal())
145  mooseError("Cannot get nodal values of a non-nodal variable.");
146  }
virtual bool isNodal() const
Is this variable nodal.
Variable _var
Coupled Kokkos variable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
const bool _nodal
Flag whether nodal 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 152 of file KokkosVariableValue.h.

152 { 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 161 of file KokkosVariableValue.h.

162  {
163  if (_var.coupled())
164  {
165  if (_nodal)
166  {
167  KOKKOS_ASSERT(datum.isNodal());
168 
169  auto node = datum.node();
170  auto dof = datum.system(_var.sys(comp)).getNodeLocalDofIndex(node, _var.var(comp));
171 
172  return datum.system(_var.sys(comp)).getVectorDofValue(dof, _var.tag());
173  }
174  else
175  {
176  KOKKOS_ASSERT(!datum.isNodal());
177 
178  auto & elem = datum.elem();
179  auto side = datum.side();
180  auto qp_offset = datum.qpOffset();
181 
182  return side == libMesh::invalid_uint
183  ? datum.system(_var.sys(comp))
184  .getVectorQpValue(elem, qp_offset + qp, _var.var(comp), _var.tag())
185  : datum.system(_var.sys(comp))
186  .getVectorQpValueFace(elem, side, qp, _var.var(comp), _var.tag());
187  }
188  }
189  else
190  return _var.value(comp);
191  }
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
const bool _nodal
Flag whether nodal values are requested.
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

Member Data Documentation

◆ _nodal

const bool Moose::Kokkos::VariableValue::_nodal
private

Flag whether nodal values are requested.

Definition at line 201 of file KokkosVariableValue.h.

Referenced by operator()().

◆ _var

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

Coupled Kokkos variable.

Definition at line 197 of file KokkosVariableValue.h.

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


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