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>;
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;
342 : _var(object._var), _seed(object._seed), _dof(object._dof)
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);
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);
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;
559 : _var(object._var), _seed(object._seed)
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);
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))
627 elem, side, datum.
J(qp), qp, _var.var(comp), _var.tag(), seed);
631 ? datum.
system(_var.sys(comp))
633 : datum.
system(_var.sys(comp))
689 unsigned int comp = 0)
const;
749 unsigned int comp = 0)
const;
801 unsigned int comp = 0)
const;
816KOKKOS_FUNCTION
inline Real3
817VectorVariableValue::operator()(
AssemblyDatum & datum,
unsigned int idx,
unsigned int comp)
const
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();
857 value = sys.getVectorQpVectorValue(elem, datum.
qpOffset() + idx, var, tag);
859 value = sys.getVectorQpVectorValueFace(elem, side, idx, var, tag);
868KOKKOS_FUNCTION
inline Real33
869VectorVariableGradient::operator()(
AssemblyDatum & datum,
unsigned int qp,
unsigned int comp)
const
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);
894KOKKOS_FUNCTION
inline Real3
895VectorVariableCurl::operator()(
AssemblyDatum & datum,
unsigned int qp,
unsigned int comp)
const
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);
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.
VariableGradientTempl(const std::vector< MooseVariableFieldBase * > &vars, const TagName &tag=Moose::SOLUTION_TAG)
VariableGradientTempl()=default
Default constructor.
KOKKOS_FUNCTION auto operator()(Datum &datum, unsigned int qp, unsigned int comp=0) const
Get the current variable gradient.
VariableGradientTempl(const std::vector< const MooseVariableFieldBase * > &vars, const TagName &tag=Moose::SOLUTION_TAG)
Constructor.
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()=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.
VariableValueTempl(const std::vector< const MooseVariableFieldBase * > &vars, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
Constructor.
Array< Real > _seed
Derivative seed of each component for AD.
VariableValueTempl< is_ad > & operator=(const VariableValueTempl< is_ad > &object)
Copy assignment operator.
VariableValueTempl(const MooseVariableFieldBase &var, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
Constructor.
VariableValueTempl(const std::vector< MooseVariableFieldBase * > &vars, const TagName &tag=Moose::SOLUTION_TAG, bool dof=false)
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.
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.
const MooseVariableFieldBase * mooseVar(unsigned int comp=0)
Get the MOOSE variable of a component.
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