All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Go to the documentation of this file.
1 #ifndef GRID_HPP
2 #define GRID_HPP
4 #include "magnetic_field.hpp"
5 #include "grid_structs.hpp"
6 #include "grid_files.hpp"
8 // Grid class
9 template<class Device>
10 class Grid {
11  public:
13  // Constructor from inputs sent through fortran interface
14  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,
15  double guess_max2, double inv_guess_d1, double inv_guess_d2, int npsi_surf2, int iphi_offset, int npsi00, double psi00min, double psi00max,
16  double dpsi00, int nwall, double wedge_angle, double eq_x_psi,
17  double* psi, int* basis, Vertex* nodes, VertexMap* mapping, int* guess_list, int* guess_xtable, int* guess_count,
18  int* guess_list_1d, double* psi_surf2,double minval_psi_surf2, double maxval_psi_surf2,
19  int* wall_nodes, int* node_to_wall, int* rgn, RZPair* gx, int nrho, double rhomax, double phimax);
21  // Constructor from file inputs
22  Grid(GridFiles& grid_files, const MagneticField<Device>& magnetic_field, int nplanes_in, int wedge_n_in, int iphi_offset_in, int guess_table_size, int npsi00_in, int nrho_in, double rhomax_in);
24  // Default constructor
25  Grid(){}
27  KOKKOS_INLINE_FUNCTION void t_coeff(const SimdVector2D &x, const Simd<int>& itr, SimdGridVec &p) const;
29  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;
31  KOKKOS_INLINE_FUNCTION void search_tr2( const SimdVector2D &xy, Simd<int>& itr, SimdGridVec &pout ) const;
33  KOKKOS_INLINE_FUNCTION void search_tr_check_guess(const SimdVector2D &x, const Simd<int>& old_itr,Simd<int>& itr,SimdGridVec &p ) const;
35  KOKKOS_INLINE_FUNCTION void search_ptl_1d(double psi,double &wp,int &ip) const;
37  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;
39  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;
41  KOKKOS_INLINE_FUNCTION void wedge_modulo_phi(Simd<double>& phi_mod) const;
43  KOKKOS_INLINE_FUNCTION void check_triangle(const Simd<int>& itr,Simd<bool>& wasnt_in_triangle) const;
45  void draw_ascii_grid(MagneticField<Device> magnetic_field, double rmin, double rmax, double dr, double zmin, double zmax, double dz){
46  printf("\n\n******** PLOT OF GRID ******* \n");
47  Kokkos::View<int*,HostType> save_vert("save_vert", 1+((rmax-rmin)/dr));
48  for (double zplot = zmax; zplot>=zmin; zplot-=dz){
49  printf("\n");
50  int save_num = 0;
51  int rsave_ind = -1;
52  for (double rplot = rmin; rplot<=rmax; rplot+=dr){
53  rsave_ind++;
54  SimdVector2D x;
55  x.r = rplot;
56  x.z = zplot;
57  Simd<int> itr = -1;
59  Simd<double> phi = 0.001;
61  //magnetic_field.psi_bicub.interpol(x.r,x.z,0,0,psi);
63  // Get itr (triangle index)
64  SimdVector2D xff; // Unused
65  SimdGridVec p; // Unused
66  charge_search_index(magnetic_field, x, phi, psi,xff,itr, p);
67  if(itr[0]!=save_num || itr[0]!=save_vert[rsave_ind]){
68  if(itr[0]<10 && itr[0]>=0) printf("%d ",itr[0]);
69  else printf("%d ",itr[0]);
70  save_num = itr[0];
71  save_vert[rsave_ind] = itr[0];
72  } else {printf(" ");}
73  }
74  }
75  }
77  int ntriangle;
78  int nnode;
79  int nplanes;
80  double wedge_angle;
81  double delta_phi;
82  double inv_delta_phi;
84  Kokkos::View<double*,Kokkos::LayoutRight,Device> psi;
85  Kokkos::View<int*, Kokkos::LayoutRight,Device> basis;
86  Kokkos::View<Vertex*,Kokkos::LayoutRight,Device> nodes;
87  Kokkos::View<VertexMap*,Kokkos::LayoutRight,Device> mapping;
89  int nguess;
91  double guess_min1;
92  double guess_min2;
93  double guess_max1;
94  double guess_max2;
95  double inv_guess_d1;
96  double inv_guess_d2;
97  Kokkos::View<int*,Kokkos::LayoutRight,Device> guess_list;
98  Kokkos::View<int**,Kokkos::LayoutRight,Device> guess_xtable;
99  Kokkos::View<int**,Kokkos::LayoutRight,Device> guess_count;
100  Kokkos::View<int**,Kokkos::LayoutRight,Device> guess_list_1d;
105  Kokkos::View<double*,Kokkos::LayoutRight,Device> psi_surf2;
108  int npsi00;
109  double psi00min;
110  double psi00max;
111  double dpsi00;
113  Kokkos::View<int*,Kokkos::LayoutRight,Device> rgn;
114  Kokkos::View<RZPair*,Kokkos::LayoutRight,Device> gx;
116  int nwall;
117  Kokkos::View<int*,Kokkos::LayoutRight,Device> wall_nodes;
118  Kokkos::View<int*,Kokkos::LayoutRight,Device> node_to_wall;
122  // Gyroaverage grid information
123  int nrho;
124  double rhomax;
125  double drho;
126  double phimin;
127  double phimax;
128 };
130 #include "grid.tpp"
131 #endif
KOKKOS_INLINE_FUNCTION void t_coeff(const SimdVector2D &x, const Simd< int > &itr, SimdGridVec &p) const
Definition: grid.tpp:375
double inv_delta_phi
Definition: grid.hpp:82
double guess_min1
Definition: grid.hpp:91
Kokkos::View< int **, Kokkos::LayoutRight, Device > guess_xtable
Definition: grid.hpp:98
Definition: grid_structs.hpp:33
Definition: grid.hpp:25
int ntriangle
Number of grid triangles.
Definition: grid.hpp:77
double minval_psi_surf2
Definition: grid.hpp:103
Kokkos::View< int **, Kokkos::LayoutRight, Device > guess_count
Definition: grid.hpp:99
Definition: magnetic_field.hpp:9
Kokkos::View< int *, Kokkos::LayoutRight, Device > guess_list
Definition: grid.hpp:97
Definition: grid_files.hpp:9
Definition: grid.hpp:10
int nrho
Definition: grid.hpp:123
int nplanes
Number of planes.
Definition: grid.hpp:79
KOKKOS_INLINE_FUNCTION void search_ptl_1d(double psi, double &wp, int &ip) const
Definition: grid.tpp:437
double phimin
Definition: grid.hpp:126
Kokkos::View< double *, Kokkos::LayoutRight, Device > psi_surf2
Definition: grid.hpp:105
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: grid.hpp:80
int nwall
Definition: grid.hpp:116
Definition: grid_structs.hpp:28
int npsi00
Definition: grid.hpp:108
double guess_min2
Definition: grid.hpp:92
KOKKOS_INLINE_FUNCTION void search_tr_check_guess(const SimdVector2D &x, const Simd< int > &old_itr, Simd< int > &itr, SimdGridVec &p) const
Definition: grid.tpp:393
Kokkos::View< double *, Kokkos::LayoutRight, Device > psi
An array of psi coordinates.
Definition: grid.hpp:84
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: grid.tpp:569
double guess_max2
Definition: grid.hpp:94
Kokkos::View< int *, Kokkos::LayoutRight, Device > rgn
Definition: grid.hpp:113
double psi00max
Definition: grid.hpp:110
Kokkos::View< int *, Kokkos::LayoutRight, Device > basis
A basis for the guesses?
Definition: grid.hpp:85
int npsi_surf2
Definition: grid.hpp:102
double inv_guess_d1
Definition: grid.hpp:95
Simd< double > z
Definition: globals.hpp:107
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: grid.tpp:317
KOKKOS_INLINE_FUNCTION void wedge_modulo_phi(Simd< double > &phi_mod) const
Definition: grid.tpp:536
double phimax
Definition: grid.hpp:127
KOKKOS_INLINE_FUNCTION void search_tr2(const SimdVector2D &xy, Simd< int > &itr, SimdGridVec &pout) const
Definition: grid.tpp:243
int guess_list_len
Definition: grid.hpp:90
Definition: grid_structs.hpp:24
Definition: grid_structs.hpp:7
double rhomax
Definition: grid.hpp:124
int nguess
Definition: grid.hpp:89
Kokkos::View< int *, Kokkos::LayoutRight, Device > node_to_wall
Definition: grid.hpp:118
Simd< double > r
Definition: globals.hpp:106
Kokkos::View< int *, Kokkos::LayoutRight, Device > wall_nodes
Definition: grid.hpp:117
int iphi_offset
Definition: grid.hpp:107
Definition: magnetic_field.F90:1
double dpsi00
Definition: grid.hpp:111
void draw_ascii_grid(MagneticField< Device > magnetic_field, double rmin, double rmax, double dr, double zmin, double zmax, double dz)
Definition: grid.hpp:45
Definition: simd.hpp:18
Definition: globals.hpp:105
Kokkos::View< int **, Kokkos::LayoutRight, Device > guess_list_1d
Definition: grid.hpp:100
double psi00min
Definition: grid.hpp:109
double maxval_psi_surf2
Definition: grid.hpp:104
double inv_guess_d2
Definition: grid.hpp:96
int nnode
Number of grid nodes.
Definition: grid.hpp:78
double delta_phi
Distance between planes.
Definition: grid.hpp:81
double eps_flux_surface
The minimum difference in psi that counts as being on two different flux surfaces.
Definition: grid.hpp:120
Kokkos::View< VertexMap *, Kokkos::LayoutRight, Device > mapping
Definition: grid.hpp:87
double drho
Definition: grid.hpp:125
KOKKOS_INLINE_FUNCTION void check_triangle(const Simd< int > &itr, Simd< bool > &wasnt_in_triangle) const
Definition: grid.tpp:555
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: grid.tpp:487
Kokkos::View< Vertex *, Kokkos::LayoutRight, Device > nodes
Definition: grid.hpp:86
double guess_max1
Definition: grid.hpp:93
Kokkos::View< RZPair *, Kokkos::LayoutRight, Device > gx
Definition: grid.hpp:114