XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bicub.hpp
Go to the documentation of this file.
1 #ifndef BICUB_HPP
2 #define BICUB_HPP
3 #include "space_settings.hpp"
4 #include "simd.hpp"
5 #include "my_mirror_view.hpp"
6 
7 // The dimensions of this were (0:ndeg, 0:ndeg) - hardcoded to (4,4) here
8 struct BicubCoeff {
9  double coeff[4][4];
10 };
11 
12 // Bicubic spline class
13 template<class Device>
14 class Bicub {
15  // This line enables private access between the host and device implementations of this class
16  // i.e. Makes the copy from host to device more straightforward
17  template<class Device2> friend class Bicub;
18 
19  // bicub variables
20  int nr, nz;
21  double rmin, zmin;
22  double dr_inv, dz_inv;
23  Kokkos::View<double*,Kokkos::LayoutRight,Device> rc;
24  Kokkos::View<double*,Kokkos::LayoutRight,Device> zc;
25  Kokkos::View<BicubCoeff**,Kokkos::LayoutRight,Device> acoeff_all;
26 
27  // Compute value
28  KOKKOS_INLINE_FUNCTION void eval_bicub_0(double x, double y, double xc, double yc, const double (&acoeff)[4][4],
29  double &f00) const;
30 
31  // Compute first derivatives
32  KOKKOS_INLINE_FUNCTION void eval_bicub_1(double x, double y, double xc, double yc, const double (&acoeff)[4][4],
33  double &f00, double &f10, double &f01) const;
34 
35  // Compute first and second derivatives
36  KOKKOS_INLINE_FUNCTION void eval_bicub_2(double x, double y, double xc, double yc, const double (&acoeff)[4][4],
37  double &f00, double &f10, double &f01,
38  double &f11, double &f20, double &f02) const;
39 
40  public:
41 
42  // Constructor from grid on r,z
43  inline Bicub(const View<double*, HostType>& r, const View<double*, HostType>& z, const View<double**, CLayout, HostType>& val);
44 
45  // Create a mirror with a different device type
46  template<class Device2>
47  inline Bicub<Device2> mirror() const{
49  m.nr = nr;
50  m.nz = nz;
51  m.rmin = rmin;
52  m.dr_inv = dr_inv;
53  m.zmin = zmin;
54  m.dz_inv = dz_inv;
55  m.rc = my_mirror_view(rc, Device2());
56  mirror_copy(m.rc, rc);
57  m.zc = my_mirror_view(zc, Device2());
58  mirror_copy(m.zc, zc);
59  m.acoeff_all = my_mirror_view(acoeff_all, Device2());
61 
62  return m;
63  }
64 
65  // Default constructor
66  Bicub(){}
67 
68  // Get values
69  KOKKOS_INLINE_FUNCTION void der_zero(double x, double y, double &f00) const;
70 
71  // Get first derivatives
72  KOKKOS_INLINE_FUNCTION void der_one(double x, double y, double &f00, double &f10, double &f01) const;
73 
74  // Get first and second derivatives
75  KOKKOS_INLINE_FUNCTION void der_all(double x, double y, double &f00, double &f10, double &f01,
76  double &f11, double &f20, double &f02) const;
77 };
78 
79 #include "bicub.tpp"
80 
81 #endif
double zmin
First r and z point.
Definition: bicub.hpp:21
void mirror_copy(T1 &view_dest, const T2 &view_src)
Definition: my_mirror_view.hpp:122
KOKKOS_INLINE_FUNCTION void der_zero(double x, double y, double &f00) const
Definition: bicub.tpp:89
KOKKOS_INLINE_FUNCTION void der_all(double x, double y, double &f00, double &f10, double &f01, double &f11, double &f20, double &f02) const
Definition: bicub.tpp:122
Definition: bicub.hpp:8
KOKKOS_INLINE_FUNCTION void eval_bicub_0(double x, double y, double xc, double yc, const double(&acoeff)[4][4], double &f00) const
Definition: bicub.tpp:139
Kokkos::View< double *, Kokkos::LayoutRight, Device > rc
Array containing the r coordinates of the grid points.
Definition: bicub.hpp:23
Bicub()
Definition: bicub.hpp:66
int nz
Number of points in r and z directions.
Definition: bicub.hpp:20
KOKKOS_INLINE_FUNCTION void eval_bicub_1(double x, double y, double xc, double yc, const double(&acoeff)[4][4], double &f00, double &f10, double &f01) const
Definition: bicub.tpp:170
Kokkos::View< double *, Kokkos::LayoutRight, Device > zc
Array containing the z coordinates of the grid points.
Definition: bicub.hpp:24
Bicub< Device2 > mirror() const
Definition: bicub.hpp:47
Definition: bicub.hpp:14
double coeff[4][4]
Definition: bicub.hpp:9
double dr_inv
Definition: bicub.hpp:22
KOKKOS_INLINE_FUNCTION void eval_bicub_2(double x, double y, double xc, double yc, const double(&acoeff)[4][4], double &f00, double &f10, double &f01, double &f11, double &f20, double &f02) const
Definition: bicub.tpp:226
double rmin
Definition: bicub.hpp:21
View< T *, CLayout, Device > my_mirror_view(const View< T *, CLayout, Device > &view, Device nd)
Definition: my_mirror_view.hpp:14
int nr
Definition: bicub.hpp:20
double dz_inv
Inverse of the cell size.
Definition: bicub.hpp:22
KOKKOS_INLINE_FUNCTION void der_one(double x, double y, double &f00, double &f10, double &f01) const
Definition: bicub.tpp:104
Kokkos::View< BicubCoeff **, Kokkos::LayoutRight, Device > acoeff_all
The field for interpolation.
Definition: bicub.hpp:25