XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
grid_field.hpp
Go to the documentation of this file.
1 #ifndef GRID_FIELD_HPP
2 #define GRID_FIELD_HPP
3 #include "space_settings.hpp"
4 #include "NamelistReader.hpp"
5 
6 #include "globals.hpp"
7 #include "grid.hpp"
8 #include "linear_weights.hpp"
9 #include "gyro_radius.hpp"
10 #include "field.hpp"
11 
12 /* TorType specifies whether the field is a single plane or needs a plane dimension
13  * */
14 enum class TorType{
15  OnePlane,
17 };
18 
19 // General declaration
20 // 2x2 = 4 types of GridField available: With and without gyroaverage dimension, with and without plane dimension
21 template<class Device, VarType VT, PhiInterpType PIT, TorType TT, KinType KT, ScatterType ST = ScatterType::Atomic>
22 struct GridField;
23 
24 // "ScalarGridField"
25 template<class Device, VarType VT, PhiInterpType PIT>
28  using device_type = Device;
29  static constexpr KinType KT = KinType::DriftKin;
30 
31  Kokkos::View<field_type*,Kokkos::LayoutRight,Device> f;
32 
34  GridField(std::string name, int nphi, int nrho, int nnode) : f(name,nnode) {}
35  GridField(std::string name, int nnode) : f(name,nnode) {}
36  field_type* data() const {return f.data();}
37  int size() const {return f.size();}
38  int nnode() const {return f.extent(0);}
39  int nrhop1() const {return 1;}
40  int nphi() const {return 1;}
41 
42  KOKKOS_INLINE_FUNCTION bool is_allocated() const {return f.is_allocated();}
43  KOKKOS_INLINE_FUNCTION field_type& operator ()(int inode) const {return f(inode);}
44 
45  // Scatter to a node
46  KOKKOS_INLINE_FUNCTION void scatter(int node, const SimdPhiWeights<get_phi_wt_usage(PIT)>& phi_wts, int i_simd, double particle_weight) const{
47  f(node).scatter(phi_wts, i_simd, particle_weight);
48  }
49 
50  // Scatter to a triangle
51  KOKKOS_INLINE_FUNCTION void scatter(const Grid<DeviceType>& grid, int ithread, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, int i_simd, const SimdGyroWeights<DriftKin>& rho_wts, double particle_weight) const{
52  for (int j = 0; j<3; j++){
53  // Find triangle's nodes
54  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
55  double wp=grid_wts.p[j][i_simd];
56 
57  // Scatter to node
58  scatter(node, grid_wts.phi_wts, i_simd, wp*particle_weight);
59  }
60  }
61 
62  // Gather from a triangle
63  KOKKOS_INLINE_FUNCTION void gather(const Grid<Device> &grid, const SimdGridWeights<Order::One, PhiInterpType::None>& grid_wts, const Simd<double>& phi, Simd<double>& fld) const{
64  // Initialize local field to 0
65  fld = 0.0;
66 
67  for (int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
68  if(grid_wts.is_invalid(i_simd)) continue;
69 
70  // Loop over the 3 vertices of the grid triangle and add up the contributions from each
71  for (int ip = 0; ip<3; ip++){
72  int node = grid.get_node_index(grid_wts.itr[i_simd], ip);
73  double wp = grid_wts.p[ip][i_simd];
74  f(node).gather(fld,i_simd,wp);
75  }
76  }
77  }
78 
79  // Gather from a triangle
80  KOKKOS_INLINE_FUNCTION void gather(const Grid<Device> &grid, const SimdGridWeights<Order::One, PhiInterpType::Planes>& grid_wts, const Simd<double>& phi, Simd<double>& fld) const{
81  // Initialize local field to 0
82  fld = 0.0;
83 
84  for (int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
85  if(grid_wts.is_invalid(i_simd)) continue;
86 
87  // Loop over the 3 vertices of the grid triangle and add up the contributions from each
88  for (int ip = 0; ip<3; ip++){
89  int node = grid.get_node_index(grid_wts.itr[i_simd], ip);
90  double wp = grid_wts.p[ip][i_simd];
91  f(node).gather(fld,i_simd,wp,grid_wts.phi_wts);
92  }
93  }
94  }
95 
96  void reset_to_zero(){
97  int ndoubles_in_grid_field = f.size()*field_type::SIZE();
98  Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((double*)(data()), ndoubles_in_grid_field);
99  Kokkos::deep_copy(view_1d_double, 0.0);
100  }
101 
102  // TODO: Generalize this copy and these transposes for ndim etc
103  // Fill View with transposed data where inode is the contiguous index
104  // Ultimately, there should probably be an implementation GridField that has the transposed indices
105  void copy_to_double_view(const View<double*,CLayout,Device>& dest_view) const{
106  // Make an unmanaged view around the input field
107  View<double*,CLayout,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> f_unmanaged((double*)data(),nnode());
108 
109  Kokkos::deep_copy(dest_view, f_unmanaged);
110  }
111 
112  // Fill View with transposed data where inode is the contiguous index
113  // Ultimately, there should probably be an implementation GridField that has the transposed indices
114  void transpose_copy_to_double_view(const View<double**,CLayout,Device>& dest_view) const{
115  // Retrieve nphi from the Field of this GridField
116  constexpr int n_phi = field_type::NPHI();
117 
118  // Make an unmanaged view around the input field
119  View<double**,CLayout,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> f_unmanaged((double*)data(),nnode(), n_phi);
120 
121  // Copy f_unmanaged into iphi = 0 and iphi = 1 of dest_view
122  Kokkos::parallel_for("var_transpose_copy", Kokkos::RangePolicy<typename Device::execution_space>( 0, nnode()), KOKKOS_LAMBDA(const int inode){
123  for(int iphi=0; iphi<n_phi; iphi++){
124  dest_view(iphi, inode) = f_unmanaged(inode, iphi);
125  }
126  });
127  Kokkos::fence();
128  }
129 
130  // Transpose and copy data from a view where inode is the contiguous index
131  void transpose_copy_from_double_view(const View<double**,CLayout,Device>& src_view) const{
132  // Retrieve nphi from the Field of this GridField
133  constexpr int n_phi = field_type::NPHI();
134 
135  // Make an unmanaged view of the data
136  View<double**,CLayout,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> f_unmanaged((double*)data(),nnode(), n_phi);
137 
138  // Transpose from src_view into this gridfield
139  Kokkos::parallel_for("var_transpose_copy", Kokkos::RangePolicy<ExSpace>( 0, nnode()), KOKKOS_LAMBDA(const int inode){
140  for(int iphi=0; iphi<n_phi; iphi++){
141  f_unmanaged(inode, iphi) = src_view(iphi, inode);
142  }
143  });
144  Kokkos::fence();
145  }
146 
149  static KOKKOS_INLINE_FUNCTION void view_gather3(const Grid<DeviceType>& grid, const View<double*,CLayout,Device>& view1, const View<double*,CLayout,Device>& view2, const View<double*,CLayout,Device>& view3, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, double& val1, double& val2, double& val3, int i_simd){
150  val1=0.0;
151  val2=0.0;
152  val3=0.0;
153  for (int ip=0; ip<3; ip++){
154  int nd = grid.get_node_index(grid_wts.itr[i_simd], ip);
155  val1 += view1(nd)*grid_wts.p[ip][i_simd];
156  val2 += view2(nd)*grid_wts.p[ip][i_simd];
157  val3 += view3(nd)*grid_wts.p[ip][i_simd];
158  }
159  }
160 
161  static KOKKOS_INLINE_FUNCTION void view_gather(const Grid<DeviceType>& grid, const View<double*,CLayout,Device>& view, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, Simd<double>& val){
162  val = 0.0;
163  for (int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
164  if(grid_wts.itr[i_simd]<=0) continue;
165  for (int ip = 0; ip < 3; ip++){
166  int node = grid.get_node_index(grid_wts.itr[i_simd], ip);
167  val[i_simd] += grid_wts.p[ip][i_simd]*view(node);
168  }
169  }
170  }
171 
172  static KOKKOS_INLINE_FUNCTION void view_vec_odim_gather(const Grid<DeviceType>& grid, const View<Field<VarType::Vector,PhiInterpType::None>**,CLayout,Device>& view, int ind, const SimdGridWeights<Order::One, PhiInterpType::None>& grid_wts, SimdVector& val, int i_simd){
173  val.r[i_simd] = 0.0;
174  val.z[i_simd] = 0.0;
175  val.phi[i_simd] = 0.0;
176  for (int ip = 0; ip<3; ip++){
177  int node = grid.get_node_index(grid_wts.itr[i_simd], ip);
178  double wp = grid_wts.p[ip][i_simd];
179  view(ind,node).gather(val, i_simd, wp);
180  }
181  }
182 
183  static KOKKOS_INLINE_FUNCTION void view_gyro_scatter3(const Grid<DeviceType>& grid, const View<double**,CLayout,Device>& view1, const View<double**,CLayout,Device>& view2, const View<double**,CLayout,Device>& view3, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, double val1, double val2, double val3, int i_simd, const LinearWeights& rho_wts, bool is_gyro){
184  // Scatter moments into grid array
185  for (int ip = 0; ip < 3; ip++){
186  int node = grid.get_node_index(grid_wts.itr[i_simd], ip);
187  Kokkos::atomic_add(&(view1(rho_wts.i, node)), grid_wts.p[ip][i_simd]*rho_wts.w[0]*val1);
188  Kokkos::atomic_add(&(view2(rho_wts.i, node)), grid_wts.p[ip][i_simd]*rho_wts.w[0]*val2);
189  Kokkos::atomic_add(&(view3(rho_wts.i, node)), grid_wts.p[ip][i_simd]*rho_wts.w[0]*val3);
190  if(is_gyro){
191  Kokkos::atomic_add(&(view1(rho_wts.i+1, node)), grid_wts.p[ip][i_simd]*rho_wts.w[1]*val1);
192  Kokkos::atomic_add(&(view2(rho_wts.i+1, node)), grid_wts.p[ip][i_simd]*rho_wts.w[1]*val2);
193  Kokkos::atomic_add(&(view3(rho_wts.i+1, node)), grid_wts.p[ip][i_simd]*rho_wts.w[1]*val3);
194  }
195  }
196  }
197 
198  // view with outer dimension
199  static KOKKOS_INLINE_FUNCTION void view_odim_scatter(const Grid<DeviceType>& grid, const View<double**,CLayout,Device>& view, int ind, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, double val, int i_simd){
200  for (int j = 0; j<3; j++){
201  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
202  double wp=grid_wts.p[j][i_simd];
203 
204  Kokkos::atomic_add(&(view(ind,node)), wp*val);
205  }
206  }
207 
208  static KOKKOS_INLINE_FUNCTION void view_scatter(const Grid<DeviceType>& grid, const View<double*,CLayout,Device>& view, const SimdGridWeights<Order::One, PhiInterpType::None>& grid_wts, double val, int i_simd){
209  for (int j = 0; j<3; j++){
210  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
211  double wp=grid_wts.p[j][i_simd];
212 
213  Kokkos::atomic_add(&(view(node)), wp*val);
214  }
215  }
216 
217  static KOKKOS_INLINE_FUNCTION void view_ff_scatter(const Grid<DeviceType>& grid, const View<double**,CLayout,Device>& view, const SimdGridWeights<Order::One, PhiInterpType::Planes>& grid_wts, double wphi, double val, int i_simd){
218  for (int j = 0; j<3; j++){
219  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
220  double wp=grid_wts.p[j][i_simd];
221 
222  Kokkos::atomic_add(&(view(0,node)), wp*wphi*val);
223  Kokkos::atomic_add(&(view(1,node)), wp*(1.0-wphi)*val);
224  }
225  }
226 
227  static KOKKOS_INLINE_FUNCTION void view_odim_variance(const Grid<DeviceType>& grid, const View<double**,CLayout,Device>& view, const View<double**,CLayout,Device>& variance, int ind, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, double val, int i_simd){
228  for (int j = 0; j<3; j++){
229  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
230  double wp=grid_wts.p[j][i_simd];
231 
232  double tmp = view(ind,node) - wp*val;
233  Kokkos::atomic_add(&(variance(ind,node)), tmp*tmp);
234  }
235  }
236 
237  static KOKKOS_INLINE_FUNCTION void view_rep_scatter3(const Grid<DeviceType>& grid, const View<double***,CLayout,Device>& view, int ind1, int ind2, int ind3, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, double val1, double val2, double val3, int ithread, int i_simd){
238  // Scatter moments into grid array
239  for (int ip = 0; ip < 3; ip++){
240  int node = grid.get_node_index(grid_wts.itr[i_simd], ip);
241  double wp = grid_wts.p[ip][i_simd];
242 
243  access_add(&(view(ithread,node,ind1)),wp*val1);
244  access_add(&(view(ithread,node,ind2)),wp*val2);
245  access_add(&(view(ithread,node,ind3)),wp*val3);
246  }
247  }
248 };
249 
250 template<class Device, VarType VT, PhiInterpType PIT>
253  using device_type = Device;
254  static constexpr KinType KT = KinType::GyroKin;
255 
256  Kokkos::View<field_type**,Kokkos::LayoutRight,Device> f;
257 
259  GridField(std::string name, int nphi, int nrho, int nnode) : f(name,nnode, nrho+1) {}
260  GridField(std::string name, int nrho, int nnode) : f(name,nnode, nrho+1) {}
261  field_type* data() const {return f.data();}
262  int size() const {return f.size();}
263  int nnode() const {return f.extent(0);}
264  int nrhop1() const {return f.extent(1);}
265  int nphi() const {return 1;}
266  KOKKOS_INLINE_FUNCTION bool is_allocated() const {return f.is_allocated();}
267  KOKKOS_INLINE_FUNCTION field_type& operator ()(int inode, int irho) const {return f(inode, irho);}
268 
269  // Scatter to a node
270  KOKKOS_INLINE_FUNCTION void scatter(int node, const SimdPhiWeights<get_phi_wt_usage(PIT)>& phi_wts, const SimdGyroWeights<GyroKin>& rho_wts, int i_simd, double particle_weight) const{
271  int irho = rho_wts.irho(i_simd);
272  f(node,irho).scatter(rho_wts, phi_wts, i_simd, particle_weight, f(node,irho+1));
273  }
274 
275  // Scatter to a triangle (same as for DriftKin - consolidate)
276  KOKKOS_INLINE_FUNCTION void scatter(const Grid<DeviceType>& grid, int ithread, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, int i_simd, const SimdGyroWeights<GyroKin>& rho_wts, double particle_weight) const{
277  for (int j = 0; j<3; j++){
278  // Find triangle's nodes
279  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
280  double wp=grid_wts.p[j][i_simd];
281 
282  // Scatter to node
283  scatter(node, grid_wts.phi_wts, rho_wts, i_simd, wp*particle_weight);
284  }
285  }
286 
288  int ndoubles_in_grid_field = f.size()*field_type::SIZE();
289  Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((double*)(f.data()), ndoubles_in_grid_field);
290  Kokkos::deep_copy(view_1d_double, 0.0);
291  }
292 };
293 
294 /******** GridField with array replication ********/
295 template<class Device, VarType VT, PhiInterpType PIT>
298  using device_type = Device;
299  static constexpr KinType KT = KinType::DriftKin;
300 
301  Kokkos::View<field_type**,Kokkos::LayoutRight,Device> f;
302 
304  GridField(std::string name, int nphi, int nrho, int nnode) : f(name,get_num_cpu_threads(), nnode) {}
305  GridField(std::string name, int nnode) : f(name,get_num_cpu_threads(), nnode) {}
306  field_type* data() const {return f.data();}
307  int size() const {return f.size();}
308  int nnode() const {return f.extent(1);}
309  int nrhop1() const {return 1;}
310  int nphi() const {return 1;}
311  KOKKOS_INLINE_FUNCTION bool is_allocated() const {return f.is_allocated();}
312  KOKKOS_INLINE_FUNCTION field_type& operator ()(int ithread, int inode) const {return f(ithread, inode);}
313 
314  // Scatter to a node
315  KOKKOS_INLINE_FUNCTION void scatter(int ithread, int node, const SimdPhiWeights<get_phi_wt_usage(PIT)>& phi_wts, int i_simd, double particle_weight) const{
316  f(ithread,node).scatter(phi_wts, i_simd, particle_weight);
317  }
318 
319  // Scatter to a triangle
320  KOKKOS_INLINE_FUNCTION void scatter(const Grid<DeviceType>& grid, int ithread, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, int i_simd, const SimdGyroWeights<DriftKin>& rho_wts, double particle_weight) const{
321  for (int j = 0; j<3; j++){
322  // Find triangle's nodes
323  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
324  double wp=grid_wts.p[j][i_simd];
325 
326  // Scatter to node
327  scatter(ithread, node, grid_wts.phi_wts, i_simd, wp*particle_weight);
328  }
329  }
330 
332  int ndoubles_in_grid_field = f.size()*field_type::SIZE();
333  Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((double*)(f.data()), ndoubles_in_grid_field);
334  Kokkos::deep_copy(view_1d_double, 0.0);
335  }
336 };
337 
338 template<class Device, VarType VT, PhiInterpType PIT>
341  using device_type = Device;
342  static constexpr KinType KT = KinType::GyroKin;
343 
344  Kokkos::View<field_type***,Kokkos::LayoutRight,Device> f;
345 
347  GridField(std::string name, int nphi, int nrho, int nnode) : f(name,get_num_cpu_threads(),nnode, nrho+1) {}
348  GridField(std::string name, int nrho, int nnode) : f(name,get_num_cpu_threads(),nnode, nrho+1) {}
349  field_type* data() const {return f.data();}
350  int size() const {return f.size();}
351  int nnode() const {return f.extent(1);}
352  int nrhop1() const {return f.extent(2);}
353  int nphi() const {return 1;}
354  KOKKOS_INLINE_FUNCTION bool is_allocated() const {return f.is_allocated();}
355  KOKKOS_INLINE_FUNCTION field_type& operator ()(int ithread, int inode, int irho) const {return f(ithread,inode, irho);}
356 
357  // Scatter to a node
358  KOKKOS_INLINE_FUNCTION void scatter(int ithread, int node, const SimdPhiWeights<get_phi_wt_usage(PIT)>& phi_wts, const SimdGyroWeights<GyroKin>& rho_wts, int i_simd, double particle_weight) const{
359  int irho = rho_wts.irho(i_simd);
360  f(ithread,node,irho).scatter(rho_wts, phi_wts, i_simd, particle_weight, f(ithread,node,irho+1));
361  }
362 
363  // Scatter to a triangle (same as for DriftKin - consolidate)
364  KOKKOS_INLINE_FUNCTION void scatter(const Grid<DeviceType>& grid, int ithread, const SimdGridWeights<Order::One, PIT_GLOBAL>& grid_wts, int i_simd, const SimdGyroWeights<GyroKin>& rho_wts, double particle_weight) const{
365  for (int j = 0; j<3; j++){
366  // Find triangle's nodes
367  int node=grid.get_node_index(grid_wts.itr[i_simd], j);
368  double wp=grid_wts.p[j][i_simd];
369 
370  // Scatter to node
371  scatter(ithread, node, grid_wts.phi_wts, rho_wts, i_simd, wp*particle_weight);
372  }
373  }
374 
376  int ndoubles_in_grid_field = f.size()*field_type::SIZE();
377  Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((double*)(f.data()), ndoubles_in_grid_field);
378  Kokkos::deep_copy(view_1d_double, 0.0);
379  }
380 };
381 /************/
382 
383 template<class Device, VarType VT, PhiInterpType PIT>
386  using device_type = Device;
387  static constexpr KinType KT = KinType::DriftKin;
388 
389  Kokkos::View<field_type**,Kokkos::LayoutRight,Device> f;
390 
392  GridField(std::string name, int nphi, int nrho, int nnode) : f(name,nphi, nnode) {}
393  GridField(std::string name, int nphi, int nnode) : f(name,nphi, nnode) {}
394  field_type* data() const {return f.data();}
395  int size() const {return f.size();}
396  int nnode() const {return f.extent(1);}
397  int nrhop1() const {return 1;}
398  int nphi() const {return f.extent(0);}
399  KOKKOS_INLINE_FUNCTION bool is_allocated() const {return f.is_allocated();}
400  KOKKOS_INLINE_FUNCTION field_type& operator ()(int iphi, int inode) const {return f(iphi, inode);}
401 
404  new_field.f = my_subview(f, subfield_idx);
405  return new_field;
406  }
407 
408  Kokkos::View<double**,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> unmanaged() const{
409  return Kokkos::View<double**,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>>((double*)(f.data()), f.layout());
410  }
411 };
412 
413 template<class Device, VarType VT, PhiInterpType PIT>
416  using device_type = Device;
417  static constexpr KinType KT = KinType::GyroKin;
418 
419  Kokkos::View<field_type***,Kokkos::LayoutRight,Device> f;
420 
422  GridField(std::string name, int nphi, int nrho, int nnode) : f(name,nphi, nnode, nrho+1) {}
423  field_type* data() const {return f.data();}
424  int size() const {return f.size();}
425  int nnode() const {return f.extent(1);}
426  int nrhop1() const {return f.extent(2);}
427  int nphi() const {return f.extent(0);}
428  KOKKOS_INLINE_FUNCTION bool is_allocated() const {return f.is_allocated();}
429  KOKKOS_INLINE_FUNCTION field_type& operator ()(int iphi, int inode, int irho) const {return f(iphi, inode, irho);}
430 };
431 
432 // For convenience
444 
445 
446 // Shallow copy if types are the same
447 template<typename T>
448 inline void grid_field_copy(T& dest, const T& src){
449  dest = src;
450 }
451 
452 // Allocate dest grid_field and copy data from src
453 template<typename T1, typename T2>
454 inline void grid_field_copy(T1& dest, const T2& src){
455  // Allocate device array
456  dest = T1("grid_field",src.nphi(), src.nrhop1()-1, src.nnode());
457  // Deep copy from host to device
458  Kokkos::deep_copy(dest.f, src.f);
459 }
460 
461 #endif
static KOKKOS_INLINE_FUNCTION void view_odim_scatter(const Grid< DeviceType > &grid, const View< double **, CLayout, Device > &view, int ind, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, double val, int i_simd)
Definition: grid_field.hpp:199
GridField< DeviceType, VarType::Vector2D, PhiInterpType::None, TorType::OnePlane, KinType::GyroKin > Efield2DGyroType
Definition: grid_field.hpp:441
Simd< double > r
Definition: simd.hpp:150
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:34
static KOKKOS_INLINE_FUNCTION void view_gather3(const Grid< DeviceType > &grid, const View< double *, CLayout, Device > &view1, const View< double *, CLayout, Device > &view2, const View< double *, CLayout, Device > &view3, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, double &val1, double &val2, double &val3, int i_simd)
Definition: grid_field.hpp:149
Definition: simd.hpp:149
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, int i_simd, const SimdGyroWeights< DriftKin > &rho_wts, double particle_weight) const
Definition: grid_field.hpp:320
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:392
GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::MultiplePlanes, KinType::DriftKin > PotType
Definition: grid_field.hpp:438
KOKKOS_INLINE_FUNCTION bool is_allocated() const
Definition: grid_field.hpp:42
GridField(std::string name, int nrho, int nnode)
Definition: grid_field.hpp:260
void transpose_copy_to_double_view(const View< double **, CLayout, Device > &dest_view) const
Definition: grid_field.hpp:114
KOKKOS_INLINE_FUNCTION int irho(int i_simd) const
Definition: gyro_radius.hpp:107
KOKKOS_INLINE_FUNCTION bool is_allocated() const
Definition: grid_field.hpp:266
static KOKKOS_INLINE_FUNCTION void view_gyro_scatter3(const Grid< DeviceType > &grid, const View< double **, CLayout, Device > &view1, const View< double **, CLayout, Device > &view2, const View< double **, CLayout, Device > &view3, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, double val1, double val2, double val3, int i_simd, const LinearWeights &rho_wts, bool is_gyro)
Definition: grid_field.hpp:183
GridField(std::string name, int nrho, int nnode)
Definition: grid_field.hpp:348
void copy_to_double_view(const View< double *, CLayout, Device > &dest_view) const
Definition: grid_field.hpp:105
static KOKKOS_INLINE_FUNCTION void view_ff_scatter(const Grid< DeviceType > &grid, const View< double **, CLayout, Device > &view, const SimdGridWeights< Order::One, PhiInterpType::Planes > &grid_wts, double wphi, double val, int i_simd)
Definition: grid_field.hpp:217
Definition: linear_weights.hpp:8
Kokkos::View< field_type **, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:256
Definition: globals.hpp:89
Definition: grid_weights.hpp:47
KOKKOS_INLINE_FUNCTION bool is_allocated() const
Definition: grid_field.hpp:399
GridField(std::string name, int nphi, int nnode)
Definition: grid_field.hpp:393
GridField(std::string name, int nnode)
Definition: grid_field.hpp:35
Kokkos::View< double **, Kokkos::LayoutRight, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged > > unmanaged() const
Definition: grid_field.hpp:408
void scatter(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, const GridFieldPack< DeviceType, PIT > &gfpack, const Species< DeviceType > &species, const Charge< DeviceType, KT > &charge)
Definition: scatter.cpp:234
GridField< DeviceType, VarType::Vector2D, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > Efield2DType
Definition: grid_field.hpp:437
GridField< DeviceType, VarType::Vector, PhiInterpType::Planes, TorType::MultiplePlanes, KinType::DriftKin > EfieldType
Definition: grid_field.hpp:436
KOKKOS_INLINE_FUNCTION bool is_allocated() const
Definition: grid_field.hpp:311
Kokkos::LayoutRight CLayout
Definition: space_settings.hpp:67
GridField< DeviceType, VarType::Vector2D, PIT_GLOBAL, TorType::OnePlane, KinType::DriftKin > E00Type
Definition: grid_field.hpp:439
KOKKOS_INLINE_FUNCTION bool is_allocated() const
Definition: grid_field.hpp:428
constexpr KOKKOS_INLINE_FUNCTION PhiWtUsage get_phi_wt_usage(PhiInterpType PIT)
Definition: grid_weights.hpp:15
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:304
Definition: grid_field.hpp:22
KOKKOS_INLINE_FUNCTION void gather(const Grid< Device > &grid, const SimdGridWeights< Order::One, PhiInterpType::Planes > &grid_wts, const Simd< double > &phi, Simd< double > &fld) const
Definition: grid_field.hpp:80
GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::DriftKin > AxisymPotType
Definition: grid_field.hpp:435
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, int i_simd, const SimdGyroWeights< DriftKin > &rho_wts, double particle_weight) const
Definition: grid_field.hpp:51
Definition: grid_weights.hpp:18
TorType
Definition: grid_field.hpp:14
Definition: gyro_radius.hpp:114
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, int i_simd, const SimdGyroWeights< GyroKin > &rho_wts, double particle_weight) const
Definition: grid_field.hpp:276
Definition: gyro_radius.hpp:84
Kokkos::View< field_type *, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:31
KOKKOS_INLINE_FUNCTION void scatter(int ithread, int node, const SimdPhiWeights< get_phi_wt_usage(PIT)> &phi_wts, const SimdGyroWeights< GyroKin > &rho_wts, int i_simd, double particle_weight) const
Definition: grid_field.hpp:358
KOKKOS_INLINE_FUNCTION void access_add(T *addr, T val)
Definition: access_add.hpp:40
KOKKOS_INLINE_FUNCTION void scatter(int node, const SimdPhiWeights< get_phi_wt_usage(PIT)> &phi_wts, int i_simd, double particle_weight) const
Definition: grid_field.hpp:46
static KOKKOS_INLINE_FUNCTION void view_odim_variance(const Grid< DeviceType > &grid, const View< double **, CLayout, Device > &view, const View< double **, CLayout, Device > &variance, int ind, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, double val, int i_simd)
Definition: grid_field.hpp:227
void grid_field_copy(T &dest, const T &src)
Definition: grid_field.hpp:448
void transpose_copy_from_double_view(const View< double **, CLayout, Device > &src_view) const
Definition: grid_field.hpp:131
KOKKOS_INLINE_FUNCTION int get_node_index(int triangle_index, int tri_vertex_index) const
Definition: grid.tpp:160
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:259
KOKKOS_INLINE_FUNCTION void scatter(int ithread, int node, const SimdPhiWeights< get_phi_wt_usage(PIT)> &phi_wts, int i_simd, double particle_weight) const
Definition: grid_field.hpp:315
double w[2]
Definition: linear_weights.hpp:10
Definition: globals.hpp:90
GridField< DeviceType, VarType::Scalar, PhiInterpType::None, TorType::OnePlane, KinType::DriftKin > ScalarGridField
Definition: grid_field.hpp:433
GridField< Device, VT, PIT, TorType::OnePlane, KinType::DriftKin > subfield(int subfield_idx) const
Definition: grid_field.hpp:402
static KOKKOS_INLINE_FUNCTION void view_vec_odim_gather(const Grid< DeviceType > &grid, const View< Field< VarType::Vector, PhiInterpType::None > **, CLayout, Device > &view, int ind, const SimdGridWeights< Order::One, PhiInterpType::None > &grid_wts, SimdVector &val, int i_simd)
Definition: grid_field.hpp:172
static KOKKOS_INLINE_FUNCTION void view_scatter(const Grid< DeviceType > &grid, const View< double *, CLayout, Device > &view, const SimdGridWeights< Order::One, PhiInterpType::None > &grid_wts, double val, int i_simd)
Definition: grid_field.hpp:208
Simd< double > phi
Definition: simd.hpp:152
KOKKOS_INLINE_FUNCTION void gather(const Grid< Device > &grid, const SimdGridWeights< Order::One, PhiInterpType::None > &grid_wts, const Simd< double > &phi, Simd< double > &fld) const
Definition: grid_field.hpp:63
Simd< double > z
Definition: simd.hpp:151
int i
Definition: linear_weights.hpp:9
KinType
Definition: globals.hpp:88
Definition: field.hpp:45
Kokkos::View< field_type ***, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:419
GridField< DeviceType, VarType::Vector2D, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > E00GyroType
Definition: grid_field.hpp:443
Kokkos::View< field_type **, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:301
Kokkos::View< T *, Kokkos::LayoutRight, Device > my_subview(const Kokkos::View< T ****, Kokkos::LayoutRight, Device > &view, int i, int j, int k)
Definition: my_subview.hpp:8
GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > PotGyroType
Definition: grid_field.hpp:442
KOKKOS_INLINE_FUNCTION void scatter(int node, const SimdPhiWeights< get_phi_wt_usage(PIT)> &phi_wts, const SimdGyroWeights< GyroKin > &rho_wts, int i_simd, double particle_weight) const
Definition: grid_field.hpp:270
KOKKOS_INLINE_FUNCTION bool is_allocated() const
Definition: grid_field.hpp:354
int get_num_cpu_threads()
Definition: globals.hpp:17
Kokkos::View< field_type ***, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:344
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:422
static KOKKOS_INLINE_FUNCTION void view_gather(const Grid< DeviceType > &grid, const View< double *, CLayout, Device > &view, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, Simd< double > &val)
Definition: grid_field.hpp:161
void parallel_for(const std::string name, int n_ptl, Function func, Option option, HostAoSoA aosoa_h, DeviceAoSoA aosoa_d)
Definition: streamed_parallel_for.hpp:252
GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::DriftKin > OnePlanePotType
Definition: grid_field.hpp:434
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, int i_simd, const SimdGyroWeights< GyroKin > &rho_wts, double particle_weight) const
Definition: grid_field.hpp:364
GridField< DeviceType, VarType::Vector, PhiInterpType::Planes, TorType::OnePlane, KinType::GyroKin > EfieldGyroType
Definition: grid_field.hpp:440
Kokkos::View< field_type **, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:389
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:347
static KOKKOS_INLINE_FUNCTION void view_rep_scatter3(const Grid< DeviceType > &grid, const View< double ***, CLayout, Device > &view, int ind1, int ind2, int ind3, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, double val1, double val2, double val3, int ithread, int i_simd)
Definition: grid_field.hpp:237