15 double* node_vol_ff_h,
17 double* node_vol_nearest_h,
double* node_vol_h,
double* node_area_h);
42 #ifndef NO_FORTRAN_MODULES
52 template<
class Device>
54 View<int**,CLayout,Device>
tr;
55 View<double***,CLayout,Device>
p;
56 View<double**,CLayout,Device>
dx;
66 template<
class Device>
70 template<
class Device2>
friend class Grid;
81 template<
class Device2>
135 #ifdef NO_FORTRAN_MODULES
136 m.gradient_matrices_h = gradient_matrices_h;
148 KOKKOS_INLINE_FUNCTION
void search_tr2_no_precheck(
const double r,
const double z,
int& itr,
double (&p)[3])
const;
154 KOKKOS_INLINE_FUNCTION
void psi_search(
double psi,
double &wp,
int &ip)
const;
162 template<PhiInterpType PIT>
165 template<PhiInterpType PIT>
168 template<PhiInterpType PIT>
171 template<PhiInterpType PIT>
174 template<PhiInterpType PIT>
177 template<PhiInterpType PIT>
180 template<PhiInterpType PIT>
193 KOKKOS_INLINE_FUNCTION
int get_node_index(
int triangle_index,
int tri_vertex_index)
const;
209 KOKKOS_INLINE_FUNCTION
int uses_rz_basis(
const int inode)
const;
211 KOKKOS_INLINE_FUNCTION
double get_r(
const int inode)
const;
213 KOKKOS_INLINE_FUNCTION
double get_dist2_from_node(
const int inode,
const double r,
const double z)
const;
215 KOKKOS_INLINE_FUNCTION
double get_dist_from_node(
const int inode,
const double r,
const double z)
const;
217 KOKKOS_INLINE_FUNCTION
void get_rz_coordinates(
const int inode,
double& r,
double& z)
const;
221 KOKKOS_INLINE_FUNCTION
void get_rz_coordinates(
const int itr,
const double (&p)[3],
double& r,
double& z)
const;
227 KOKKOS_INLINE_FUNCTION
int get_nearest_node(
const int itr,
const double (&p)[3])
const;
232 const View<int**,CLayout,DeviceType>& tr_node,
const View<double*,CLayout,DeviceType>& tr_area,
233 const View<double***, CLayout, DeviceType>& unit_vecs,
237 const View<int**,CLayout,DeviceType>& tr_node,
const int i,
238 double& dist_triangle,
double& dist_psi,
double& dist_theta)
const;
240 KOKKOS_INLINE_FUNCTION
void set_grad_matrix_from_psi_theta(
bool is_psi_dir,
int itr_pos,
int itr_neg,
double (&p_pos)[3],
double (&p_neg)[3],
double dl_pos,
double dl_neg,
int inode,
const Matrix<Device>& matrix)
const;
243 printf(
"\n\n******** PLOT OF GRID ******* \n");
244 Kokkos::View<int*,HostType> save_vert(
"save_vert", 1+((rmax-rmin)/dr));
245 for (
double zplot = zmax; zplot>=zmin; zplot-=dz){
249 for (
double rplot = rmin; rplot<=rmax; rplot+=dr){
260 if(itr[0]!=save_num || itr[0]!=save_vert[rsave_ind]){
261 if(itr[0]<10 && itr[0]>=0) printf(
"%d ",itr[0]);
262 else printf(
"%d ",itr[0]);
264 save_vert[rsave_ind] = itr[0];
265 }
else {printf(
" ");}
277 Kokkos::View<double*,Kokkos::LayoutRight,Device>
psi;
278 Kokkos::View<double*,Kokkos::LayoutRight,Device>
bfield;
281 Kokkos::View<int*, Kokkos::LayoutRight,Device>
basis;
282 Kokkos::View<Vertex*,Kokkos::LayoutRight,Device>
nodes;
283 Kokkos::View<VertexMap*,Kokkos::LayoutRight,Device>
mapping;
290 Kokkos::View<double*,Kokkos::LayoutRight,Device>
psi_surf2;
296 Kokkos::View<int*,Kokkos::LayoutRight,Device>
rgn;
297 Kokkos::View<RZPair*,Kokkos::LayoutRight,Device>
gx;
299 View<int**,CLayout,Device>
adj;
320 #ifdef NO_FORTRAN_MODULES
Projection< HostType > one_plane_ff
Definition: grid.hpp:317
KOKKOS_INLINE_FUNCTION void t_coeff(const SimdVector2D &x, const Simd< int > &itr, SimdGridVec &p) const
Definition: grid.tpp:500
double inv_delta_phi
1/delta_phi
Definition: grid.hpp:275
VolumesAndAreas volumes_and_areas
Definition: grid.hpp:313
Simd< double > r
Definition: simd.hpp:150
Definition: guess_list_1d.hpp:7
KOKKOS_INLINE_FUNCTION void get_grid_weights_ff(const MagneticField< Device > &magnetic_field, const SimdVector &v, const Simd< double > &psi_in, SimdVector2D &xff, SimdGridWeights< Order::One, PhiInterpType::Planes > &grid_wts) const
Definition: grid.tpp:664
void init_fortran_vols_and_areas(double *tr_area_h, double *tr_vol_h, double *node_vol_ff_h, double *node_vol_nearest_h, double *node_vol_h, double *node_area_h)
GuessList1D< Device > psi_guess
Definition: grid.hpp:294
Projection()
Definition: grid.hpp:58
KOKKOS_INLINE_FUNCTION double get_r_center_of_mass(int itr) const
Definition: grid.tpp:948
Grid()
Definition: grid.hpp:78
Definition: gradient_matrices.hpp:9
void mirror_copy(T1 &view_dest, const T2 &view_src)
Definition: my_mirror_view.hpp:122
void set_fortran_ptrs()
Definition: grid.hpp:41
Definition: grid_weights.hpp:77
Kokkos::View< double *, Kokkos::LayoutRight, Device > bfield
Magnetic field magnitude at nodes.
Definition: grid.hpp:278
int ntriangle
Number of grid triangles.
Definition: grid.hpp:270
KOKKOS_INLINE_FUNCTION double get_dist_from_node(const int inode, const double r, const double z) const
Definition: grid.tpp:1055
double minval_psi_surf2
Definition: grid.hpp:288
View< int **, CLayout, Device > adj
The indices of the three adjacent triangles for each triangle.
Definition: grid.hpp:299
KOKKOS_INLINE_FUNCTION bool node_is_in_private_region_no_wall(const int inode) const
Definition: grid.tpp:975
Definition: grid_weights.hpp:51
KOKKOS_INLINE_FUNCTION int get_characteristic_length(const View< int *, CLayout, DeviceType > &num_t_node, const View< int **, CLayout, DeviceType > &tr_node, const int i, double &dist_triangle, double &dist_psi, double &dist_theta) const
Definition: grid.tpp:1242
Definition: NamelistReader.hpp:193
Definition: magnetic_field.hpp:12
Grid< Device2 > mirror() const
Definition: grid.hpp:82
KOKKOS_INLINE_FUNCTION bool node_is_in_included_region(const int inode, const bool exclude_private_region) const
Definition: grid.tpp:988
View< double *, CLayout, HostType > node_area_h
Definition: grid.hpp:26
Definition: grid_files.hpp:17
KOKKOS_INLINE_FUNCTION void get_triangle_area_and_volume(const MagneticField< Device > &magnetic_field, int i, double &area, double &volume) const
Definition: grid.tpp:922
KOKKOS_INLINE_FUNCTION void t_coeff_mod(const MagneticField< Device > &magnetic_field, const double r, const double z, const double psiin, const int itr, double(&p)[3]) const
Definition: grid.tpp:379
int nplanes
Number of planes.
Definition: grid.hpp:272
KOKKOS_INLINE_FUNCTION void get_wall_index(const Simd< bool > &just_left_the_grid, const SimdVector2D &x, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, Simd< int > &widx) const
Definition: grid.tpp:803
Projection< HostType > half_plane_ff
Definition: grid.hpp:316
KOKKOS_INLINE_FUNCTION double get_nearest_midplane(double phi) const
Definition: grid.tpp:1165
KOKKOS_INLINE_FUNCTION int uses_rz_basis(const int inode) const
Definition: grid.tpp:1014
Kokkos::View< double *, Kokkos::LayoutRight, Device > psi_surf2
Definition: grid.hpp:290
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:273
int nwall
Definition: grid.hpp:302
View< double ***, CLayout, Device > p
Definition: grid.hpp:55
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:518
Kokkos::View< double *, Kokkos::LayoutRight, Device > psi
An array of psi coordinates.
Definition: grid.hpp:277
KOKKOS_INLINE_FUNCTION void get_rz_coordinates(const int inode, double &r, double &z) const
Definition: grid.tpp:1080
Definition: guess_table.hpp:8
GuessTable< Device > guess
Definition: grid.hpp:284
Kokkos::View< int *, Kokkos::LayoutRight, Device > rgn
Definition: grid.hpp:296
View< double *, CLayout, HostType > tr_area_h
Definition: grid.hpp:21
Kokkos::View< int *, Kokkos::LayoutRight, Device > basis
0 for Psi-theta, 1 for R-Z ; should be enum (and bool/char?)
Definition: grid.hpp:281
KOKKOS_INLINE_FUNCTION void get_grid_weights_no_ff(const MagneticField< Device > &magnetic_field, const SimdVector2D &x, const Simd< double > &psi_in, SimdGridWeights< Order::One, PhiInterpType::None > &grid_wts) const
Definition: grid.tpp:643
int npsi_surf2
Definition: grid.hpp:287
KOKKOS_INLINE_FUNCTION int get_nearest_node(const Simd< int > &itr, const SimdGridVec &p, int i_simd) const
Definition: grid.tpp:1137
KOKKOS_INLINE_FUNCTION int get_node_index(int triangle_index, int tri_vertex_index) const
Definition: grid.tpp:891
KOKKOS_INLINE_FUNCTION double get_r(const int inode) const
Definition: grid.tpp:1026
KOKKOS_INLINE_FUNCTION bool node_is_inside_psi_range(const MagneticField< Device > &magnetic_field, const int node) const
Definition: grid.tpp:865
VolumesAndAreas(int ntriangle_in, int nnode_in)
Definition: grid.hpp:30
KOKKOS_INLINE_FUNCTION void nearest_node(const SimdGridWeights< Order::One, PIT > &grid_wts, SimdGridWeights< Order::Zero, PIT > &grid_wts0) const
Definition: grid.tpp:735
KOKKOS_INLINE_FUNCTION int get_plane_index(double phi) const
Definition: grid.tpp:878
KOKKOS_INLINE_FUNCTION void search_tr2_no_precheck(const double r, const double z, int &itr, double(&p)[3]) const
Definition: grid.tpp:253
KOKKOS_INLINE_FUNCTION void wedge_modulo_phi(Simd< double > &phi_mod) const
Definition: grid.tpp:773
Simd< double > phi
Definition: simd.hpp:152
View< double *, CLayout, HostType > tr_vol_h
Definition: grid.hpp:22
KOKKOS_INLINE_FUNCTION void search_tr2(const SimdVector2D &xy, Simd< int > &itr, SimdGridVec &pout) const
Definition: grid.tpp:304
Definition: matrix.hpp:13
KOKKOS_INLINE_FUNCTION void follow_field_to_midplane(const MagneticField< Device > &magnetic_field, const SimdVector2D &x, const Simd< double > &phi, SimdVector2D &xff) const
Definition: grid.tpp:609
Simd< double > z
Definition: simd.hpp:151
KOKKOS_INLINE_FUNCTION double node_area_to_volume(const MagneticField< Device > &magnetic_field, double area, int node_index) const
Definition: grid.tpp:907
Definition: grid_structs.hpp:7
KOKKOS_INLINE_FUNCTION bool node_is_in_region_1_or_2_no_wall(const int inode) const
Definition: grid.tpp:963
View< T *, CLayout, Device > my_mirror_view(const View< T *, CLayout, Device > &view, Device nd)
Definition: my_mirror_view.hpp:14
Kokkos::View< int *, Kokkos::LayoutRight, Device > node_to_wall
Definition: grid.hpp:306
Kokkos::View< int *, Kokkos::LayoutRight, Device > wall_nodes
Definition: grid.hpp:305
KOKKOS_INLINE_FUNCTION double get_dist2_from_node(const int inode, const double r, const double z) const
Definition: grid.tpp:1041
Definition: grid_weights.hpp:56
View< double *, CLayout, HostType > node_vol_h
Definition: grid.hpp:25
UniformRange psi00
Definition: grid.hpp:291
View< int **, CLayout, Device > tr
Definition: grid.hpp:54
Projection(int nnode)
Definition: grid.hpp:59
Definition: magnetic_field.F90:1
void draw_ascii_grid(MagneticField< Device > magnetic_field, double rmin, double rmax, double dr, double zmin, double zmax, double dz)
Definition: grid.hpp:242
KOKKOS_INLINE_FUNCTION void set_gradient_mat_triangle(const View< int *, CLayout, DeviceType > &num_t_node, const View< int **, CLayout, DeviceType > &tr_node, const View< double *, CLayout, DeviceType > &tr_area, const View< double ***, CLayout, DeviceType > &unit_vecs, const int i, const GradientMatrices< Device > &gradient_matrices) const
Definition: grid.tpp:1180
KOKKOS_INLINE_FUNCTION void get_grid_weights(const MagneticField< Device > &magnetic_field, const SimdVector &v, const Simd< double > &psi, SimdVector2D &xff, SimdGridWeights< Order::One, PIT > &grid_wts) const
Definition: grid.tpp:688
double maxval_psi_surf2
Definition: grid.hpp:289
int nnode
Number of grid nodes.
Definition: grid.hpp:271
double delta_phi
Distance between planes.
Definition: grid.hpp:274
double eps_flux_surface
The minimum difference in psi that counts as being on two different flux surfaces.
Definition: grid.hpp:308
Kokkos::View< VertexMap *, Kokkos::LayoutRight, Device > mapping
Definition: grid.hpp:283
KOKKOS_INLINE_FUNCTION void psi_search(double psi, double &wp, int &ip) const
Definition: grid.tpp:562
View< double **, CLayout, Device > dx
Definition: grid.hpp:56
KOKKOS_INLINE_FUNCTION void set_grad_matrix_from_psi_theta(bool is_psi_dir, int itr_pos, int itr_neg, double(&p_pos)[3], double(&p_neg)[3], double dl_pos, double dl_neg, int inode, const Matrix< Device > &matrix) const
Definition: grid.tpp:1367
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:68
View< double *, CLayout, HostType > node_vol_nearest_h
Definition: grid.hpp:24
VolumesAndAreas()
Definition: grid.hpp:28
KOKKOS_INLINE_FUNCTION bool node_is_in_region_1_or_2(const MagneticField< Device > &magnetic_field, const int inode) const
Definition: grid.tpp:1002
Kokkos::View< Vertex *, Kokkos::LayoutRight, Device > nodes
Definition: grid.hpp:282
Kokkos::View< RZPair *, Kokkos::LayoutRight, Device > gx
Definition: grid.hpp:297
View< double **, CLayout, HostType > node_vol_ff_h
Definition: grid.hpp:23