69 mooseError(
"computeOffDiagJacobian() is not used for Kokkos residual objects.");
139 const unsigned int i,
140 const unsigned int comp = 0)
const;
151 const unsigned int comp = 0)
const;
162 const unsigned int i)
const;
174 const unsigned int i,
175 const unsigned int j,
176 const unsigned int jvar,
177 const unsigned int comp = 0)
const;
188 const unsigned int i,
189 const unsigned int comp = 0)
const;
201 const unsigned int jvar,
202 const unsigned int comp = 0)
const;
215 const unsigned int i,
216 const unsigned int j,
217 const unsigned int jvar)
const;
229 const unsigned int comp = 0)
const;
236 template <
typename function>
243 template <
typename function>
256 KOKKOS_FUNCTION
inline void 259 const unsigned int i,
260 const unsigned int comp)
const 266 auto dof = sys.getElemLocalDofIndex(elem, i,
_kokkos_var.
var(comp));
272 if (sys.isResidualTagActive(tag))
273 ::Kokkos::atomic_add(&sys.getVectorDofValue(dof, tag), local_re);
277 KOKKOS_FUNCTION
inline void 281 const unsigned int comp)
const 283 if (!local_re && add)
287 auto dof = sys.getNodeLocalDofIndex(node, 0,
_kokkos_var.
var(comp));
293 if (sys.isResidualTagActive(tag))
296 sys.getVectorDofValue(dof, tag) += local_re;
298 sys.getVectorDofValue(dof, tag) = local_re;
303 KOKKOS_FUNCTION
inline void 307 const unsigned int i)
const 309 if (!local_re && add)
319 if (sys.isResidualTagActive(tag))
322 sys.getVectorDofValue(dof, tag) += local_re;
324 sys.getVectorDofValue(dof, tag) = local_re;
329 KOKKOS_FUNCTION
inline void 332 const unsigned int i,
333 const unsigned int j,
334 const unsigned int jvar,
335 const unsigned int comp)
const 341 auto row = sys.getElemLocalDofIndex(elem, i,
_kokkos_var.
var(comp));
342 auto col = sys.getElemGlobalDofIndex(elem, j, jvar);
348 if (sys.isMatrixTagActive(tag) && !sys.hasNodalBCMatrixTag(row, tag))
349 ::Kokkos::atomic_add(&sys.getMatrixValue(row, col, tag), local_ke);
353 KOKKOS_FUNCTION
inline void 356 const unsigned int i,
357 const unsigned int comp)
const 366 if (sys.isMatrixTagActive(tag) && !sys.hasNodalBCMatrixTag(row, tag))
367 for (
unsigned int j = 0; j < local_ke.size(); ++j)
369 auto col = local_ke.raw_index(j);
371 ::Kokkos::atomic_add(&sys.getMatrixValue(row, col, tag), local_ke.raw_at(j));
376 KOKKOS_FUNCTION
inline void 380 const unsigned int jvar,
381 const unsigned int comp)
const 383 if (!local_ke && add)
387 auto row = sys.getNodeLocalDofIndex(node, 0,
_kokkos_var.
var(comp));
388 auto col = sys.getNodeGlobalDofIndex(node, 0, jvar);
394 if (sys.isMatrixTagActive(tag))
396 auto & matrix = sys.getMatrix(tag);
399 matrix(row, col) += local_ke;
403 matrix(row, col) = local_ke;
409 KOKKOS_FUNCTION
inline void 413 const unsigned int i,
414 const unsigned int j,
415 const unsigned int jvar)
const 417 if (!local_ke && add)
422 auto col = sys.getNodeGlobalDofIndex(node, j, jvar);
428 if (sys.isMatrixTagActive(tag))
430 auto & matrix = sys.getMatrix(tag);
433 matrix(row, col) += local_ke;
437 matrix(row, col) = local_ke;
443 KOKKOS_FUNCTION
inline void 447 const unsigned int comp)
const 450 auto row = sys.getNodeLocalDofIndex(node, 0,
_kokkos_var.
var(comp));
455 auto & matrix = sys.getMatrix(tag);
457 if (sys.isMatrixTagActive(tag))
462 for (
unsigned int j = 0; j < local_ke.size(); ++j)
464 auto col = local_ke.raw_index(j);
467 matrix(row, col) += local_ke.raw_at(j);
469 matrix(row, col) = local_ke.raw_at(j);
475 template <
typename function>
482 unsigned int num_batches = datum.
n_dofs() / stride;
484 if (datum.
n_dofs() % stride)
487 for (
unsigned int batch = 0; batch < num_batches; ++batch)
489 unsigned int ib = batch * stride;
492 const unsigned int n = ie - ib;
497 ib += t * d + (t < m ? t : m);
498 ie = ib + d + (t < m ? 1 : 0);
500 for (
unsigned int i = ib; i < ie; ++i)
501 local_re[i - ib] = 0;
503 body(local_re - ib, ib, ie);
505 for (
unsigned int i = ib; i < ie; ++i)
510 template <
typename function>
524 for (
unsigned int batch = 0; batch < num_batches; ++batch)
529 for (
unsigned int i = ib; i < ie; ++i)
530 local_ke[i - ib] = 0;
532 body(local_ke - ib, ib, ie, j);
534 for (
unsigned int i = ib; i < ie; ++i)
Scalar< Real > _dt_old
Size of the old time step.
static constexpr bool use_precompute_hooks
Whether this object's hooks factor out the test function.
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...
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 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...
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.
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.
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...
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.
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 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.
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.
const unsigned int _dimension
Mesh dimension.