7 extern "C" void f0_init_decomposed_ptrs(
double* f0_T_ev_cpp,
double* f0_inv_grid_vol_cpp,
double* f0_grid_vol_cpp,
8 double* f0_grid_vol_vonly_cpp,
double* f0_n_Ta_cpp,
double* f0_den_cpp,
11 extern "C" void f0_set_ptrs(
int nnode,
double* f0_delta_n_cpp,
double* f0_delta_u_cpp,
double* f0_delta_T_cpp);
12 extern "C" void set_f0_f0g_ptr(
int f0_inode1,
int f0_inode2,
double* f0_f0g_loc);
34 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_T_ev;
36 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_grid_vol;
38 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_n_Ta;
39 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_den;
40 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_flow;
45 :
f0_T_ev(
"f0_T_ev", nsp, pol_decomp.nnodes),
49 f0_n_Ta(
"f0_n_Ta", nsp, pol_decomp.nnodes),
50 f0_den(
"f0_den", nsp, pol_decomp.nnodes),
51 f0_flow(
"f0_flow", nsp, pol_decomp.nnodes)
53 #ifndef NO_FORTRAN_MODULES
72 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_delta_n;
73 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_delta_u;
74 Kokkos::View<double**,Kokkos::LayoutRight, HostType>
f0_delta_T;
116 printf(
"ISP ERROR in for_all_nonadiabatic_sepcies: isp=%d",isp);
177 max_n_ptl = std::max(max_n_ptl,species.
n_ptl);
189 species.
particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>();
193 particles_d_has_owner =
false;
210 f0_delta_n = View<double**,CLayout, HostType>(
"f0_delta_n", nspecies, grid_nnode);
211 f0_delta_u = View<double**,CLayout, HostType>(
"f0_delta_u", nspecies, grid_nnode);
212 f0_delta_T = View<double**,CLayout, HostType>(
"f0_delta_T", nspecies, grid_nnode);
215 set_unmanaged_f0_species_view(f0_delta_n, species.
idx, species.
f0.delta_n_h);
216 set_unmanaged_f0_species_view(f0_delta_u, species.
idx, species.
f0.delta_u_h);
217 set_unmanaged_f0_species_view(f0_delta_T, species.
idx, species.
f0.delta_T_h);
219 #ifndef NO_FORTRAN_MODULES
221 f0_set_ptrs(grid_nnode, f0_delta_n.data(), f0_delta_u.data(), f0_delta_T.data());
225 f0_den_global = View<double**,CLayout, HostType>(
"f0_den_global", n_nonadiabatic_species, grid_nnode);
226 f0_temp_global = View<double**,CLayout, HostType>(
"f0_temp_global", n_nonadiabatic_species, grid_nnode);
227 #ifndef NO_FORTRAN_MODULES
234 set_unmanaged_f0_species_view(f0_den_global, species.
nonadiabatic_idx, species.
f0.den_global_h);
235 set_unmanaged_f0_species_view(f0_temp_global, species.
nonadiabatic_idx, species.
f0.temp_global_h);
240 template<
typename T_in,
typename T_out>
242 auto view_in_subview =
my_subview(view_in, isp);
243 view_out = T_out(view_in_subview.data(), view_in_subview.layout());
251 #ifndef NO_FORTRAN_MODULES
253 int f0_inode2 = f0_inode1 + pol_decomp.
nnodes - 1;
258 int f0_species_cnt=0;
260 set_unmanaged_f0_species_view(f0_f0g.f, f0_species_cnt, species.
f0.f0g_h);
268 if(!particles_d_has_owner){
270 particles_d_owner = isp;
272 all_species[particles_d_owner].particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>(
"particles_d", 0);
273 all_species[particles_d_owner].owns_particles_d =
true;
274 particles_d_has_owner =
true;
277 if(particles_d_owner == isp)
return;
280 all_species[isp].particles_d = all_species[particles_d_owner].particles_d;
283 all_species[particles_d_owner].particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>();
284 all_species[particles_d_owner].owns_particles_d =
false;
287 particles_d_owner = isp;
288 all_species[particles_d_owner].owns_particles_d =
true;
293 if((!all_species[isp].is_adiabatic) && device_ptl_opt==UseDevicePtl){
294 if(species_share_particles_d_ownership){
295 transfer_particles_d_ownership(isp);
297 if(!all_species[isp].owns_particles_d){
298 all_species[isp].particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>(
"particles_d", 0);
299 all_species[isp].owns_particles_d =
true;
304 all_species[isp].resize_device_particles();
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_n_Ta
Equilibrium n_Ta at nodes.
Definition: plasma.hpp:38
void for_all_ions(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:139
bool owns_particles_d
Whether the species owns the device particle allocation right now.
Definition: species.hpp:100
View< double **, CLayout, HostType > f0_den_global
Equilibrium density at vertices.
Definition: plasma.hpp:76
Distribution< Device > f0
Species distribution in velocity space on local mesh nodes.
Definition: species.hpp:119
void manage_particle_ownership(int isp, DevicePtlOpt device_ptl_opt)
Definition: plasma.hpp:292
bool is_electron
Whether this species is the electrons.
Definition: species.hpp:78
void f0_set_ptrs(int nnode, double *f0_delta_n_cpp, double *f0_delta_u_cpp, double *f0_delta_T_cpp)
ParticleType
Definition: plasma.hpp:97
void for_one_species(int isp, F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:162
View< double **, CLayout, HostType > f0_temp_global
Equilibrium temperature at vertices.
Definition: plasma.hpp:77
Definition: velocity_grid.hpp:8
bool particles_d_has_owner
Whether a species owns the device particles allocation.
Definition: plasma.hpp:18
void deallocate_device_ptl()
Definition: plasma.hpp:186
Definition: plasma.hpp:94
Definition: NamelistReader.hpp:193
Definition: magnetic_field.hpp:12
DecomposedRecalculableF0Arrays decomposed_recalculable_f0_arrays
Contains f0 values that are poloidally decomposed but don't need to be transferred between ranks duri...
Definition: plasma.hpp:69
int idx
Index in all_species.
Definition: species.hpp:77
VGridDistribution< HostType > f0_f0g
Definition: plasma.hpp:28
void for_all_nonadiabatic_species(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:113
int nonadiabatic_idx
Index of species skipping adiabatic species (for compatibility with fortran arrays) ...
Definition: species.hpp:80
bool default_residence_option()
Definition: species.hpp:34
int n_ptl
Number of particles.
Definition: species.hpp:94
int node_offset
Offset of first mesh node belonging to this MPI rank.
Definition: domain_decomposition.hpp:41
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_delta_n
Flux-surface averaged change of density.
Definition: plasma.hpp:72
std::vector< Species< DeviceType > > all_species
Every particle species in the simulation.
Definition: plasma.hpp:23
void resize_f0_f0g(const DomainDecomposition< DeviceType > &pol_decomp, const VelocityGrid &vgrid)
Definition: plasma.hpp:248
int nnodes
Number of nodes belonging to this MPI rank.
Definition: domain_decomposition.hpp:42
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_flow
Equilibrium flow at nodes.
Definition: plasma.hpp:40
Definition: plasma.hpp:98
Cabana::AoSoA< ParticleDataTypes, Device, VEC_LEN > particles_d
Particles on device.
Definition: species.hpp:98
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_inv_grid_vol
Inverse grid volume at nodes.
Definition: plasma.hpp:35
void set_unmanaged_f0_species_view(const T_in &view_in, int isp, T_out &view_out)
Definition: plasma.hpp:241
int particles_d_owner
Which species, if any, owns the device particles allocation.
Definition: plasma.hpp:19
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_grid_vol_vonly
Grid volume (v only) at nodes.
Definition: plasma.hpp:37
void f0_init_global_arrays(double *f0_den_global, double *f0_temp_global)
int largest_n_ptl(bool check_backup)
Definition: plasma.hpp:167
DevicePtlOpt
Definition: plasma.hpp:92
Definition: plasma.hpp:33
int nspecies
Number of species including electrons.
Definition: plasma.hpp:79
void for_all_species(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:104
int n_nonadiabatic_species
Number of nonadiabatic species.
Definition: plasma.hpp:80
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_T_ev
Equilibrium temperature at nodes.
Definition: plasma.hpp:34
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_grid_vol
Grid volume at nodes.
Definition: plasma.hpp:36
void set_f0_f0g_ptr(int f0_inode1, int f0_inode2, double *f0_f0g_loc)
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_delta_u
Flux-surface averaged change of parallel flow.
Definition: plasma.hpp:73
Definition: plasma.hpp:93
DecomposedRecalculableF0Arrays()
Definition: plasma.hpp:42
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
Definition: magnetic_field.F90:1
int n_backup_particles
Definition: species.hpp:116
void for_electrons(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:128
double * data()
Definition: vgrid_distribution.hpp:71
Definition: plasma.hpp:14
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_den
Equilibrium density at nodes.
Definition: plasma.hpp:39
Definition: plasma.hpp:99
void for_all(ParticleType particle_type, F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:150
bool species_share_particles_d_ownership
Whether to use the device particles sharing scheme.
Definition: plasma.hpp:17
Plasma()
Definition: plasma.hpp:83
Definition: species.hpp:74
void transfer_particles_d_ownership(int isp)
Definition: plasma.hpp:267
Kokkos::View< double **, Kokkos::LayoutRight, HostType > f0_delta_T
Flux-surface averaged change of temperature.
Definition: plasma.hpp:74
void f0_init_decomposed_ptrs(double *f0_T_ev_cpp, double *f0_inv_grid_vol_cpp, double *f0_grid_vol_cpp, double *f0_grid_vol_vonly_cpp, double *f0_n_Ta_cpp, double *f0_den_cpp, double *f0_flow_cpp)
void init_global_f0_arrays(int grid_nnode)
Definition: plasma.hpp:208
DecomposedRecalculableF0Arrays(int nsp, const DomainDecomposition< DeviceType > &pol_decomp)
Definition: plasma.hpp:44