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

464 : _var(var)
465 {
466 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
467 }
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 473 of file KokkosVariableValue.h.

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

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

487 : _var(vars, tag)
488 {
489 checkVariable(_var, false, is_ad ? "ADVariableGradient" : "VariableGradient");
490 }
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 491 of file KokkosVariableValue.h.

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

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

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

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

512{ 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 535 of file KokkosVariableValue.h.

536 {
537 return this->operator()(datum, qp, datum.comp());
538 }
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 598 of file KokkosVariableValue.h.

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

522 {
523 return get(datum, qp, comp);
524 }

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

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

545{ 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 566 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: