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 Variablevariable () 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)
 

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 444 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 446 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 457 of file KokkosVariableValue.h.

457 : _var(var)
458 {
459 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
460 }
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 466 of file KokkosVariableValue.h.

468 : _var(var, tag)
469 {
470 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
471 }

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

480 : _var(vars, tag)
481 {
482 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
483 }
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 484 of file KokkosVariableValue.h.

486 : _var(vars, tag)
487 {
488 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
489 }

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

559 : _var(object._var), _seed(object._seed)
560{
561 if constexpr (is_ad)
562 if (_var.coupled())
563 {
564 if (!_seed.isAlloc())
566
567 for (unsigned int comp = 0; comp < _var.components(); ++comp)
568 _seed[comp] =
569 _var.dot() ? _var.mooseVar(comp)->sys().duDotDu(_var.var(comp)) : (_var.old() ? 0 : 1);
570
572 }
573}
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.
KOKKOS_FUNCTION bool dot() const
Get whether the tag is time derivative.
const MooseVariableFieldBase * mooseVar(unsigned int comp=0)
Get the MOOSE variable of a component.
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 603 of file KokkosVariableValue.h.

607{
608 KOKKOS_ASSERT(_var.initialized());
609
610 real3_type grad;
611
612 if (_var.coupled())
613 {
614 KOKKOS_ASSERT(!datum.isNodal());
615
616 auto & elem = datum.elem();
617 auto side = datum.side();
618
619 if constexpr (is_ad)
620 grad =
622 ? datum.system(_var.sys(comp))
623 .getVectorQpADGrad(
624 elem, datum.J(qp), datum.qpOffset(), qp, _var.var(comp), _var.tag(), seed)
625 : datum.system(_var.sys(comp))
626 .getVectorQpADGradFace(
627 elem, side, datum.J(qp), qp, _var.var(comp), _var.tag(), seed);
628 else
629 grad =
631 ? datum.system(_var.sys(comp))
632 .getVectorQpGrad(elem, datum.qpOffset() + qp, _var.var(comp), _var.tag())
633 : datum.system(_var.sys(comp))
634 .getVectorQpGradFace(elem, side, datum.J(qp), qp, _var.var(comp), _var.tag());
635 }
636
637 return grad;
638}
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 505 of file KokkosVariableValue.h.

505{ 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 586 of file KokkosVariableValue.h.

589{
590 if constexpr (is_ad)
591 {
592 Real seed =
593 datum.do_derivatives() && _var.coupled() && _var.sys(comp) == datum.sys() ? _seed[comp] : 0;
594
595 return get(datum, qp, comp, seed);
596 }
597 else
598 return get(datum, qp, comp);
599}
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 514 of file KokkosVariableValue.h.

515 {
516 return get(datum, qp, comp);
517 }

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

578{
579 _var = object._var;
580
581 return *this;
582}
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 533 of file KokkosVariableValue.h.

533{ 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 554 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: