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.
 
 VariableGradientTempl (const std::vector< const MooseVariableFieldBase * > &vars, const TagName &tag=Moose::SOLUTION_TAG)
 Constructor.
 
 VariableGradientTempl (const std::vector< MooseVariableFieldBase * > &vars, const TagName &tag=Moose::SOLUTION_TAG)
 
KOKKOS_FUNCTION auto operator() (AssemblyDatum &datum, unsigned int qp, unsigned int comp) const
 Get the current variable gradient.
 
KOKKOS_FUNCTION auto operator() (AssemblyDatum &datum, unsigned int qp) const
 

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 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 453 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 455 of file KokkosVariableValue.h.

Constructor & Destructor Documentation

◆ VariableGradientTempl() [1/6]

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

Default constructor.

◆ VariableGradientTempl() [2/6]

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

Constructor.

Parameters
varThe Kokkos variable

Definition at line 466 of file KokkosVariableValue.h.

466 : _var(var)
467 {
468 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
469 }
Variable _var
Coupled Kokkos variable.
void checkVariable(const Variable &var, bool expect_vector, const std::string &wrapper_name)

◆ VariableGradientTempl() [3/6]

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 475 of file KokkosVariableValue.h.

477 : _var(var, tag)
478 {
479 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
480 }

◆ VariableGradientTempl() [4/6]

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

Constructor.

Parameters
varsThe MOOSE variables
tagThe vector tag name

Definition at line 487 of file KokkosVariableValue.h.

489 : _var(vars, tag)
490 {
491 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
492 }
char ** vars

◆ VariableGradientTempl() [5/6]

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

Definition at line 493 of file KokkosVariableValue.h.

495 : _var(vars, tag)
496 {
497 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
498 }

◆ VariableGradientTempl() [6/6]

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

Copy constructor for parallel dispatch.

Definition at line 572 of file KokkosVariableValue.h.

573 : _var(object._var), _seed(object._seed)
574{
575 if constexpr (is_ad)
576 if (_var.coupled())
577 {
578 if (!_seed.isAlloc())
580
581 for (unsigned int comp = 0; comp < _var.components(); ++comp)
582 _seed[comp] =
583 _var.dot() ? _var.mooseVar(comp)->sys().duDotDu(_var.var(comp)) : (_var.old() ? 0 : 1);
584
586 }
587}
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 617 of file KokkosVariableValue.h.

621{
622 KOKKOS_ASSERT(_var.initialized());
623
624 real3_type grad;
625
626 if (_var.coupled())
627 {
628 KOKKOS_ASSERT(!datum.isNodal());
629
630 auto & elem = datum.elem();
631 auto side = datum.side();
632
633 KOKKOS_ASSERT(comp < _var.components());
634
635 if constexpr (is_ad)
636 grad =
638 ? datum.system(_var.sys(comp))
639 .getVectorQpADGrad(
640 elem, datum.J(qp), datum.qpOffset(), qp, _var.var(comp), _var.tag(), seed)
641 : datum.system(_var.sys(comp))
642 .getVectorQpADGradFace(
643 elem, side, datum.J(qp), qp, _var.var(comp), _var.tag(), seed);
644 else
645 grad =
647 ? datum.system(_var.sys(comp))
648 .getVectorQpGrad(elem, datum.qpOffset() + qp, _var.var(comp), _var.tag())
649 : datum.system(_var.sys(comp))
650 .getVectorQpGradFace(elem, side, datum.J(qp), qp, _var.var(comp), _var.tag());
651 }
652
653 return grad;
654}
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 514 of file KokkosVariableValue.h.

514{ return _var.coupled(); }

◆ operator()() [1/3]

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

Definition at line 537 of file KokkosVariableValue.h.

538 {
539 return this->operator()(datum, qp, _var.components() > 1 ? datum.comp() : 0);
540 }
KOKKOS_FUNCTION unsigned int comp() const
Get the variable component.
KOKKOS_FUNCTION auto operator()(Datum &datum, unsigned int qp, unsigned int comp=0) const
Get the current variable gradient.

◆ operator()() [2/3]

template<bool is_ad>
KOKKOS_FUNCTION auto Moose::Kokkos::VariableGradientTempl< is_ad >::operator() ( AssemblyDatum &  datum,
unsigned int  qp,
unsigned int  comp 
) 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 600 of file KokkosVariableValue.h.

603{
604 if constexpr (is_ad)
605 {
606 Real seed =
607 datum.do_derivatives() && _var.coupled() && _var.sys(comp) == datum.sys() ? _seed[comp] : 0;
608
609 return get(datum, qp, comp, seed);
610 }
611 else
612 return get(datum, qp, comp);
613}
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()() [3/3]

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 523 of file KokkosVariableValue.h.

524 {
525 return get(datum, qp, comp);
526 }

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

◆ 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 591 of file KokkosVariableValue.h.

592{
593 _var = object._var;
594
595 return *this;
596}
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 547 of file KokkosVariableValue.h.

547{ 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 568 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: