75 mooseError(
"computeOffDiagJacobian() is not used for Kokkos residual objects.");
146 const unsigned int i,
147 const unsigned int comp = 0)
const;
158 const unsigned int comp = 0)
const;
169 const unsigned int i)
const;
181 const unsigned int i,
182 const unsigned int j,
183 const unsigned int jvar,
184 const unsigned int comp = 0)
const;
195 const unsigned int i,
196 const unsigned int comp = 0)
const;
208 const unsigned int jvar,
209 const unsigned int comp = 0)
const;
222 const unsigned int i,
223 const unsigned int j,
224 const unsigned int jvar)
const;
236 const unsigned int comp = 0)
const;
243 template <
typename function>
250 template <
typename function>
263KOKKOS_FUNCTION
inline void
266 const unsigned int i,
267 const unsigned int comp)
const
273 auto dof = sys.getElemLocalDofIndex(elem, i,
_kokkos_var.
var(comp));
279 if (sys.isResidualTagActive(tag))
280 ::Kokkos::atomic_add(&sys.getVectorDofValue(dof, tag), local_re);
284KOKKOS_FUNCTION
inline void
288 const unsigned int comp)
const
290 if (!local_re && add)
294 auto dof = sys.getNodeLocalDofIndex(node, 0,
_kokkos_var.
var(comp));
300 if (sys.isResidualTagActive(tag))
303 sys.getVectorDofValue(dof, tag) += local_re;
305 sys.getVectorDofValue(dof, tag) = local_re;
310KOKKOS_FUNCTION
inline void
314 const unsigned int i)
const
316 if (!local_re && add)
326 if (sys.isResidualTagActive(tag))
329 sys.getVectorDofValue(dof, tag) += local_re;
331 sys.getVectorDofValue(dof, tag) = local_re;
336KOKKOS_FUNCTION
inline void
339 const unsigned int i,
340 const unsigned int j,
341 const unsigned int jvar,
342 const unsigned int comp)
const
348 auto row = sys.getElemLocalDofIndex(elem, i,
_kokkos_var.
var(comp));
349 auto col = sys.isScalarVariable(jvar) ? sys.getScalarGlobalDofIndex(j, jvar)
350 : sys.getElemGlobalDofIndex(elem, j, jvar);
356 if (sys.isMatrixTagActive(tag) && !sys.hasNodalBCMatrixTag(row, tag))
357 ::Kokkos::atomic_add(&sys.getMatrixValue(row, col, tag), local_ke);
361KOKKOS_FUNCTION
inline void
364 const unsigned int i,
365 const unsigned int comp)
const
374 if (sys.isMatrixTagActive(tag) && !sys.hasNodalBCMatrixTag(row, tag))
375 for (
unsigned int j = 0; j < local_ke.size(); ++j)
377 auto col = local_ke.raw_index(j);
379 ::Kokkos::atomic_add(&sys.getMatrixValue(row, col, tag), local_ke.raw_at(j));
384KOKKOS_FUNCTION
inline void
388 const unsigned int jvar,
389 const unsigned int comp)
const
391 if (!local_ke && add)
395 auto row = sys.getNodeLocalDofIndex(node, 0,
_kokkos_var.
var(comp));
396 auto col = sys.getNodeGlobalDofIndex(node, 0, jvar);
402 if (sys.isMatrixTagActive(tag))
404 auto & matrix = sys.getMatrix(tag);
407 matrix(row, col) += local_ke;
411 matrix(row, col) = local_ke;
417KOKKOS_FUNCTION
inline void
421 const unsigned int i,
422 const unsigned int j,
423 const unsigned int jvar)
const
425 if (!local_ke && add)
430 auto col = sys.getNodeGlobalDofIndex(node, j, jvar);
436 if (sys.isMatrixTagActive(tag))
438 auto & matrix = sys.getMatrix(tag);
441 matrix(row, col) += local_ke;
445 matrix(row, col) = local_ke;
451KOKKOS_FUNCTION
inline void
455 const unsigned int comp)
const
458 auto row = sys.getNodeLocalDofIndex(node, 0,
_kokkos_var.
var(comp));
463 auto & matrix = sys.getMatrix(tag);
465 if (sys.isMatrixTagActive(tag))
470 for (
unsigned int j = 0; j < local_ke.size(); ++j)
472 auto col = local_ke.raw_index(j);
475 matrix(row, col) += local_ke.raw_at(j);
477 matrix(row, col) = local_ke.raw_at(j);
483template <
typename function>
490 unsigned int num_batches = datum.
n_dofs() / stride;
492 if (datum.
n_dofs() % stride)
495 for (
unsigned int batch = 0; batch < num_batches; ++batch)
497 unsigned int ib = batch * stride;
498 unsigned int ie = ::Kokkos::min(ib + stride, datum.
n_dofs());
500 const unsigned int n = ie - ib;
505 ib += t * d + (t < m ? t : m);
506 ie = ib + d + (t < m ? 1 : 0);
508 for (
unsigned int i = ib; i < ie; ++i)
509 local_re[i - ib] = 0;
511 body(local_re - ib, ib, ie);
513 for (
unsigned int i = ib; i < ie; ++i)
518template <
typename function>
532 for (
unsigned int batch = 0; batch < num_batches; ++batch)
537 for (
unsigned int i = ib; i < ie; ++i)
538 local_ke[i - ib] = 0;
540 body(local_ke - ib, ib, ie, j);
542 for (
unsigned int i = ib; i < ie; ++i)
dof_id_type ContiguousElementID
dof_id_type ContiguousNodeID
const InputParameters & parameters() const
Get the parameters of the 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...
This class provides an interface for common operations on field variables of both FE and FV types wit...
KOKKOS_FUNCTION index_type size() const
Get the total array size.
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels.
KOKKOS_FUNCTION unsigned int n_dofs() const
Get the number of local DOFs.
KOKKOS_FUNCTION unsigned int jvar() const
Get the coupled variable number.
KOKKOS_FUNCTION unsigned int n_idofs() const
Get the number of local DOFs.
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 assembly and copies it to device dur...
KOKKOS_FUNCTION unsigned int num_local_threads() const
Get the number of local threads.
KOKKOS_FUNCTION unsigned int local_thread_id() const
Get the current local thread ID.
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
The Kokkos interface that holds the host reference of the Kokkos mesh and copies it to device during ...
The base class for Kokkos residual objects.
virtual void computeResidualAndJacobian() override
Compute this object's contribution to the residual and Jacobian simultaneously.
Scalar< const Real > _t_old
Old time.
ResidualObject(const InputParameters ¶meters, Moose::VarFieldType field_type, bool nodal=false)
Constructor.
std::unique_ptr< DispatcherBase > _residual_dispatcher
Kokkos functor dispatchers.
Scalar< Real > _t
TODO: Move to TransientInterface.
Scalar< Real > _dt_old
Size of the old time step.
KOKKOS_FUNCTION void accumulateTaggedVectorNodalMatrix(const bool add, const Real local_ke, const ContiguousNodeID node, const unsigned int i, const unsigned int j, const unsigned int jvar) const
Accumulate or set local nodal Jacobian contribution to tagged matrices for vector FE variables.
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.
ResidualObject(const ResidualObject &object)
Copy constructor for parallel dispatch.
Variable _kokkos_var
Kokkos variable.
Thread _thread
Kokkos thread object.
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.
const unsigned int _dimension
Mesh dimension.
static InputParameters validParams()
std::unique_ptr< DispatcherBase > _offdiag_jacobian_scalar_dispatcher
static constexpr bool uses_precompute_hooks
Whether this object's hooks factor out the test function.
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.
Array< TagID > _vector_tags
Tags this object operates on.
KOKKOS_FUNCTION void accumulateTaggedVectorNodalResidual(const bool add, const Real local_re, const ContiguousNodeID node, const unsigned int i) const
Accumulate or set local nodal residual contribution to tagged vectors for vector FE variables.
MooseVariableFieldBase & _var
Reference of the MOOSE variable.
virtual void computeOffDiagJacobian(unsigned int) override final
Computes this object's contribution to off-diagonal blocks of the system Jacobian matrix.
static constexpr bool supports_scalar_jacobian
Whether this object has computeQpOffDiagJacobianScalar() hook.
KOKKOS_FUNCTION void computeJacobianInternal(AssemblyDatum &datum, function body) const
The common loop structure template for computing elemental Jacobian.
Scalar< Real > _dt
Time step size.
std::unique_ptr< DispatcherBase > _offdiag_jacobian_dispatcher
virtual const MooseVariableBase & variable() const override
Returns the variable that this object operates on.
std::unique_ptr< DispatcherBase > _jacobian_dispatcher
Array< TagID > _matrix_tags
Scalar< int > _t_step
The number of the time step.
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.
KOKKOS_FUNCTION void computeResidualInternal(AssemblyDatum &datum, function body) const
The common loop structure template for computing elemental residual.
The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable.
The Kokkos thread object that aids in converting the one-dimensional thread index into multi-dimensio...
The Kokkos variable object that carries the coupled variable and tag information.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
This is the common base class for objects that give residual contributions.
virtual void computeResidual()=0
Compute this object's contribution to the residual.
virtual void computeJacobian()=0
Compute this object's contribution to the diagonal Jacobian entries.
KokkosSemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
constexpr unsigned int MAX_CACHED_DOF
Maximum number of DOFs to cache during residual and Jacobian computation.
ContiguousElementID id
Contiguous element ID.