XGC1
 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
28  CubInterp(OneDCoeff *one_d_cub_acoef_in, int ncoeff_in, double max_psi_in, double min_psi_in, double one_d_cub_dpsi_inv_in);
29 
30  // Constructor from x and y
31  inline CubInterp(const View<double*, HostType>& x, const View<double*, HostType>& y);
32 
33  // Create a mirror with a different device type
34  template<class Device2>
35  inline CubInterp<Device2> mirror() const{
37  m.max_x = max_x;
38  m.min_x = min_x;
39  m.dx_inv = dx_inv;
40  m.ncoeff = ncoeff;
41  m.acoef = my_mirror_view(acoef, Device2());
43 
44  return m;
45  }
46 
47  // Default constructor
49 
50  KOKKOS_INLINE_FUNCTION double value(double x) const;
51  KOKKOS_INLINE_FUNCTION double derivative(double x) const;
52 };
53 
54 #include "cub_interp.tpp"
55 
56 #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:44
Definition: cub_interp.hpp:12
KOKKOS_INLINE_FUNCTION double derivative(double x) const
Definition: cub_interp.tpp:63
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:35
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:48
double dx_inv
Increment dx on which acoef is mapped.
Definition: cub_interp.hpp:21