https://mooseframework.inl.gov
KokkosFunction.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 "KokkosTypes.h"
13 #include "KokkosFunctionWrapper.h"
14 #include "KokkosFunctorRegistry.h"
15 
16 #include "FunctionBase.h"
17 
18 namespace Moose
19 {
20 namespace Kokkos
21 {
22 
32 {
33 public:
35 
43  FunctionBase(const FunctionBase & object);
44 
51  KOKKOS_FUNCTION Real value(Real /* t */, Real3 /* p */) const
52  {
53  KOKKOS_ASSERT(false);
54  return 0;
55  }
62  KOKKOS_FUNCTION Real3 vectorValue(Real /* t */, Real3 /* p */) const
63  {
64  KOKKOS_ASSERT(false);
65  return Real3(0);
66  }
73  KOKKOS_FUNCTION Real3 gradient(Real /* t */, Real3 /* p */) const
74  {
75  KOKKOS_ASSERT(false);
76  return Real3(0);
77  }
84  KOKKOS_FUNCTION Real3 curl(Real /* t */, Real3 /* p */) const
85  {
86  KOKKOS_ASSERT(false);
87  return Real3(0);
88  }
95  KOKKOS_FUNCTION Real div(Real /* t */, Real3 /* p */) const
96  {
97  KOKKOS_ASSERT(false);
98  return 0;
99  }
106  KOKKOS_FUNCTION Real timeDerivative(Real /* t */, Real3 /* p */) const
107  {
108  KOKKOS_ASSERT(false);
109  return 0;
110  }
118  KOKKOS_FUNCTION Real timeIntegral(Real /* t1 */, Real /* t2 */, Real3 /* p */) const
119  {
120  KOKKOS_ASSERT(false);
121  return 0;
122  }
127  KOKKOS_FUNCTION Real integral() const
128  {
129  KOKKOS_ASSERT(false);
130  return 0;
131  }
136  KOKKOS_FUNCTION Real average() const
137  {
138  KOKKOS_ASSERT(false);
139  return 0;
140  }
141 };
142 
149 class Function final
150 {
151 public:
156  Function(std::shared_ptr<FunctionWrapperHostBase> wrapper);
160  Function(const Function & function);
164  ~Function();
165 
166  KOKKOS_FUNCTION Real value(Real t, Real3 p) const { return _wrapper_device->value(t, p); }
167  KOKKOS_FUNCTION Real3 vectorValue(Real t, Real3 p) const
168  {
169  return _wrapper_device->vectorValue(t, p);
170  }
171  KOKKOS_FUNCTION Real3 gradient(Real t, Real3 p) const { return _wrapper_device->gradient(t, p); }
172  KOKKOS_FUNCTION Real3 curl(Real t, Real3 p) const { return _wrapper_device->curl(t, p); }
173  KOKKOS_FUNCTION Real div(Real t, Real3 p) const { return _wrapper_device->div(t, p); }
174  KOKKOS_FUNCTION Real timeDerivative(Real t, Real3 p) const
175  {
176  return _wrapper_device->timeDerivative(t, p);
177  }
178  KOKKOS_FUNCTION Real timeIntegral(Real t1, Real t2, Real3 p) const
179  {
180  return _wrapper_device->timeIntegral(t1, t2, p);
181  }
182  KOKKOS_FUNCTION Real integral() const { return _wrapper_device->integral(); }
183  KOKKOS_FUNCTION Real average() const { return _wrapper_device->average(); }
184 
185 private:
189  std::shared_ptr<FunctionWrapperHostBase> _wrapper_host;
194 };
195 
196 }
197 }
Base class for device function wrapper.
KOKKOS_FUNCTION Real3 vectorValue(Real t, Real3 p) const
static InputParameters validParams()
virtual KOKKOS_FUNCTION Real timeIntegral(Real t1, Real t2, Real3 p) const =0
virtual KOKKOS_FUNCTION Real3 gradient(Real t, Real3 p) const =0
KOKKOS_FUNCTION Real timeIntegral(Real, Real, Real3) const
Evaluate a time integral at point (x,y,z) between time t1 and t2.
KOKKOS_FUNCTION Real integral() const
Evaluate the integral over the domain.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
KOKKOS_FUNCTION Real3 gradient(Real t, Real3 p) const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
KOKKOS_FUNCTION Real3 gradient(Real, Real3) const
Evaluate a gradient at point (t,x,y,z)
The base class for a user to derive their own Kokkos functions.
KOKKOS_FUNCTION Real div(Real, Real3) const
Evaluate a divergence at point (t,x,y,z)
Function(std::shared_ptr< FunctionWrapperHostBase > wrapper)
Constructor.
virtual KOKKOS_FUNCTION Real3 vectorValue(Real t, Real3 p) const =0
KOKKOS_FUNCTION Real3 curl(Real, Real3) const
Evaluate a curl at point (t,x,y,z)
The abstract class that provides polymorphic interfaces for a function.
virtual KOKKOS_FUNCTION Real integral() const =0
FunctionWrapperDeviceBase * _wrapper_device
Pointer to the device function wrapper.
virtual KOKKOS_FUNCTION Real average() const =0
~Function()
Destructor.
KOKKOS_FUNCTION Real timeDerivative(Real t, Real3 p) const
std::shared_ptr< FunctionWrapperHostBase > _wrapper_host
Pointer to the host function wrapper.
KOKKOS_FUNCTION Real timeIntegral(Real t1, Real t2, Real3 p) const
KOKKOS_FUNCTION Real3 curl(Real t, Real3 p) const
KOKKOS_FUNCTION Real average() const
Evaluate the average over the domain.
KOKKOS_FUNCTION Real3 vectorValue(Real, Real3) const
Evaluate a vector value at point (t,x,y,z)
virtual KOKKOS_FUNCTION Real timeDerivative(Real t, Real3 p) const =0
KOKKOS_FUNCTION Real integral() const
FunctionBase(const InputParameters &parameters)
Constructor.
virtual KOKKOS_FUNCTION Real div(Real t, Real3 p) const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
KOKKOS_FUNCTION Real average() const
KOKKOS_FUNCTION Real div(Real t, Real3 p) const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual KOKKOS_FUNCTION Real value(Real t, Real3 p) const =0
Virtual shims that calls the corresponding methods of the actual stored function. ...
virtual KOKKOS_FUNCTION Real3 curl(Real t, Real3 p) const =0
KOKKOS_FUNCTION Real value(Real, Real3) const
Evaluate a scalar value at point (t,x,y,z)
KOKKOS_FUNCTION Real timeDerivative(Real, Real3) const
Evaluate a time derivative at point (t,x,y,z)
KOKKOS_FUNCTION Real value(Real t, Real3 p) const