All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Go to the documentation of this file.
1 #ifndef CPP_GRID_HPP
2 #define CPP_GRID_HPP
3 #include "cpp_magnetic_field.hpp"
5 // The three points of a grid triangle
6 struct SimdGridVec{
9  // Allows array-like access pattern
10  KOKKOS_INLINE_FUNCTION const Simd<double>& operator [](int i) const {return x[i];}
11  KOKKOS_INLINE_FUNCTION Simd<double>& operator [](int i) {return x[i];}
15  KOKKOS_INLINE_FUNCTION void maxloc(Simd<int> &ml) const {
16  for (int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
17  ml[i_simd] = (x[1][i_simd] > x[0][i_simd]) ? 1 : 0;
18  ml[i_simd] = (x[2][i_simd] > x[0][i_simd] && x[2][i_simd] > x[1][i_simd]) ? 2 : ml[i_simd];
19  }
20  }
21 };
23 struct Vertex {
24  int vertex[3];
25 };
27 struct RZPair {
28  double r;
29  double z;
30 };
32 struct VertexMap {
34 };
36 // Grid class
37 template<class Device>
38 class Grid {
39  public:
41  // Constructor
42  Grid(int ntriangle, int nnode, int nplanes, double delta_phi, int nguess, int guess_list_len, double guess_min1, double guess_min2, double guess_max1,
43  double guess_max2, double inv_guess_d1, double inv_guess_d2, int npsi_surf2, int iphi_offset, int npsi00, double psi00min, double psi00max,
44  double dpsi00, int nwall, double wedge_angle, double eq_x_psi,
45  double* psi, int* basis, Vertex* nodes, VertexMap* mapping, int* guess_list, int* guess_xtable, int* guess_count,
46 #ifdef CONVERT_GRID2
47  int* guess_list_1d, double* psi_surf2,double minval_psi_surf2, double maxval_psi_surf2,
48 #endif
49  int* wall_nodes, int* node_to_wall, int* rgn, RZPair* gx, int nrho, double rhomax, double phimax);
51  // Default constructor
52  Grid(){}
54  KOKKOS_INLINE_FUNCTION void t_coeff(const SimdVector2D &x, const Simd<int>& itr, SimdGridVec &p) const;
56  KOKKOS_INLINE_FUNCTION void t_coeff_mod(const MagneticField<Device> &magnetic_field, const SimdVector2D &xy, const Simd<double>& psiin, const Simd<int>& itr, SimdGridVec &p ) const;
58  KOKKOS_INLINE_FUNCTION void search_tr2( const SimdVector2D &xy, Simd<int>& itr, SimdGridVec &pout ) const;
60  KOKKOS_INLINE_FUNCTION void search_tr_check_guess(const SimdVector2D &x, const Simd<int>& old_itr,Simd<int>& itr,SimdGridVec &p ) const;
62 #ifdef CONVERT_GRID2
63  KOKKOS_INLINE_FUNCTION void search_ptl_1d(double psi,double &wp,int &ip) const;
64 #endif
66  KOKKOS_INLINE_FUNCTION void charge_search_index(const MagneticField<Device> &magnetic_field, const SimdVector2D &x, const Simd<double>& phi, const Simd<double>& psi, SimdVector2D &xff,Simd<int>& itr, SimdGridVec &p) const;
68  KOKKOS_INLINE_FUNCTION void get_wall_index(const Simd<bool>& just_left_the_grid,const SimdVector2D &x,const Simd<int>& itr, const SimdGridVec &p, Simd<int>& widx) const;
70  KOKKOS_INLINE_FUNCTION void wedge_modulo_phi(Simd<double>& phi_mod) const;
72  KOKKOS_INLINE_FUNCTION void check_triangle(const Simd<int>& itr,Simd<bool>& wasnt_in_triangle) const;
74  int ntriangle;
75  int nnode;
76  int nplanes;
77  double wedge_angle;
78  double delta_phi;
79  double inv_delta_phi;
81  Kokkos::View<double*,Kokkos::LayoutRight,Device> psi;
82  Kokkos::View<int*, Kokkos::LayoutRight,Device> basis;
83  Kokkos::View<Vertex*,Kokkos::LayoutRight,Device> nodes;
84  Kokkos::View<VertexMap*,Kokkos::LayoutRight,Device> mapping;
86  int nguess;
88  double guess_min1;
89  double guess_min2;
90  double guess_max1;
91  double guess_max2;
92  double inv_guess_d1;
93  double inv_guess_d2;
94  Kokkos::View<int*,Kokkos::LayoutRight,Device> guess_list;
95  Kokkos::View<int**,Kokkos::LayoutRight,Device> guess_xtable;
96  Kokkos::View<int**,Kokkos::LayoutRight,Device> guess_count;
97  Kokkos::View<int**,Kokkos::LayoutRight,Device> guess_list_1d;
102  Kokkos::View<double*,Kokkos::LayoutRight,Device> psi_surf2;
105  int npsi00;
106  double psi00min;
107  double psi00max;
108  double dpsi00;
110  Kokkos::View<int*,Kokkos::LayoutRight,Device> rgn;
111  Kokkos::View<RZPair*,Kokkos::LayoutRight,Device> gx;
113  int nwall;
114  Kokkos::View<int*,Kokkos::LayoutRight,Device> wall_nodes;
115  Kokkos::View<int*,Kokkos::LayoutRight,Device> node_to_wall;
119  // Gyroaverage grid information
120  int nrho;
121  double rhomax;
122  double drho;
123  double phimin;
124  double phimax;
125 };
127 #include "cpp_grid.tpp"
128 #endif
KOKKOS_INLINE_FUNCTION void t_coeff(const SimdVector2D &x, const Simd< int > &itr, SimdGridVec &p) const
Definition: cpp_grid.tpp:236
double inv_delta_phi
Definition: cpp_grid.hpp:79
double guess_min1
Definition: cpp_grid.hpp:88
Kokkos::View< int **, Kokkos::LayoutRight, Device > guess_xtable
Definition: cpp_grid.hpp:95
Definition: cpp_grid.hpp:32
Definition: cpp_grid.hpp:52
int ntriangle
Number of grid triangles.
Definition: cpp_grid.hpp:74
double minval_psi_surf2
Definition: cpp_grid.hpp:100
Simd< double > x[3]
Definition: cpp_grid.hpp:7
Kokkos::View< int **, Kokkos::LayoutRight, Device > guess_count
Definition: cpp_grid.hpp:96
Definition: cpp_magnetic_field.hpp:9
Kokkos::View< int *, Kokkos::LayoutRight, Device > guess_list
Definition: cpp_grid.hpp:94
Definition: cpp_grid.hpp:38
int nrho
Definition: cpp_grid.hpp:120
int nplanes
Number of planes.
Definition: cpp_grid.hpp:76
KOKKOS_INLINE_FUNCTION void maxloc(Simd< int > &ml) const
Definition: cpp_grid.hpp:15
KOKKOS_INLINE_FUNCTION void search_ptl_1d(double psi, double &wp, int &ip) const
Definition: cpp_grid.tpp:301
double phimin
Definition: cpp_grid.hpp:123
Kokkos::View< double *, Kokkos::LayoutRight, Device > psi_surf2
Definition: cpp_grid.hpp:102
double wedge_angle
The size of the wedge (the model is periodic in phi, a angle of e.g. pi means half the tokamak is mod...
Definition: cpp_grid.hpp:77
double z
Definition: cpp_grid.hpp:29
int nwall
Definition: cpp_grid.hpp:113
Definition: cpp_grid.hpp:27
int npsi00
Definition: cpp_grid.hpp:105
double guess_min2
Definition: cpp_grid.hpp:89
KOKKOS_INLINE_FUNCTION void search_tr_check_guess(const SimdVector2D &x, const Simd< int > &old_itr, Simd< int > &itr, SimdGridVec &p) const
Definition: cpp_grid.tpp:256
Kokkos::View< double *, Kokkos::LayoutRight, Device > psi
An array of psi coordinates.
Definition: cpp_grid.hpp:81
KOKKOS_INLINE_FUNCTION void get_wall_index(const Simd< bool > &just_left_the_grid, const SimdVector2D &x, const Simd< int > &itr, const SimdGridVec &p, Simd< int > &widx) const
Definition: cpp_grid.tpp:434
double guess_max2
Definition: cpp_grid.hpp:91
Kokkos::View< int *, Kokkos::LayoutRight, Device > rgn
Definition: cpp_grid.hpp:110
double psi00max
Definition: cpp_grid.hpp:107
Kokkos::View< int *, Kokkos::LayoutRight, Device > basis
A basis for the guesses?
Definition: cpp_grid.hpp:82
int npsi_surf2
Definition: cpp_grid.hpp:99
double inv_guess_d1
Definition: cpp_grid.hpp:92
KOKKOS_INLINE_FUNCTION void t_coeff_mod(const MagneticField< Device > &magnetic_field, const SimdVector2D &xy, const Simd< double > &psiin, const Simd< int > &itr, SimdGridVec &p) const
Definition: cpp_grid.tpp:178
KOKKOS_INLINE_FUNCTION void wedge_modulo_phi(Simd< double > &phi_mod) const
Definition: cpp_grid.tpp:401
double phimax
Definition: cpp_grid.hpp:124
KOKKOS_INLINE_FUNCTION void search_tr2(const SimdVector2D &xy, Simd< int > &itr, SimdGridVec &pout) const
Definition: cpp_grid.tpp:101
int guess_list_len
Definition: cpp_grid.hpp:87
Definition: cpp_grid.hpp:23
Definition: cpp_grid.hpp:6
double rhomax
Definition: cpp_grid.hpp:121
int nguess
Definition: cpp_grid.hpp:86
Kokkos::View< int *, Kokkos::LayoutRight, Device > node_to_wall
Definition: cpp_grid.hpp:115
Kokkos::View< int *, Kokkos::LayoutRight, Device > wall_nodes
Definition: cpp_grid.hpp:114
int iphi_offset
Definition: cpp_grid.hpp:104
double r
Definition: cpp_grid.hpp:28
double dpsi00
Definition: cpp_grid.hpp:108
Definition: cpp_globals.hpp:54
Kokkos::View< int **, Kokkos::LayoutRight, Device > guess_list_1d
Definition: cpp_grid.hpp:97
int vertex[3]
Definition: cpp_grid.hpp:24
double psi00min
Definition: cpp_grid.hpp:106
double maxval_psi_surf2
Definition: cpp_grid.hpp:101
double inv_guess_d2
Definition: cpp_grid.hpp:93
int nnode
Number of grid nodes.
Definition: cpp_grid.hpp:75
RZPair vertex[3]
Definition: cpp_grid.hpp:33
KOKKOS_INLINE_FUNCTION const Simd< double > & operator[](int i) const
Definition: cpp_grid.hpp:10
double delta_phi
Distance between planes.
Definition: cpp_grid.hpp:78
double eps_flux_surface
The minimum difference in psi that counts as being on two different flux surfaces.
Definition: cpp_grid.hpp:117
Kokkos::View< VertexMap *, Kokkos::LayoutRight, Device > mapping
Definition: cpp_grid.hpp:84
double drho
Definition: cpp_grid.hpp:122
KOKKOS_INLINE_FUNCTION void check_triangle(const Simd< int > &itr, Simd< bool > &wasnt_in_triangle) const
Definition: cpp_grid.tpp:420
KOKKOS_INLINE_FUNCTION void charge_search_index(const MagneticField< Device > &magnetic_field, const SimdVector2D &x, const Simd< double > &phi, const Simd< double > &psi, SimdVector2D &xff, Simd< int > &itr, SimdGridVec &p) const
Definition: cpp_grid.tpp:352
Kokkos::View< Vertex *, Kokkos::LayoutRight, Device > nodes
Definition: cpp_grid.hpp:83
double guess_max1
Definition: cpp_grid.hpp:90
Kokkos::View< RZPair *, Kokkos::LayoutRight, Device > gx
Definition: cpp_grid.hpp:111