https://mooseframework.inl.gov
KokkosVectorTimeDerivative.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
13 
15 {
16 public:
18 
20 
21  template <typename Derived>
22  KOKKOS_FUNCTION void computeJacobianInternal(const Derived & kernel, AssemblyDatum & datum) const;
23 
24  template <typename Derived>
25  KOKKOS_FUNCTION Moose::Kokkos::Real3 precomputeQpResidual(const unsigned int qp,
26  AssemblyDatum & datum) const;
27  template <typename Derived>
28  KOKKOS_FUNCTION Moose::Kokkos::Real3
29  precomputeQpJacobian(const unsigned int j, const unsigned int qp, AssemblyDatum & datum) const;
30 
31 protected:
32  const bool _lumping;
33 };
34 
35 template <typename Derived>
36 KOKKOS_FUNCTION void
38  AssemblyDatum & datum) const
39 {
41 
42  Real local_ke[MAX_CACHED_DOF];
43 
44  for (unsigned int j = datum.local_thread_id(); j < datum.n_jdofs();
45  j += datum.num_local_threads())
46  {
47  unsigned int num_batches = datum.n_idofs() / MAX_CACHED_DOF;
48 
49  if (datum.n_idofs() % MAX_CACHED_DOF)
50  ++num_batches;
51 
52  for (unsigned int batch = 0; batch < num_batches; ++batch)
53  {
54  unsigned int ib = batch * MAX_CACHED_DOF;
55  unsigned int ie = ::Kokkos::min(ib + MAX_CACHED_DOF, datum.n_idofs());
56 
57  for (unsigned int i = ib; i < ie; ++i)
58  local_ke[i - ib] = 0;
59 
60  for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
61  {
63  datum.JxW(qp) * kernel.template precomputeQpJacobian<Derived>(j, qp, datum);
64 
65  for (unsigned int i = ib; i < ie; ++i)
66  local_ke[i - ib] += value * _test(datum, i, qp);
67  }
68 
69  for (unsigned int i = ib; i < ie; ++i)
71  local_ke[i - ib], datum.elem().id, i, _lumping ? i : j, datum.jvar());
72  }
73  }
74 }
75 
76 template <typename Derived>
77 KOKKOS_FUNCTION Moose::Kokkos::Real3
79 {
80  return _u_dot(datum, qp);
81 }
82 
83 template <typename Derived>
84 KOKKOS_FUNCTION Moose::Kokkos::Real3
86  const unsigned int qp,
87  AssemblyDatum & datum) const
88 {
89  return _phi(datum, j, qp) * _du_dot_du;
90 }
KOKKOS_FUNCTION Moose::Kokkos::Real3 precomputeQpJacobian(const unsigned int j, const unsigned int qp, AssemblyDatum &datum) const
KOKKOS_FUNCTION unsigned int num_local_threads() const
Get the number of local threads.
Definition: KokkosDatum.h:384
The base class for Kokkos vector time kernels whose test function can be factored out...
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
KOKKOS_FUNCTION unsigned int jvar() const
Get the coupled variable number.
Definition: KokkosDatum.h:651
const VectorVariablePhiValue _phi
Current vector shape function.
KOKKOS_FUNCTION void computeJacobianInternal(const Derived &kernel, AssemblyDatum &datum) const
KOKKOS_FUNCTION unsigned int n_jdofs() const
Get the number of local DOFs for the coupled variable.
Definition: KokkosDatum.h:631
KokkosVectorTimeDerivative(const InputParameters &parameters)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const Scalar< const Real > _du_dot_du
Derivative of u_dot with respect to u.
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 unsigned int n_idofs() const
Get the number of local DOFs.
Definition: KokkosDatum.h:626
const VectorVariableValue _u_dot
Time derivative of the current solution at quadrature points.
static InputParameters validParams()
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.
Definition: KokkosDatum.h:303
KOKKOS_FUNCTION unsigned int local_thread_id() const
Get the current local thread ID.
Definition: KokkosDatum.h:379
KOKKOS_FUNCTION Moose::Kokkos::Real3 precomputeQpResidual(const unsigned int qp, AssemblyDatum &datum) const
const VectorVariableTestValue _test
Current vector test function.
constexpr unsigned int MAX_CACHED_DOF
Maximum number of DOFs to cache during residual and Jacobian computation.
Definition: KokkosHeader.h:83
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels...
Definition: KokkosDatum.h:559
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
Definition: KokkosDatum.h:506
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
Definition: KokkosDatum.h:46
auto min(const L &left, const R &right)
ContiguousElementID id
Contiguous element ID.
Definition: KokkosMesh.h:42