52 template <
typename Derived>
191 template <
typename Derived>
199 template <
typename Derived>
212 template <
typename Derived>
216 ::Kokkos::RangePolicy<ResidualLoop, ExecSpace, ::Kokkos::IndexType<ThreadID>> policy(
217 0, numKokkosBlockElements());
218 ::Kokkos::parallel_for(policy, *static_cast<Derived *>(
this));
222 template <
typename Derived>
226 if (!defaultJacobian())
228 ::Kokkos::RangePolicy<JacobianLoop, ExecSpace, ::Kokkos::IndexType<ThreadID>> policy(
229 0, numKokkosBlockElements());
230 ::Kokkos::parallel_for(policy, *static_cast<Derived *>(
this));
234 if (!defaultOffDiagJacobian())
236 auto & sys = kokkosSystem(_kokkos_var.sys());
238 _thread.resize({sys.getCoupling(_kokkos_var.var()).size(), numKokkosBlockElements()});
240 ::Kokkos::RangePolicy<OffDiagJacobianLoop, ExecSpace, ::Kokkos::IndexType<ThreadID>> policy(
242 ::Kokkos::parallel_for(policy, *static_cast<Derived *>(
this));
247 template <
typename Derived>
251 auto kernel =
static_cast<const Derived *
>(
this);
252 auto elem = kokkosBlockElementID(tid);
254 ResidualDatum datum(elem, kokkosAssembly(), kokkosSystems(), _kokkos_var, _kokkos_var.var());
256 kernel->computeResidualInternal(kernel, datum);
259 template <
typename Derived>
263 auto kernel =
static_cast<const Derived *
>(
this);
264 auto elem = kokkosBlockElementID(tid);
266 ResidualDatum datum(elem, kokkosAssembly(), kokkosSystems(), _kokkos_var, _kokkos_var.var());
268 kernel->computeJacobianInternal(kernel, datum);
271 template <
typename Derived>
275 auto kernel =
static_cast<const Derived *
>(
this);
276 auto elem = kokkosBlockElementID(_thread(tid, 1));
278 auto & sys = kokkosSystem(_kokkos_var.sys());
279 auto jvar = sys.getCoupling(_kokkos_var.var())[_thread(tid, 0)];
281 if (!sys.isVariableActive(jvar, kokkosMesh().getElementInfo(elem).subdomain))
284 ResidualDatum datum(elem, kokkosAssembly(), kokkosSystems(), _kokkos_var, jvar);
286 kernel->computeOffDiagJacobianInternal(kernel, datum);
289 template <
typename Derived>
293 ResidualObject::computeResidualInternal(
295 [&](
Real * local_re,
const unsigned int ib,
const unsigned int ie)
297 for (
unsigned int qp = 0; qp < datum.
n_qps(); ++qp)
301 for (
unsigned int i = ib; i < ie; ++i)
302 local_re[i] += datum.
JxW(qp) * kernel->computeQpResidual(i, qp, datum);
307 template <
typename Derived>
311 ResidualObject::computeJacobianInternal(
313 [&](
Real * local_ke,
const unsigned int ijb,
const unsigned int ije)
315 for (
unsigned int qp = 0; qp < datum.
n_qps(); ++qp)
319 for (
unsigned int ij = ijb; ij < ije; ++ij)
321 unsigned int i = ij % datum.
n_jdofs();
322 unsigned int j = ij / datum.
n_jdofs();
324 local_ke[ij] += datum.
JxW(qp) * kernel->computeQpJacobian(i, j, qp, datum);
330 template <
typename Derived>
334 ResidualObject::computeJacobianInternal(
336 [&](
Real * local_ke,
const unsigned int ijb,
const unsigned int ije)
338 for (
unsigned int qp = 0; qp < datum.
n_qps(); ++qp)
342 for (
unsigned int ij = ijb; ij < ije; ++ij)
344 unsigned int i = ij % datum.
n_jdofs();
345 unsigned int j = ij / datum.
n_jdofs();
348 datum.
JxW(qp) * kernel->computeQpOffDiagJacobian(i, j, datum.
jvar(), qp, datum);
357 #define usingKokkosKernelMembers(T) \ 358 usingKokkosKernelBaseMembers; \ 361 using Moose::Kokkos::Kernel<T>::_test; \ 362 using Moose::Kokkos::Kernel<T>::_grad_test; \ 363 using Moose::Kokkos::Kernel<T>::_phi; \ 364 using Moose::Kokkos::Kernel<T>::_grad_phi; \ 365 using Moose::Kokkos::Kernel<T>::_u; \ 366 using Moose::Kokkos::Kernel<T>::_grad_u; \ 369 using Moose::Kokkos::Kernel<T>::operator()
KOKKOS_FUNCTION unsigned int n_jdofs() const
Get the number of local DOFs for the coupled variable.
virtual void computeResidual() override
Dispatch residual calculation.
KOKKOS_FUNCTION void computeOffDiagJacobianInternal(const Derived *kernel, ResidualDatum &datum) const
Compute off-diagonal Jacobian.
virtual bool defaultJacobian() const
Get whether computeQpJacobian() was not defined in the derived class.
virtual void computeResidual() override
Compute this Kernel's contribution to the residual.
static InputParameters validParams()
MooseVariable & _var
This is a regular kernel so we cast to a regular MooseVariable.
const VariablePhiValue _phi
Current shape function.
KOKKOS_FUNCTION Real computeQpJacobian(const unsigned int, const unsigned int, const unsigned int, ResidualDatum &) const
Default methods to prevent compile errors even when these methods were not defined in the derived cla...
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
KOKKOS_FUNCTION void operator()(ResidualLoop, const ThreadID tid) const
The parallel computation entry functions called by Kokkos.
const VariableValue _u
Current solution at quadrature points.
const VariableGradient _grad_u
Gradient of the current solution at quadrature points.
The Kokkos wrapper classes for MOOSE-like shape function access.
virtual void computeJacobian() override
Dispatch diagonal and off-diagonal Jacobian calculation.
KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int, const unsigned int, const unsigned int, const unsigned int, ResidualDatum &) const
Compute off-diagonal Jacobian contribution on a quadrature point.
Kernel(const InputParameters ¶meters)
Constructor.
KOKKOS_FUNCTION void computeResidualInternal(const Derived *kernel, ResidualDatum &datum) const
The parallel computation bodies that can be customized in the derived class by defining them in the d...
KOKKOS_FUNCTION void computeJacobianInternal(const Derived *kernel, ResidualDatum &datum) const
Compute diagonal Jacobian.
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.
const VariablePhiGradient _grad_phi
Gradient of the current shape function.
The base class for Kokkos kernels.
virtual void computeJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian entries.
const VariableTestGradient _grad_test
Gradient of the current test function.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual bool defaultOffDiagJacobian() const
Get whether computeQpOffDiagJacobian() was not defined in the derived class.
The Kokkos wrapper classes for MOOSE-like variable value access.
The base class for a user to derive their own Kokkos kernels.
KOKKOS_FUNCTION unsigned int jvar() const
Get the coupled variable number.
The Kokkos object that holds thread-private data in the parallel operations of Kokkos residual object...
KOKKOS_FUNCTION void reinit()
Reset the reinit flag.
const VariableTestValue _test
Current test function.