65 mooseError(
"computeOffDiagJacobian() is not used for Kokkos residual objects.");
130 const unsigned int i,
131 const unsigned int comp = 0)
const;
142 const unsigned int comp = 0)
const;
154 const unsigned int i,
155 const unsigned int j,
156 const unsigned int jvar,
157 const unsigned int comp = 0)
const;
168 const unsigned int i,
169 const unsigned int comp = 0)
const;
181 const unsigned int jvar,
182 const unsigned int comp = 0)
const;
194 const unsigned int comp = 0)
const;
201 template <
typename function>
208 template <
typename function>
221 KOKKOS_FUNCTION
inline void 224 const unsigned int i,
225 const unsigned int comp)
const 237 if (sys.isResidualTagActive(tag))
238 ::Kokkos::atomic_add(&sys.getVectorDofValue(dof, tag), local_re);
242 KOKKOS_FUNCTION
inline void 246 const unsigned int comp)
const 248 if (!local_re && add)
258 if (sys.isResidualTagActive(tag))
261 sys.getVectorDofValue(dof, tag) += local_re;
263 sys.getVectorDofValue(dof, tag) = local_re;
268 KOKKOS_FUNCTION
inline void 271 const unsigned int i,
272 const unsigned int j,
273 const unsigned int jvar,
274 const unsigned int comp)
const 281 auto col = sys.getElemGlobalDofIndex(elem, j, jvar);
287 if (sys.isMatrixTagActive(tag) && !sys.hasNodalBCMatrixTag(row, tag))
288 ::Kokkos::atomic_add(&sys.getMatrixValue(row, col, tag), local_ke);
292 KOKKOS_FUNCTION
inline void 295 const unsigned int i,
296 const unsigned int comp)
const 305 if (sys.isMatrixTagActive(tag) && !sys.hasNodalBCMatrixTag(row, tag))
306 for (
unsigned int j = 0; j < local_ke.size(); ++j)
308 auto col = local_ke.raw_index(j);
310 ::Kokkos::atomic_add(&sys.getMatrixValue(row, col, tag), local_ke.raw_at(j));
315 KOKKOS_FUNCTION
inline void 319 const unsigned int jvar,
320 const unsigned int comp)
const 322 if (!local_ke && add)
327 auto col = sys.getNodeGlobalDofIndex(node, jvar);
333 if (sys.isMatrixTagActive(tag))
335 auto & matrix = sys.getMatrix(tag);
338 matrix(row, col) += local_ke;
342 matrix(row, col) = local_ke;
348 KOKKOS_FUNCTION
inline void 352 const unsigned int comp)
const 360 auto & matrix = sys.getMatrix(tag);
362 if (sys.isMatrixTagActive(tag))
367 for (
unsigned int j = 0; j < local_ke.size(); ++j)
369 auto col = local_ke.raw_index(j);
372 matrix(row, col) += local_ke.raw_at(j);
374 matrix(row, col) = local_ke.raw_at(j);
380 template <
typename function>
387 unsigned int num_batches = datum.
n_dofs() / stride;
389 if (datum.
n_dofs() % stride)
392 for (
unsigned int batch = 0; batch < num_batches; ++batch)
394 unsigned int ib = batch * stride;
397 const unsigned int n = ie - ib;
402 ib += t * d + (t < m ? t : m);
403 ie = ib + d + (t < m ? 1 : 0);
405 for (
unsigned int i = ib; i < ie; ++i)
406 local_re[i - ib] = 0;
408 body(local_re - ib, ib, ie);
410 for (
unsigned int i = ib; i < ie; ++i)
415 template <
typename function>
429 for (
unsigned int batch = 0; batch < num_batches; ++batch)
434 for (
unsigned int i = ib; i < ie; ++i)
435 local_ke[i - ib] = 0;
437 body(local_ke - ib, ib, ie, j);
439 for (
unsigned int i = ib; i < ie; ++i)
KOKKOS_FUNCTION dof_id_type getElemLocalDofIndex(ContiguousElementID elem, unsigned int i, unsigned int var) const
Get the local DOF index of a variable for an element.
Scalar< Real > _dt_old
Size of the old time step.
KOKKOS_FUNCTION dof_id_type getNodeLocalDofIndex(ContiguousNodeID node, unsigned int i, unsigned int var) const
Get the local DOF index of a variable for a node.
std::unique_ptr< DispatcherBase > _jacobian_dispatcher
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
KOKKOS_FUNCTION void computeJacobianInternal(AssemblyDatum &datum, function body) const
The common loop structure template for computing elemental Jacobian.
Scalar< Real > _t
TODO: Move to TransientInterface.
dof_id_type ContiguousElementID
KOKKOS_FUNCTION unsigned int num_local_threads() const
Get the number of local threads.
const InputParameters & parameters() const
Get the parameters of the object.
ResidualObject(const InputParameters ¶meters, Moose::VarFieldType field_type, bool nodal=false)
Constructor.
KOKKOS_FUNCTION void accumulateTaggedNodalResidual(const bool add, const Real local_re, const ContiguousNodeID node, const unsigned int comp=0) const
Accumulate or set local nodal residual contribution to tagged vectors.
virtual void computeOffDiagJacobian(unsigned int) override final
Computes this object's contribution to off-diagonal blocks of the system Jacobian matrix...
The base class for Kokkos residual objects.
Thread _thread
Kokkos thread object.
KOKKOS_FUNCTION unsigned int jvar() const
Get the coupled variable number.
MooseVariableFieldBase & _var
Reference of the MOOSE variable.
This class provides an interface for common operations on field variables of both FE and FV types wit...
The Kokkos interface that holds the host reference of the Kokkos systems and copies it to device duri...
KOKKOS_FUNCTION unsigned int n_jdofs() const
Get the number of local DOFs for the coupled variable.
The Kokkos interface that holds the host reference of the Kokkos mesh and copies it to device during ...
KOKKOS_FUNCTION void accumulateTaggedElementalMatrix(const Real local_ke, const ContiguousElementID elem, const unsigned int i, const unsigned int j, const unsigned int jvar, const unsigned int comp=0) const
Accumulate local elemental Jacobian contribution to tagged matrices.
dof_id_type ContiguousNodeID
KOKKOS_FUNCTION unsigned int n_idofs() const
Get the number of local DOFs.
virtual void computeResidual()=0
Compute this object's contribution to the residual.
KOKKOS_FUNCTION const System & kokkosSystem(unsigned int sys) const
Get the const reference of a Kokkos system.
The Kokkos interface that holds the host reference of the Kokkos assembly and copies it to device dur...
KOKKOS_FUNCTION unsigned int local_thread_id() const
Get the current local thread ID.
virtual void computeJacobian()=0
Compute this object's contribution to the diagonal Jacobian entries.
KOKKOS_FUNCTION index_type size() const
Get the total array size.
Scalar< const Real > _t_old
Old time.
KokkosSemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
Scalar< int > _t_step
The number of the time step.
std::unique_ptr< DispatcherBase > _offdiag_jacobian_dispatcher
constexpr unsigned int MAX_CACHED_DOF
Maximum number of DOFs to cache during residual and Jacobian computation.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Kokkos variable object that carries the coupled variable and tag information. ...
KOKKOS_FUNCTION void accumulateTaggedElementalResidual(const Real local_re, const ContiguousElementID elem, const unsigned int i, const unsigned int comp=0) const
Accumulate local elemental residual contribution to tagged vectors.
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels...
Scalar< Real > _dt
Time step size.
Variable _kokkos_var
Kokkos variable.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
std::unique_ptr< DispatcherBase > _residual_dispatcher
Kokkos functor dispatchers.
KOKKOS_FUNCTION unsigned int n_dofs() const
Get the number of local DOFs.
auto min(const L &left, const R &right)
static InputParameters validParams()
Array< TagID > _vector_tags
Tags this object operates on.
KOKKOS_FUNCTION void computeResidualInternal(AssemblyDatum &datum, function body) const
The common loop structure template for computing elemental residual.
KOKKOS_FUNCTION void accumulateTaggedNodalMatrix(const bool add, const Real local_ke, const ContiguousNodeID node, const unsigned int jvar, const unsigned int comp=0) const
Accumulate or set local nodal Jacobian contribution to tagged matrices.
Array< TagID > _matrix_tags
The Kokkos thread object that aids in converting the one-dimensional thread index into multi-dimensio...
virtual void computeResidualAndJacobian() override
Compute this object's contribution to the residual and Jacobian simultaneously.
virtual const MooseVariableBase & variable() const override
Returns the variable that this object operates on.
ContiguousElementID id
Contiguous element ID.