https://mooseframework.inl.gov
KokkosBodyForce.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 
12 #include "KokkosKernel.h"
13 
14 template <typename Derived>
15 class KokkosBodyForce : public Moose::Kokkos::Kernel<Derived>
16 {
17  usingKokkosKernelMembers(Derived);
18 
19 public:
21 
23 
24  KOKKOS_FUNCTION Real computeQpResidual(const unsigned int i,
25  const unsigned int qp,
26  ResidualDatum & datum) const;
27 
28 protected:
31 
34 };
35 
36 template <typename Derived>
39 {
41  params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
42  params.addParam<PostprocessorName>(
43  "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
44  params.declareControllable("value");
45  return params;
46 }
47 
48 template <typename Derived>
50  : Moose::Kokkos::Kernel<Derived>(parameters),
51  _scale(this->template getParam<Real>("value")),
52  _postprocessor(getPostprocessorValue("postprocessor"))
53 {
54 }
55 
56 template <typename Derived>
57 KOKKOS_FUNCTION Real
59  const unsigned int qp,
60  ResidualDatum & datum) const
61 {
62  return -_test(datum, i, qp) * _scale * _postprocessor;
63 }
64 
65 class KokkosBodyForceKernel final : public KokkosBodyForce<KokkosBodyForceKernel>
66 {
67 public:
69 
71 };
static InputParameters validParams()
Definition: KokkosKernel.h:193
KOKKOS_FUNCTION Real computeQpResidual(const unsigned int i, const unsigned int qp, ResidualDatum &datum) const
const Moose::Kokkos::PostprocessorValue _postprocessor
Optional Postprocessor value.
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...
KokkosBodyForceKernel(const InputParameters &parameters)
const Moose::Kokkos::Scalar< const Real > _scale
Scale factor.
static InputParameters validParams()
usingKokkosKernelMembers(Derived)
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: Kernel.h:15
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
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
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
KokkosBodyForce(const InputParameters &parameters)