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