https://mooseframework.inl.gov
KokkosTimeKernel.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
12 #include "KokkosKernel.h"
13 
14 namespace Moose
15 {
16 namespace Kokkos
17 {
18 
22 template <typename Derived>
23 class TimeKernel : public Kernel<Derived>
24 {
25  usingKokkosKernelMembers(Derived);
26 
27 public:
29 
34 
42  KOKKOS_FUNCTION void computeResidualAdditional(const unsigned int /* ib */,
43  const unsigned int /* ie */,
44  ResidualDatum & /* datum */,
45  Real * /* local_re */) const
46  {
47  }
48 
53  KOKKOS_FUNCTION void computeResidualInternal(const Derived * kernel, ResidualDatum & datum) const;
54 
55 protected:
64 };
65 
66 template <typename Derived>
69 {
71 
72  params.set<MultiMooseEnum>("vector_tags") = "time";
73  params.set<MultiMooseEnum>("matrix_tags") = "system time";
74 
75  return params;
76 }
77 
78 template <typename Derived>
80  : Kernel<Derived>(parameters),
81  _u_dot(_var, Moose::SOLUTION_DOT_TAG),
82  _du_dot_du(_var.sys().duDotDu(_var.number()))
83 {
84 }
85 
86 template <typename Derived>
87 KOKKOS_FUNCTION void
88 TimeKernel<Derived>::computeResidualInternal(const Derived * kernel, ResidualDatum & datum) const
89 {
90  ResidualObject::computeResidualInternal(
91  datum,
92  [&](Real * local_re, const unsigned int ib, const unsigned int ie)
93  {
94  for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
95  {
96  datum.reinit();
97 
98  for (unsigned int i = ib; i < ie; ++i)
99  local_re[i] += datum.JxW(qp) * kernel->computeQpResidual(i, qp, datum);
100  }
101 
102  kernel->computeResidualAdditional(ib, ie, datum, local_re);
103  });
104 }
105 
106 } // namespace Kokkos
107 } // namespace Moose
108 
109 #define usingKokkosTimeKernelMembers(T) \
110  usingKokkosKernelMembers(T); \
111  \
112 protected: \
113  using Moose::Kokkos::TimeKernel<T>::_u_dot; \
114  using Moose::Kokkos::TimeKernel<T>::_du_dot_du
const Scalar< const Real > _du_dot_du
Derivative of u_dot with respect to u.
static InputParameters validParams()
Definition: KokkosKernel.h:193
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
KOKKOS_FUNCTION void computeResidualAdditional(const unsigned int, const unsigned int, ResidualDatum &, Real *) const
Hook for additional computation for residual after the standard calls.
The base class for Kokkos time-derivative kernels.
const VariableValue _u_dot
Time derivative of the current solution at quadrature points.
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.
Definition: KokkosDatum.h:95
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
KOKKOS_FUNCTION void computeResidualInternal(const Derived *kernel, ResidualDatum &datum) const
The parallel computation body that hides the base class method to allow additional computation for re...
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
Definition: KokkosDatum.h:126
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
The Kokkos wrapper classes for MOOSE-like variable value access.
The base class for a user to derive their own Kokkos kernels.
Definition: KokkosKernel.h:53
The Kokkos object that holds thread-private data in the parallel operations of Kokkos residual object...
Definition: KokkosDatum.h:222
KOKKOS_FUNCTION void reinit()
Reset the reinit flag.
Definition: KokkosDatum.h:147
TimeKernel(const InputParameters &parameters)
Constructor.
const TagName SOLUTION_DOT_TAG
Definition: MooseTypes.C:30