https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
Moose::Kokkos::VariableGradientTempl< is_ad > Class Template Reference

#include <KokkosVariableValue.h>

Public Member Functions

 VariableGradientTempl ()=default
 Default constructor.
 
 VariableGradientTempl (Variable var)
 Constructor.
 
 VariableGradientTempl (const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
 Constructor.
 
KOKKOS_FUNCTION operator bool () const
 Get whether the variable was coupled.
 
KOKKOS_FUNCTION auto operator() (Datum &datum, unsigned int qp, unsigned int comp=0) const
 Get the current variable gradient.
 
KOKKOS_FUNCTION const Variable & variable () const
 Get the Kokkos variable.
 

Private Types

using real3_type = std::conditional_t< is_ad, ADReal3, Real3 >
 

Private Attributes

Variable _var
 Coupled Kokkos variable.
 
Array< Real > _seed
 Derivative seed of each component for AD.
 
 VariableGradientTempl (const VariableGradientTempl< is_ad > &object)
 Copy constructor for parallel dispatch.
 
VariableGradientTempl< is_ad > & operator= (const VariableGradientTempl< is_ad > &object)
 Copy assignment operator.
 
KOKKOS_FUNCTION auto operator() (AssemblyDatum &datum, unsigned int qp, unsigned int comp=0) const
 Get the current variable gradient.
 
KOKKOS_FUNCTION auto get (Datum &datum, unsigned int qp, unsigned int comp=0, Real seed=0) const
 Get the current variable gradient.
 

Detailed Description

template<bool is_ad>
class Moose::Kokkos::VariableGradientTempl< is_ad >

Definition at line 424 of file KokkosVariableValue.h.

Member Typedef Documentation

◆ real3_type

template<bool is_ad>
using Moose::Kokkos::VariableGradientTempl< is_ad >::real3_type = std::conditional_t<is_ad, ADReal3, Real3>
private

Definition at line 426 of file KokkosVariableValue.h.

Constructor & Destructor Documentation

◆ VariableGradientTempl() [1/4]

template<bool is_ad>
Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl ( )
default

Default constructor.

◆ VariableGradientTempl() [2/4]

template<bool is_ad>
Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl ( Variable  var)
inline

Constructor.

Parameters
varThe Kokkos variable

Definition at line 437 of file KokkosVariableValue.h.

437 : _var(var)
438 {
439 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
440 }
Variable _var
Coupled Kokkos variable.
void checkVariable(const Variable &var, bool expect_vector, const std::string &wrapper_name)

◆ VariableGradientTempl() [3/4]

template<bool is_ad>
Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl ( const MooseVariableFieldBase &  var,
const TagName &  tag = Moose::SOLUTION_TAG 
)
inline

Constructor.

Parameters
varThe MOOSE variable
tagThe vector tag name

Definition at line 446 of file KokkosVariableValue.h.

448 : _var(var, tag)
449 {
450 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
451 }

◆ VariableGradientTempl() [4/4]

template<bool is_ad>
Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl ( const VariableGradientTempl< is_ad > &  object)

Copy constructor for parallel dispatch.

Definition at line 519 of file KokkosVariableValue.h.

520 : _var(object._var), _seed(object._seed)
521{
522 if constexpr (is_ad)
523 if (_var.coupled())
524 {
525 if (!_seed.isAlloc())
527
528 for (unsigned int comp = 0; comp < _var.components(); ++comp)
529 _seed[comp] =
530 _var.dot() ? _var.mooseVar(comp)->sys().duDotDu(_var.var(comp)) : (_var.old() ? 0 : 1);
531
533 }
534}
SystemBase & sys()
Get the system this variable is part of.
void copyToDevice()
Copy data from host to device.
KOKKOS_FUNCTION bool isAlloc() const
Get whether the array was allocated either on host or device.
void create(const std::vector< index_type > &n)
Allocate array on host and device.
Array< Real > _seed
Derivative seed of each component for AD.
KOKKOS_FUNCTION unsigned int components() const
Get the number of components.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
KOKKOS_FUNCTION bool coupled() const
Get whether the variable is coupled.
const MooseVariableBase * mooseVar(unsigned int comp=0)
Get the MOOSE variable of a component.
KOKKOS_FUNCTION bool dot() const
Get whether the tag is time derivative.
virtual const Number & duDotDu(unsigned int var_num=0) const

Member Function Documentation

◆ get()

template<bool is_ad>
KOKKOS_FUNCTION auto Moose::Kokkos::VariableGradientTempl< is_ad >::get ( Datum &  datum,
unsigned int  qp,
unsigned int  comp = 0,
Real  seed = 0 
) const
private

Get the current variable gradient.

Parameters
datumThe Datum object of the current thread
qpThe local quadrature point index
compThe variable component
seedThe derivative seed (only meaningful for AD)
Returns
The variable gradient

Definition at line 564 of file KokkosVariableValue.h.

568{
569 KOKKOS_ASSERT(_var.initialized());
570
571 real3_type grad;
572
573 if (_var.coupled())
574 {
575 KOKKOS_ASSERT(!datum.isNodal());
576
577 auto & elem = datum.elem();
578 auto side = datum.side();
579
580 if constexpr (is_ad)
581 grad =
583 ? datum.system(_var.sys(comp))
584 .getVectorQpADGrad(
585 elem, datum.J(qp), datum.qpOffset(), qp, _var.var(comp), _var.tag(), seed)
586 : datum.system(_var.sys(comp))
587 .getVectorQpADGradFace(
588 elem, side, datum.J(qp), qp, _var.var(comp), _var.tag(), seed);
589 else
590 grad =
592 ? datum.system(_var.sys(comp))
593 .getVectorQpGrad(elem, datum.qpOffset() + qp, _var.var(comp), _var.tag())
594 : datum.system(_var.sys(comp))
595 .getVectorQpGradFace(elem, side, datum.J(qp), qp, _var.var(comp), _var.tag());
596 }
597
598 return grad;
599}
KOKKOS_FUNCTION const FESystem & system(unsigned int sys) const
Get the Kokkos system.
KOKKOS_FUNCTION const Real33 & J(const unsigned int qp)
Get the inverse of Jacobian matrix | dxi/dx deta/dx dzeta/dx | | dxi/dy deta/dy dzeta/dy | | dxi/dz d...
KOKKOS_FUNCTION dof_id_type qpOffset() const
Get the starting offset into the global quadrature point index.
KOKKOS_FUNCTION bool isNodal() const
Get whether the current datum is on a node.
KOKKOS_FUNCTION Real3 getVectorQpGradFace(const ElementInfo info, const unsigned int side, const Real33 jacobian, const unsigned int qp, const unsigned int var, const TagID tag) const
Get the face quadrature point gradient of a variable from a tagged vector.
KOKKOS_FUNCTION Real3 & getVectorQpGrad(const ElementInfo info, const dof_id_type qp, const unsigned int var, const TagID tag) const
Get the quadrature point gradient of a variable from a tagged vector.
KOKKOS_FUNCTION unsigned int side() const
Get the side index.
Definition KokkosDatum.h:79
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
Definition KokkosDatum.h:46
std::conditional_t< is_ad, ADReal3, Real3 > real3_type
KOKKOS_FUNCTION TagID tag() const
Get the vector tag ID.
KOKKOS_FUNCTION bool initialized() const
Get whether the variable is initialized.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
const unsigned int invalid_uint

Referenced by Moose::Kokkos::VariableGradientTempl< is_ad >::operator()().

◆ operator bool()

template<bool is_ad>
KOKKOS_FUNCTION Moose::Kokkos::VariableGradientTempl< is_ad >::operator bool ( ) const
inline

Get whether the variable was coupled.

Returns
Whether the variable was coupled

Definition at line 466 of file KokkosVariableValue.h.

466{ return _var.coupled(); }

◆ operator()() [1/2]

template<bool is_ad>
KOKKOS_FUNCTION auto Moose::Kokkos::VariableGradientTempl< is_ad >::operator() ( AssemblyDatum &  datum,
unsigned int  qp,
unsigned int  comp = 0 
) const

Get the current variable gradient.

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

Definition at line 547 of file KokkosVariableValue.h.

550{
551 if constexpr (is_ad)
552 {
553 Real seed =
554 datum.do_derivatives() && _var.coupled() && _var.sys(comp) == datum.sys() ? _seed[comp] : 0;
555
556 return get(datum, qp, comp, seed);
557 }
558 else
559 return get(datum, qp, comp);
560}
KOKKOS_FUNCTION unsigned int sys() const
Get the system number of variable.
KOKKOS_FUNCTION void do_derivatives(const bool flag)
Set whether to compute derivatives for automatic differentiation (AD)
KOKKOS_FUNCTION auto get(Datum &datum, unsigned int qp, unsigned int comp=0, Real seed=0) const
Get the current variable gradient.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ operator()() [2/2]

template<bool is_ad>
KOKKOS_FUNCTION auto Moose::Kokkos::VariableGradientTempl< is_ad >::operator() ( Datum &  datum,
unsigned int  qp,
unsigned int  comp = 0 
) const
inline

Get the current variable gradient.

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

Definition at line 475 of file KokkosVariableValue.h.

476 {
477 return get(datum, qp, comp);
478 }

◆ operator=()

template<bool is_ad>
VariableGradientTempl< is_ad > & Moose::Kokkos::VariableGradientTempl< is_ad >::operator= ( const VariableGradientTempl< is_ad > &  object)

Copy assignment operator.

Definition at line 538 of file KokkosVariableValue.h.

539{
540 _var = object._var;
541
542 return *this;
543}
Array< unsigned int > _var
Variable number of each component.

◆ variable()

template<bool is_ad>
KOKKOS_FUNCTION const Variable & Moose::Kokkos::VariableGradientTempl< is_ad >::variable ( ) const
inline

Get the Kokkos variable.

Returns
The Kokkos variable

Definition at line 494 of file KokkosVariableValue.h.

494{ return _var; }

Member Data Documentation

◆ _seed

template<bool is_ad>
Array<Real> Moose::Kokkos::VariableGradientTempl< is_ad >::_seed
private

Derivative seed of each component for AD.

Definition at line 515 of file KokkosVariableValue.h.

Referenced by Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl().

◆ _var

template<bool is_ad>
Variable Moose::Kokkos::VariableGradientTempl< is_ad >::_var
private

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