XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cub_interp.hpp
Go to the documentation of this file.
1 #ifndef CUB_INTERP_HPP
2 #define CUB_INTERP_HPP
3 #include "space_settings.hpp"
4 #include "my_mirror_view.hpp"
5 
6 // An array of this struct contains the background magnetic field used for interpolation. Size 4 since it is 3rd-order spline
7 struct OneDCoeff {
8  double coeff[4];
9 };
10 
11 template<class Device>
12 class CubInterp {
13  // This line enables private access between the host and device implementations of this class
14  // i.e. Makes the copy from host to device more straightforward
15  template<class Device2> friend class CubInterp;
16 
17  // Variables needed in the interp
18  int ncoeff;
19  double max_x;
20  double min_x;
21  double dx_inv;
22 
23  Kokkos::View<OneDCoeff*,Kokkos::LayoutRight,Device> acoef;
24 
25  public:
26 
27  // Constructor from x and y
28  CubInterp(const View<double*, HostType>& x, const View<double*, HostType>& y);
29 
30  // Create a mirror with a different device type
31  template<class Device2>
32  inline CubInterp<Device2> mirror() const{
34  m.max_x = max_x;
35  m.min_x = min_x;
36  m.dx_inv = dx_inv;
37  m.ncoeff = ncoeff;
38  m.acoef = my_mirror_view(acoef, Device2());
40 
41  return m;
42  }
43 
44  // Default constructor
46 
47  KOKKOS_INLINE_FUNCTION double value(double x) const;
48  KOKKOS_INLINE_FUNCTION double derivative(double x) const;
49 };
50 
51 #include "cub_interp.tpp"
52 
53 #endif
double min_x
min x cutoff for the interpolation
Definition: cub_interp.hpp:20
void mirror_copy(T1 &view_dest, const T2 &view_src)
Definition: my_mirror_view.hpp:122
KOKKOS_INLINE_FUNCTION double value(double x) const
Definition: cub_interp.tpp:6
Definition: cub_interp.hpp:12
KOKKOS_INLINE_FUNCTION double derivative(double x) const
Definition: cub_interp.tpp:25
double coeff[4]
Definition: cub_interp.hpp:8
Kokkos::View< OneDCoeff *, Kokkos::LayoutRight, Device > acoef
y data for interpolation
Definition: cub_interp.hpp:23
CubInterp< Device2 > mirror() const
Definition: cub_interp.hpp:32
Definition: cub_interp.hpp:7
View< T *, CLayout, Device > my_mirror_view(const View< T *, CLayout, Device > &view, Device nd)
Definition: my_mirror_view.hpp:14
double max_x
max x cutoff for the interpolation
Definition: cub_interp.hpp:19
int ncoeff
Length of acoef.
Definition: cub_interp.hpp:18
CubInterp()
Definition: cub_interp.hpp:45
double dx_inv
Increment dx on which acoef is mapped.
Definition: cub_interp.hpp:21