25 mooseError(
"Attempted to construct Kokkos ", wrapper_name,
" with an uninitialized variable.");
27 if (var.
vector() != expect_vector)
30 " cannot be constructed with ",
31 var.
vector() ?
"vector" :
"scalar",
38 template <
bool is_test>
52 auto & elem = datum.
elem();
53 auto side = datum.
side();
54 auto fe = is_test ? datum.
ife() : datum.
jfe();
62 template <
bool is_test>
73 KOKKOS_FUNCTION
const Real3 &
89 template <
bool is_test>
90 KOKKOS_FUNCTION
const Real3 &
93 unsigned int qp)
const 95 auto & elem = datum.
elem();
96 auto side = datum.
side();
97 auto fe = is_test ? datum.
ife() : datum.
jfe();
113 template <
bool is_test>
126 auto & elem = datum.
elem();
127 auto side = datum.
side();
128 auto fe = is_test ? datum.
ife() : datum.
jfe();
136 template <
bool is_test>
147 KOKKOS_FUNCTION
const Real33 &
163 template <
bool is_test>
164 KOKKOS_FUNCTION
const Real33 &
167 unsigned int qp)
const 169 auto & elem = datum.
elem();
170 auto side = datum.
side();
171 auto fe = is_test ? datum.
ife() : datum.
jfe();
178 template <
bool is_test>
191 auto & elem = datum.
elem();
192 auto side = datum.
side();
193 auto fe = is_test ? datum.
ife() : datum.
jfe();
215 template <
bool is_ad>
219 using real_type = std::conditional_t<is_ad, ADReal, Real>;
293 KOKKOS_FUNCTION
auto operator()(
Datum & datum,
unsigned int idx,
unsigned int comp = 0)
const 295 return get(datum,
idx, comp);
324 get(
Datum & datum,
unsigned int idx,
unsigned int comp = 0,
Real seed = 0)
const;
340 template <
bool is_ad>
342 : _var(object._var), _seed(object._seed), _dof(object._dof)
358 template <
bool is_ad>
368 template <
bool is_ad>
372 unsigned int comp)
const 377 datum.
do_derivatives() && _var.coupled() && _var.sys(comp) == datum.
sys() ? _seed[comp] : 0;
379 return get(datum,
idx, comp, seed);
382 return get(datum,
idx, comp);
385 template <
bool is_ad>
390 [[maybe_unused]] Real seed)
const 392 KOKKOS_ASSERT(_var.initialized());
398 auto & sys = datum.
system(_var.sys(comp));
399 auto var = _var.var(comp);
400 auto tag = _var.tag();
408 auto node = datum.
node();
409 dof = sys.getNodeLocalDofIndex(node, 0, var);
413 auto elem = datum.
elem().
id;
414 dof = sys.getElemLocalDofIndex(elem,
idx, var);
418 value = sys.getVectorDofADValue(dof, tag, seed);
420 value = sys.getVectorDofValue(dof, tag);
424 auto & elem = datum.
elem();
425 auto side = datum.
side();
429 ? sys.getVectorQpADValue(elem, datum.
qpOffset(),
idx, var, tag, seed)
430 : sys.getVectorQpADValueFace(elem, side,
idx, var, tag, seed);
433 ? sys.getVectorQpValue(elem, datum.
qpOffset() +
idx, var, tag)
434 : sys.getVectorQpValueFace(elem, side,
idx, var, tag);
438 value = _var.value(comp);
443 template <
bool is_ad>
446 using real3_type = std::conditional_t<is_ad, ADReal3, Real3>;
514 KOKKOS_FUNCTION
auto operator()(
Datum & datum,
unsigned int qp,
unsigned int comp = 0)
const 516 return get(datum, qp, comp);
545 get(
Datum & datum,
unsigned int qp,
unsigned int comp = 0,
Real seed = 0)
const;
557 template <
bool is_ad>
559 : _var(object._var), _seed(object._seed)
575 template <
bool is_ad>
584 template <
bool is_ad>
588 unsigned int comp)
const 593 datum.
do_derivatives() && _var.coupled() && _var.sys(comp) == datum.
sys() ? _seed[comp] : 0;
595 return get(datum, qp, comp, seed);
598 return get(datum, qp, comp);
601 template <
bool is_ad>
606 [[maybe_unused]] Real seed)
const 608 KOKKOS_ASSERT(_var.initialized());
614 KOKKOS_ASSERT(!datum.
isNodal());
616 auto & elem = datum.
elem();
617 auto side = datum.
side();
622 ? datum.
system(_var.sys(comp))
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);
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());
689 unsigned int comp = 0)
const;
749 unsigned int comp = 0)
const;
801 unsigned int comp = 0)
const;
816 KOKKOS_FUNCTION
inline Real3 835 auto node = datum.
node();
837 for (
unsigned int c = 0; c < dimension; ++c)
838 value(c) = sys.getVectorDofValue(sys.getNodeLocalDofIndex(node, c, var), tag);
842 auto elem = datum.
elem().
id;
843 auto offset =
idx * dimension;
845 for (
unsigned int c = 0; c < dimension; ++c)
846 value(c) = sys.getVectorDofValue(sys.getElemLocalDofIndex(elem, offset + c, var), tag);
851 KOKKOS_ASSERT(!datum.
isNodal());
853 auto & elem = datum.
elem();
854 auto side = datum.
side();
859 value = sys.getVectorQpVectorValueFace(elem, side,
idx, var, tag);
868 KOKKOS_FUNCTION
inline Real33 877 KOKKOS_ASSERT(!datum.
isNodal());
879 auto & elem = datum.
elem();
880 auto side = datum.
side();
886 grad = sys.getVectorQpVectorGrad(elem, datum.
qpOffset() + qp, var, tag);
888 grad = sys.getVectorQpVectorGradFace(elem, side, datum.
J(qp), qp, var, tag);
894 KOKKOS_FUNCTION
inline Real3 903 KOKKOS_ASSERT(!datum.
isNodal());
905 auto & elem = datum.
elem();
906 auto side = datum.
side();
912 curl = sys.getVectorQpVectorCurl(elem, datum.
qpOffset() + qp, var, tag);
915 auto fe = sys.getFETypeID(var);
918 auto jacobian = datum.
J(qp);
919 auto jacobian_transpose = jacobian.
transpose();
922 for (
unsigned int i = 0; i < n_dofs; ++i)
923 grad += sys.getVectorDofValue(sys.getElemLocalDofIndex(elem.id, i, var), tag) *
924 (grad_phi(i, qp) * jacobian_transpose);
KOKKOS_FUNCTION const auto & getPhi(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the shape functions of a FE type for an element type and subdomain.
void checkVariable(const Variable &var, bool expect_vector, const std::string &wrapper_name)
KOKKOS_FUNCTION bool old() const
Get whether the tag is old/older value.
KOKKOS_FUNCTION TagID tag() const
Get the vector tag ID.
KOKKOS_FUNCTION auto get(Datum &datum, unsigned int qp, unsigned int comp=0, Real seed=0) const
Get the current variable gradient.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
KOKKOS_FUNCTION const Real33 & reference(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the gradient of the current vector shape function in reference space.
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
bool _dof
Flag whether DOF values are requested.
VectorVariableValue()=default
Default constructor.
const unsigned int invalid_uint
VariableGradientTempl()=default
Default constructor.
VariableGradientTempl(const std::vector< MooseVariableFieldBase *> &vars, const TagName &tag=Moose::SOLUTION_TAG)
Array< Real > _seed
Derivative seed of each component for AD.
VectorVariableCurl(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
VariableValueTempl(const std::vector< MooseVariableFieldBase *> &vars, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
KOKKOS_FUNCTION auto operator()(Datum &datum, unsigned int idx, unsigned int comp=0) const
Get the current variable value.
KOKKOS_FUNCTION Real3 vectorValue(unsigned int comp=0) const
Get the default vector value of a component.
KOKKOS_FUNCTION bool vector() const
Get whether the variable is vector variable.
Variable _var
Coupled Kokkos variable.
KOKKOS_FUNCTION const auto & getVectorPhiFace(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the face vector shape functions of a FE type for an element type and subdomain.
KOKKOS_FUNCTION unsigned int getDimension() const
Get the mesh dimension.
KOKKOS_FUNCTION void do_derivatives(const bool flag)
Set whether to compute derivatives for automatic differentiation (AD)
KOKKOS_FUNCTION unsigned int sys() const
Get the system number of variable.
KOKKOS_FUNCTION const FESystem & system(unsigned int sys) const
Get the Kokkos system.
KOKKOS_FUNCTION const auto & getGradPhiFace(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the gradient of face shape functions of a FE type for an element type and subdomain.
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 const auto & getGradPhi(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the gradient of shape functions of a FE type for an element type and subdomain.
KOKKOS_FUNCTION Real33 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the gradient of the current vector shape function.
KOKKOS_FUNCTION bool initialized() const
Get whether the variable is initialized.
This class provides an interface for common operations on field variables of both FE and FV types wit...
KOKKOS_FUNCTION unsigned int getNumDofs(unsigned int elem_type, unsigned int fe_type) const
Get the number of DOFs of a FE type for an element type.
KOKKOS_FUNCTION const Real3 & reference(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the gradient of the current shape function in reference space.
KOKKOS_FUNCTION bool dot() const
Get whether the tag is time derivative.
KOKKOS_FUNCTION const auto & getPhiFace(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the face shape functions of a FE type for an element type and subdomain.
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 side() const
Get the side index.
KOKKOS_FUNCTION bool coupled() const
Get whether the variable is coupled.
std::conditional_t< is_ad, ADReal3, Real3 > real3_type
Variable _var
Coupled Kokkos variable.
KOKKOS_FUNCTION bool isAlloc() const
Get whether the array was allocated either on host or device.
KOKKOS_FUNCTION const auto & getVectorPhi(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the vector shape functions of a FE type for an element type and subdomain.
Variable _var
Coupled Kokkos variable.
KOKKOS_FUNCTION const auto & getVectorGradPhiFace(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the gradient of face vector shape functions of a FE type for an element type and subdomain...
virtual const Number & duDotDu(unsigned int var_num=0) const
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
KOKKOS_FUNCTION unsigned int jfe() const
Get the coupled variable FE type ID.
VectorVariableValue(Variable var, bool dof=false)
Constructor.
KOKKOS_FUNCTION const auto & getVectorGradPhi(ContiguousSubdomainID subdomain, unsigned int elem_type, unsigned int fe_type) const
Get the gradient of vector shape functions of a FE type for an element type and subdomain.
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int idx, unsigned int comp=0) const
Get the current vector variable value.
VariableShapeValue< true > VariableTestValue
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the gradient of the current shape function.
KOKKOS_INLINE_FUNCTION Real3 curlFromVectorGradient(const Real33 grad, const unsigned int dim)
VariableGradientTempl< is_ad > & operator=(const VariableGradientTempl< is_ad > &object)
Copy assignment operator.
VectorVariableGradient(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
void create(const std::vector< index_type > &n)
Allocate array on host and device.
VectorVariableCurl(Variable var)
Constructor.
KOKKOS_FUNCTION const Assembly & assembly() const
Get the Kokkos assembly.
VariableValueTempl()=default
Default constructor.
The Kokkos wrapper classes for MOOSE-like variable value access.
void copyToDevice()
Copy data from host to device.
KOKKOS_INLINE_FUNCTION Real33 transpose() const
std::conditional_t< is_ad, ADReal, Real > real_type
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the curl of the current vector shape function.
VariableShapeGradient< true > VariableTestGradient
The type trait that determines the default behavior of copy constructor and deepCopy() If this type t...
VariableShapeGradient< false > VariablePhiGradient
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
KOKKOS_FUNCTION ContiguousNodeID node() const
Get the contiguous node ID.
VariableValueTempl(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
Constructor.
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int qp, unsigned int comp=0) const
Get the current vector variable curl.
VectorVariableValue(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
Constructor.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
VariableValueTempl(Variable var, bool dof=false)
Constructor.
Variable _var
Coupled Kokkos variable.
VariableValueTempl< is_ad > & operator=(const VariableValueTempl< is_ad > &object)
Copy assignment operator.
KOKKOS_FUNCTION bool isNodal() const
Get whether the current datum is on a node.
The Kokkos variable object that carries the coupled variable and tag information. ...
const MooseVariableFieldBase * mooseVar(unsigned int comp=0)
Get the MOOSE variable of a component.
KOKKOS_FUNCTION Real33 operator()(AssemblyDatum &datum, unsigned int qp, unsigned int comp=0) const
Get the current vector variable gradient.
KOKKOS_FUNCTION unsigned int ife() const
Get the variable FE type ID.
Variable _var
Coupled Kokkos variable.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
VariableShapeValue< false > VariablePhiValue
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the current vector shape function.
KOKKOS_FUNCTION auto get(Datum &datum, unsigned int idx, unsigned int comp=0, Real seed=0) const
Get the current variable value.
VariableGradientTempl(Variable var)
Constructor.
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels...
const TagName SOLUTION_TAG
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
bool _dof
Flag whether DOF values are requested.
VectorVariableGradient(Variable var)
Constructor.
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
KOKKOS_FUNCTION dof_id_type qpOffset() const
Get the starting offset into the global quadrature point index.
SystemBase & sys()
Get the system this variable is part of.
KOKKOS_FUNCTION auto operator()(Datum &datum, unsigned int qp, unsigned int comp=0) const
Get the current variable gradient.
The Kokkos wrapper classes for MOOSE-like shape function access.
KOKKOS_FUNCTION Real operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the current shape function.
static constexpr bool value
ContiguousElementID id
Contiguous element ID.
VariableGradientTempl(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
VectorVariableGradient()=default
Default constructor.
VectorVariableCurl()=default
Default constructor.