24 template<
class Device, VarType VT, PhiInterpType PIT, TorType TT, KinType KT, ScatterType ST = ScatterType::Atomic>
27 template<
class Device, VarType VT, PhiInterpType PIT>
30 Kokkos::View<field_type*,Kokkos::LayoutRight,Device>
f;
33 GridField(std::string name,
int nphi,
int nrho,
int nnode) : f(name,nnode) {}
34 GridField(std::string name,
int nnode) : f(name,nnode) {}
36 int size()
const {
return f.size();}
37 int nnode()
const {
return f.extent(0);}
39 int nphi()
const {
return 1;}
40 KOKKOS_INLINE_FUNCTION
field_type& operator ()(
int inode)
const {
return f(inode);}
44 f(node).scatter(wts, particle_weight);
49 for (
int j = 0; j<3; j++){
52 double wp=p[j][i_simd];
55 scatter(node, wts, wp*particle_weight);
60 int ndoubles_in_grid_field = f.size()*field_type::SIZE();
61 Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((
double*)(data()), ndoubles_in_grid_field);
62 Kokkos::deep_copy(view_1d_double, 0.0);
70 View<double*,CLayout,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> f_unmanaged((
double*)data(),nnode());
72 Kokkos::deep_copy(dest_view, f_unmanaged);
79 constexpr
int n_phi = field_type::NPHI();
82 View<double**,CLayout,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> f_unmanaged((
double*)data(),nnode(), n_phi);
85 Kokkos::parallel_for(
"var_transpose_copy", Kokkos::RangePolicy<ExSpace>( 0, nnode()), KOKKOS_LAMBDA(
const int inode){
86 for(
int iphi=0; iphi<n_phi; iphi++){
87 dest_view(iphi, inode) = f_unmanaged(inode, iphi);
96 constexpr
int n_phi = field_type::NPHI();
99 View<double**,CLayout,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> f_unmanaged((
double*)data(),nnode(), n_phi);
102 Kokkos::parallel_for(
"var_transpose_copy", Kokkos::RangePolicy<ExSpace>( 0, nnode()), KOKKOS_LAMBDA(
const int inode){
103 for(
int iphi=0; iphi<n_phi; iphi++){
104 f_unmanaged(inode, iphi) = src_view(iphi, inode);
111 template<
class Device, VarType VT, PhiInterpType PIT>
114 Kokkos::View<field_type**,Kokkos::LayoutRight,Device>
f;
117 GridField(std::string name,
int nphi,
int nrho,
int nnode) : f(name,nnode, nrho+1) {}
118 GridField(std::string name,
int nrho,
int nnode) : f(name,nnode, nrho+1) {}
120 int size()
const {
return f.size();}
121 int nnode()
const {
return f.extent(0);}
124 KOKKOS_INLINE_FUNCTION
field_type& operator ()(
int inode,
int irho)
const {
return f(inode, irho);}
130 int irho = wts.rho[0].i;
132 int irho = wts.rho.i;
134 f(node,irho).scatter(wts, particle_weight, f(node,irho+1));
139 for (
int j = 0; j<3; j++){
142 double wp=p[j][i_simd];
145 scatter(node, wts, wp*particle_weight);
150 int ndoubles_in_grid_field = f.size()*field_type::SIZE();
151 Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((
double*)(f.data()), ndoubles_in_grid_field);
152 Kokkos::deep_copy(view_1d_double, 0.0);
157 template<
class Device, VarType VT, PhiInterpType PIT>
160 Kokkos::View<field_type**,Kokkos::LayoutRight,Device>
f;
166 int size()
const {
return f.size();}
167 int nnode()
const {
return f.extent(1);}
170 KOKKOS_INLINE_FUNCTION
field_type& operator ()(
int ithread,
int inode)
const {
return f(ithread, inode);}
174 f(ithread,node).scatter(wts, particle_weight);
179 for (
int j = 0; j<3; j++){
182 double wp=p[j][i_simd];
185 scatter(ithread, node, wts, wp*particle_weight);
190 int ndoubles_in_grid_field = f.size()*field_type::SIZE();
191 Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((
double*)(f.data()), ndoubles_in_grid_field);
192 Kokkos::deep_copy(view_1d_double, 0.0);
196 template<
class Device, VarType VT, PhiInterpType PIT>
199 Kokkos::View<field_type***,Kokkos::LayoutRight,Device>
f;
205 int size()
const {
return f.size();}
206 int nnode()
const {
return f.extent(1);}
209 KOKKOS_INLINE_FUNCTION
field_type& operator ()(
int ithread,
int inode,
int irho)
const {
return f(ithread,inode, irho);}
215 int irho = wts.rho[0].i;
217 int irho = wts.rho.i;
219 f(ithread,node,irho).scatter(wts, particle_weight, f(ithread,node,irho+1));
224 for (
int j = 0; j<3; j++){
227 double wp=p[j][i_simd];
230 scatter(ithread, node, wts, wp*particle_weight);
235 int ndoubles_in_grid_field = f.size()*field_type::SIZE();
236 Kokkos::View<double*,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>> view_1d_double((
double*)(f.data()), ndoubles_in_grid_field);
237 Kokkos::deep_copy(view_1d_double, 0.0);
242 template<
class Device, VarType VT, PhiInterpType PIT>
245 Kokkos::View<field_type**,Kokkos::LayoutRight,Device>
f;
248 GridField(std::string name,
int nphi,
int nrho,
int nnode) : f(name,nphi, nnode) {}
249 GridField(std::string name,
int nphi,
int nnode) : f(name,nphi, nnode) {}
251 int size()
const {
return f.size();}
252 int nnode()
const {
return f.extent(1);}
254 int nphi()
const {
return f.extent(0);}
255 KOKKOS_INLINE_FUNCTION
field_type& operator ()(
int iphi,
int inode)
const {
return f(iphi, inode);}
263 Kokkos::View<double**,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>>
unmanaged(){
264 return Kokkos::View<double**,Kokkos::LayoutRight,Device,Kokkos::MemoryTraits<Kokkos::Unmanaged>>((
double*)(f.data()), f.layout());
268 template<
class Device, VarType VT, PhiInterpType PIT>
271 Kokkos::View<field_type***,Kokkos::LayoutRight,Device>
f;
274 GridField(std::string name,
int nphi,
int nrho,
int nnode) : f(name,nphi, nnode, nrho+1) {}
276 int size()
const {
return f.size();}
277 int nnode()
const {
return f.extent(1);}
279 int nphi()
const {
return f.extent(0);}
280 KOKKOS_INLINE_FUNCTION
field_type& operator ()(
int iphi,
int inode,
int irho)
const {
return f(iphi, inode, irho);}
int size() const
Definition: grid_field.hpp:251
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:33
int nnode() const
Definition: grid_field.hpp:206
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:248
int nphi() const
Definition: grid_field.hpp:208
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const Simd< int > &itr, const SimdGridVec &p, int i_simd, const FieldWeights< GyroKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:223
int size() const
Definition: grid_field.hpp:36
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const Simd< int > &itr, const SimdGridVec &p, int i_simd, const FieldWeights< DriftKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:48
GridField(std::string name, int nrho, int nnode)
Definition: grid_field.hpp:118
void transpose_copy_to_double_view(const View< double **, CLayout, Device > &dest_view) const
Definition: grid_field.hpp:77
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const Simd< int > &itr, const SimdGridVec &p, int i_simd, const FieldWeights< GyroKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:138
GridField(std::string name, int nrho, int nnode)
Definition: grid_field.hpp:203
KOKKOS_INLINE_FUNCTION void scatter(int node, const FieldWeights< GyroKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:127
void copy_to_double_view(const View< double *, CLayout, Device > &dest_view) const
Definition: grid_field.hpp:68
int size() const
Definition: grid_field.hpp:166
KOKKOS_INLINE_FUNCTION void scatter(const Grid< DeviceType > &grid, int ithread, const Simd< int > &itr, const SimdGridVec &p, int i_simd, const FieldWeights< DriftKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:178
int size() const
Definition: grid_field.hpp:120
Definition: field_weights.hpp:13
Kokkos::View< field_type **, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:114
Definition: globals.hpp:83
GridField(std::string name, int nphi, int nnode)
Definition: grid_field.hpp:249
GridField(std::string name, int nnode)
Definition: grid_field.hpp:34
field_type * data() const
Definition: grid_field.hpp:165
int nphi() const
Definition: grid_field.hpp:39
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:240
int nrhop1() const
Definition: grid_field.hpp:278
GridField()
Definition: grid_field.hpp:273
int nrhop1() const
Definition: grid_field.hpp:253
KOKKOS_INLINE_FUNCTION void scatter(int node, const FieldWeights< DriftKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:43
void reset_to_zero()
Definition: grid_field.hpp:234
int size() const
Definition: grid_field.hpp:276
field_type * data() const
Definition: grid_field.hpp:250
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:163
Definition: grid_field.hpp:25
field_type * data() const
Definition: grid_field.hpp:35
void reset_to_zero()
Definition: grid_field.hpp:59
TorType
Definition: grid_field.hpp:17
int nphi() const
Definition: grid_field.hpp:123
int size() const
Definition: grid_field.hpp:205
GridField()
Definition: grid_field.hpp:32
int nrhop1() const
Definition: grid_field.hpp:122
Kokkos::View< field_type *, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:30
void transpose_copy_from_double_view(const View< double **, CLayout, Device > &src_view) const
Definition: grid_field.hpp:94
KOKKOS_INLINE_FUNCTION int get_node_index(int triangle_index, int tri_vertex_index) const
Definition: grid.tpp:792
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:117
Definition: globals.hpp:84
GridField< DeviceType, VarType::Scalar, PhiInterpType::None, TorType::OnePlane, KinType::DriftKin > ScalarGridField
Definition: grid_field.hpp:284
GridField< Device, VT, PIT, TorType::OnePlane, KinType::DriftKin > subfield(int subfield_idx) const
Definition: grid_field.hpp:257
GridField()
Definition: grid_field.hpp:247
field_type * data() const
Definition: grid_field.hpp:119
int nrhop1() const
Definition: grid_field.hpp:38
Kokkos::View< field_type ***, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:271
Definition: grid_structs.hpp:7
field_type * data() const
Definition: grid_field.hpp:275
int nphi() const
Definition: grid_field.hpp:169
int nphi() const
Definition: grid_field.hpp:254
field_type * data() const
Definition: grid_field.hpp:204
int nnode() const
Definition: grid_field.hpp:121
GridField()
Definition: grid_field.hpp:162
Kokkos::View< field_type **, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:160
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
int nrhop1() const
Definition: grid_field.hpp:207
int nnode() const
Definition: grid_field.hpp:252
int get_num_cpu_threads()
Definition: globals.hpp:17
Kokkos::View< field_type ***, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:199
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:274
int nnode() const
Definition: grid_field.hpp:167
GridField()
Definition: grid_field.hpp:116
void reset_to_zero()
Definition: grid_field.hpp:189
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(int ithread, int node, const FieldWeights< DriftKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:173
int nnode() const
Definition: grid_field.hpp:37
Kokkos::View< field_type **, Kokkos::LayoutRight, Device > f
Definition: grid_field.hpp:245
int nrhop1() const
Definition: grid_field.hpp:168
GridField()
Definition: grid_field.hpp:201
Kokkos::View< double **, Kokkos::LayoutRight, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged > > unmanaged()
Definition: grid_field.hpp:263
GridField(std::string name, int nphi, int nrho, int nnode)
Definition: grid_field.hpp:202
int nnode() const
Definition: grid_field.hpp:277
void reset_to_zero()
Definition: grid_field.hpp:149
int nphi() const
Definition: grid_field.hpp:279
GridField(std::string name, int nnode)
Definition: grid_field.hpp:164
KOKKOS_INLINE_FUNCTION void scatter(int ithread, int node, const FieldWeights< GyroKin, PIT > &wts, double particle_weight) const
Definition: grid_field.hpp:212