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",
39template <
bool is_test>
52 auto & elem = datum.
elem();
53 auto side = datum.
side();
54 auto fe = is_test ? datum.
ife() : datum.
jfe();
62template <
bool is_test>
73 KOKKOS_FUNCTION
const Real3 &
89template <
bool is_test>
90KOKKOS_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();
113template <
bool is_test>
126 auto & elem = datum.
elem();
127 auto side = datum.
side();
128 auto fe = is_test ? datum.
ife() : datum.
jfe();
136template <
bool is_test>
147 KOKKOS_FUNCTION
const Real33 &
163template <
bool is_test>
164KOKKOS_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();
178template <
bool is_test>
191 auto & elem = datum.
elem();
192 auto side = datum.
side();
193 auto fe = is_test ? datum.
ife() : datum.
jfe();
219 using real_type = std::conditional_t<is_ad, ADReal, Real>;
271 KOKKOS_FUNCTION
auto operator()(
Datum & datum,
unsigned int idx,
unsigned int comp = 0)
const
273 return get(datum, idx, comp);
302 get(
Datum & datum,
unsigned int idx,
unsigned int comp = 0, Real seed = 0)
const;
320 : _var(object._var), _seed(object._seed), _dof(object._dof)
350 unsigned int comp)
const
355 datum.
do_derivatives() && _var.coupled() && _var.sys(comp) == datum.
sys() ? _seed[comp] : 0;
357 return get(datum, idx, comp, seed);
360 return get(datum, idx, comp);
368 [[maybe_unused]] Real seed)
const
370 KOKKOS_ASSERT(_var.initialized());
376 auto & sys = datum.
system(_var.sys(comp));
377 auto var = _var.var(comp);
378 auto tag = _var.tag();
388 auto node = datum.
node();
389 dof = sys.getNodeLocalDofIndex(node, 0, var);
393 auto elem = datum.
elem().
id;
394 dof = sys.getElemLocalDofIndex(elem, idx, var);
398 value = sys.getVectorDofADValue(dof, tag, seed);
400 value = sys.getVectorDofValue(dof, tag);
404 auto & elem = datum.
elem();
405 auto side = datum.
side();
409 ? sys.getVectorQpADValue(elem, datum.
qpOffset(), idx, var, tag, seed)
410 : sys.getVectorQpADValueFace(elem, side, idx, var, tag, seed);
413 ? sys.getVectorQpValue(elem, datum.
qpOffset() + idx, var, tag)
414 : sys.getVectorQpValueFace(elem, side, idx, var, tag);
418 value = _var.value(_var.scalar() ? idx : comp);
426 using real3_type = std::conditional_t<is_ad, ADReal3, Real3>;
475 KOKKOS_FUNCTION
auto operator()(
Datum & datum,
unsigned int qp,
unsigned int comp = 0)
const
477 return get(datum, qp, comp);
506 get(
Datum & datum,
unsigned int qp,
unsigned int comp = 0, Real seed = 0)
const;
520 : _var(object._var), _seed(object._seed)
549 unsigned int comp)
const
554 datum.
do_derivatives() && _var.coupled() && _var.sys(comp) == datum.
sys() ? _seed[comp] : 0;
556 return get(datum, qp, comp, seed);
559 return get(datum, qp, comp);
567 [[maybe_unused]] Real seed)
const
569 KOKKOS_ASSERT(_var.initialized());
575 KOKKOS_ASSERT(!datum.
isNodal());
577 auto & elem = datum.
elem();
578 auto side = datum.
side();
583 ? datum.
system(_var.sys(comp))
585 elem, datum.
J(qp), datum.
qpOffset(), qp, _var.var(comp), _var.tag(), seed)
586 : datum.
system(_var.sys(comp))
588 elem, side, datum.
J(qp), qp, _var.var(comp), _var.tag(), seed);
592 ? datum.
system(_var.sys(comp))
594 : datum.
system(_var.sys(comp))
650 unsigned int comp = 0)
const;
710 unsigned int comp = 0)
const;
762 unsigned int comp = 0)
const;
777KOKKOS_FUNCTION
inline Real3
778VectorVariableValue::operator()(
AssemblyDatum & datum,
unsigned int idx,
unsigned int comp)
const
796 auto node = datum.
node();
798 for (
unsigned int c = 0; c < dimension; ++c)
799 value(c) = sys.getVectorDofValue(sys.getNodeLocalDofIndex(node, c, var), tag);
803 auto elem = datum.
elem().
id;
804 auto offset = idx * dimension;
806 for (
unsigned int c = 0; c < dimension; ++c)
807 value(c) = sys.getVectorDofValue(sys.getElemLocalDofIndex(elem, offset + c, var), tag);
812 KOKKOS_ASSERT(!datum.
isNodal());
814 auto & elem = datum.
elem();
815 auto side = datum.
side();
818 value = sys.getVectorQpVectorValue(elem, datum.
qpOffset() + idx, var, tag);
820 value = sys.getVectorQpVectorValueFace(elem, side, idx, var, tag);
829KOKKOS_FUNCTION
inline Real33
830VectorVariableGradient::operator()(
AssemblyDatum & datum,
unsigned int qp,
unsigned int comp)
const
838 KOKKOS_ASSERT(!datum.
isNodal());
840 auto & elem = datum.
elem();
841 auto side = datum.
side();
847 grad = sys.getVectorQpVectorGrad(elem, datum.
qpOffset() + qp, var, tag);
849 grad = sys.getVectorQpVectorGradFace(elem, side, datum.
J(qp), qp, var, tag);
855KOKKOS_FUNCTION
inline Real3
856VectorVariableCurl::operator()(
AssemblyDatum & datum,
unsigned int qp,
unsigned int comp)
const
864 KOKKOS_ASSERT(!datum.
isNodal());
866 auto & elem = datum.
elem();
867 auto side = datum.
side();
873 curl = sys.getVectorQpVectorCurl(elem, datum.
qpOffset() + qp, var, tag);
876 auto fe = sys.getFETypeID(var);
879 auto jacobian = datum.
J(qp);
880 auto jacobian_transpose = jacobian.
transpose();
883 for (
unsigned int i = 0; i < n_dofs; ++i)
884 grad += sys.getVectorDofValue(sys.getElemLocalDofIndex(elem.id, i, var), tag) *
885 (grad_phi(i, qp) * jacobian_transpose);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
SystemBase & sys()
Get the system this variable is part of.
This class provides an interface for common operations on field variables of both FE and FV types wit...
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.
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels.
KOKKOS_FUNCTION unsigned int sys() const
Get the system number of variable.
KOKKOS_FUNCTION unsigned int jfe() const
Get the coupled variable FE type ID.
KOKKOS_FUNCTION void do_derivatives(const bool flag)
Set whether to compute derivatives for automatic differentiation (AD)
KOKKOS_FUNCTION unsigned int ife() const
Get the variable FE type ID.
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 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.
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 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 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 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 unsigned int getDimension() const
Get the mesh dimension.
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.
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.
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.
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object.
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 ContiguousNodeID node() const
Get the contiguous node ID.
KOKKOS_FUNCTION dof_id_type qpOffset() const
Get the starting offset into the global quadrature point index.
KOKKOS_FUNCTION const Assembly & assembly() const
Get the Kokkos assembly.
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 ADReal3 getVectorQpADGradFace(const ElementInfo info, const unsigned int side, const Real33 jacobian, const unsigned int qp, const unsigned int var, const TagID tag, const Real seed) const
Get the face quadrature point gradient of a variable from a tagged vector for automatic differentiati...
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.
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
KOKKOS_FUNCTION dof_id_type getScalarLocalDofIndex(unsigned int i, unsigned int var) const
Get the local DOF index of a scalar variable.
VariableGradientTempl()=default
Default constructor.
KOKKOS_FUNCTION auto operator()(Datum &datum, unsigned int qp, unsigned int comp=0) const
Get the current variable gradient.
Array< Real > _seed
Derivative seed of each component for AD.
VariableGradientTempl(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
KOKKOS_FUNCTION auto get(Datum &datum, unsigned int qp, unsigned int comp=0, Real seed=0) const
Get the current variable gradient.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
VariableGradientTempl< is_ad > & operator=(const VariableGradientTempl< is_ad > &object)
Copy assignment operator.
Variable _var
Coupled Kokkos variable.
VariableGradientTempl(Variable var)
Constructor.
std::conditional_t< is_ad, ADReal3, Real3 > real3_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 Real3 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the gradient of the current shape function.
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.
The Kokkos wrapper classes for MOOSE-like variable value access.
bool _dof
Flag whether DOF values are requested.
KOKKOS_FUNCTION auto get(Datum &datum, unsigned int idx, unsigned int comp=0, Real seed=0) const
Get the current variable value.
std::conditional_t< is_ad, ADReal, Real > real_type
VariableValueTempl(const MooseVariableBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
Constructor.
VariableValueTempl()=default
Default constructor.
KOKKOS_FUNCTION auto operator()(Datum &datum, unsigned int idx, unsigned int comp=0) const
Get the current variable value.
VariableValueTempl(Variable var, bool dof=false)
Constructor.
Variable _var
Coupled Kokkos variable.
Array< Real > _seed
Derivative seed of each component for AD.
VariableValueTempl< is_ad > & operator=(const VariableValueTempl< is_ad > &object)
Copy assignment operator.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
The Kokkos variable object that carries the coupled variable and tag information.
KOKKOS_FUNCTION unsigned int components() const
Get the number of components.
KOKKOS_FUNCTION bool vector() const
Get whether the variable is vector variable.
KOKKOS_FUNCTION bool old() const
Get whether the tag is old/older value.
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 TagID tag() const
Get the vector tag ID.
KOKKOS_FUNCTION Real3 vectorValue(unsigned int comp=0) const
Get the default vector value of a component.
KOKKOS_FUNCTION bool dot() const
Get whether the tag is time derivative.
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.
VectorVariableCurl(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int qp, unsigned int comp=0) const
Get the current vector variable curl.
VectorVariableCurl(Variable var)
Constructor.
VectorVariableCurl()=default
Default constructor.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
Variable _var
Coupled Kokkos variable.
Variable _var
Coupled Kokkos variable.
VectorVariableGradient()=default
Default constructor.
KOKKOS_FUNCTION Real33 operator()(AssemblyDatum &datum, unsigned int qp, unsigned int comp=0) const
Get the current vector variable gradient.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
VectorVariableGradient(Variable var)
Constructor.
VectorVariableGradient(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the curl of the current vector shape function.
KOKKOS_FUNCTION Real33 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the gradient of the current vector shape function.
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.
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int i, unsigned int qp) const
Get the current vector shape function.
VectorVariableValue(Variable var, bool dof=false)
Constructor.
KOKKOS_FUNCTION Real3 operator()(AssemblyDatum &datum, unsigned int idx, unsigned int comp=0) const
Get the current vector variable value.
VectorVariableValue(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
Constructor.
bool _dof
Flag whether DOF values are requested.
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
Variable _var
Coupled Kokkos variable.
VectorVariableValue()=default
Default constructor.
virtual const Number & duDotDu(unsigned int var_num=0) const
VariableShapeValue< true > VariableTestValue
VariableShapeGradient< false > VariablePhiGradient
KOKKOS_INLINE_FUNCTION Real3 curlFromVectorGradient(const Real33 grad, const unsigned int dim)
void checkVariable(const Variable &var, bool expect_vector, const std::string &wrapper_name)
VariableShapeValue< false > VariablePhiValue
VariableShapeGradient< true > VariableTestGradient
const TagName SOLUTION_TAG
const unsigned int invalid_uint
The type trait that determines the default behavior of copy constructor and deepCopy() If this type t...
static constexpr bool value
ContiguousElementID id
Contiguous element ID.
KOKKOS_INLINE_FUNCTION Real33 transpose() const