7 extern "C" void f0_init_decomposed_ptrs(
double* f0_T_ev_cpp,
double* f0_fg_T_ev_cpp,
double* f0_inv_grid_vol_cpp,
double* f0_grid_vol_cpp,
8 double* f0_grid_vol_vonly_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);
52 View<double**,CLayout, HostType>
f0_den;
59 :
f0_T_ev(
"f0_T_ev", nsp, pol_decomp.nnodes),
60 f0_fg_T_ev(
"f0_fg_T_ev", nsp, pol_decomp.nnodes),
65 f0_den(
"f0_den", nsp, pol_decomp.nnodes),
66 f0_flow(
"f0_flow", nsp, pol_decomp.nnodes)
68 #ifndef NO_FORTRAN_MODULES
106 sp_names{
"e",
"i",
"i2",
"i3",
"i4",
"i5",
"i6"}
135 printf(
"ISP ERROR in for_all_nonadiabatic_sepcies: isp=%d",isp);
196 max_n_ptl = std::max(max_n_ptl,species.
n_ptl);
208 species.
particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>();
212 particles_d_has_owner =
false;
229 f0_delta_n = View<double**,CLayout, HostType>(
"f0_delta_n", nspecies, grid.
nnode);
230 f0_delta_u = View<double**,CLayout, HostType>(
"f0_delta_u", nspecies, grid.
nnode);
231 f0_delta_T = View<double**,CLayout, HostType>(
"f0_delta_T", nspecies, grid.
nnode);
234 set_unmanaged_f0_species_view(f0_delta_n, species.
idx, species.
f0.delta_n_h);
235 set_unmanaged_f0_species_view(f0_delta_u, species.
idx, species.
f0.delta_u_h);
236 set_unmanaged_f0_species_view(f0_delta_T, species.
idx, species.
f0.delta_T_h);
238 #ifndef NO_FORTRAN_MODULES
240 f0_set_ptrs(grid.
nnode, f0_delta_n.data(), f0_delta_u.data(), f0_delta_T.data());
244 f0_den_global = View<double**,CLayout, HostType>(
"f0_den_global", nspecies, grid.
nnode);
245 f0_temp_global = View<double**,CLayout, HostType>(
"f0_temp_global", nspecies, grid.
nnode);
246 #ifndef NO_FORTRAN_MODULES
253 set_unmanaged_f0_species_view(f0_den_global, species.
idx, species.
f0.den_global_h);
254 set_unmanaged_f0_species_view(f0_temp_global, species.
idx, species.
f0.temp_global_h);
261 template<
typename T_in,
typename T_out>
263 auto view_in_subview =
my_subview(view_in, isp);
264 view_out = T_out(view_in_subview.data(), view_in_subview.layout());
272 #ifndef NO_FORTRAN_MODULES
274 int f0_inode2 = f0_inode1 + pol_decomp.
nnodes - 1;
279 int f0_species_cnt=0;
281 set_unmanaged_f0_species_view(f0_f0g.f, f0_species_cnt, species.
f0.f0g_h);
289 if(!particles_d_has_owner){
291 particles_d_owner = isp;
293 all_species[particles_d_owner].particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>(
"particles_d", 0);
294 all_species[particles_d_owner].owns_particles_d =
true;
295 particles_d_has_owner =
true;
298 if(particles_d_owner == isp)
return;
301 all_species[isp].particles_d = all_species[particles_d_owner].particles_d;
304 all_species[particles_d_owner].particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>();
305 all_species[particles_d_owner].owns_particles_d =
false;
308 particles_d_owner = isp;
309 all_species[particles_d_owner].owns_particles_d =
true;
314 if((!all_species[isp].is_adiabatic) && device_ptl_opt==UseDevicePtl){
315 if(species_share_particles_d_ownership){
316 transfer_particles_d_ownership(isp);
318 if(!all_species[isp].owns_particles_d){
319 all_species[isp].particles_d = Cabana::AoSoA<ParticleDataTypes,DeviceType,VEC_LEN>(
"particles_d", 0);
320 all_species[isp].owns_particles_d =
true;
325 all_species[isp].resize_device_particles();
335 double main_ion_mass = all_species[
MAIN_ION].mass;
337 double characteristic_velocity = sqrt(2*main_ion_characteristic_energy/main_ion_mass);
338 return axis_length / characteristic_velocity;
void calculate_global_f0_arrays(const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field)
Definition: species.cpp:493
void for_all_ions(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:158
bool owns_particles_d
Whether the species owns the device particle allocation right now.
Definition: species.hpp:110
double * data() const
Definition: vgrid_distribution.hpp:73
void init_global_f0_arrays(const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field)
Definition: plasma.hpp:227
View< double **, CLayout, HostType > f0_den_global
Equilibrium density at vertices.
Definition: plasma.hpp:91
Distribution< Device > f0
Species distribution in velocity space on local mesh nodes.
Definition: species.hpp:129
void manage_particle_ownership(int isp, DevicePtlOpt device_ptl_opt)
Definition: plasma.hpp:313
bool is_electron
Whether this species is the electrons.
Definition: species.hpp:79
void f0_set_ptrs(int nnode, double *f0_delta_n_cpp, double *f0_delta_u_cpp, double *f0_delta_T_cpp)
static constexpr bool reduced_deltaf
Equivalent to the preprocessor flag for now.
Definition: plasma.hpp:25
ParticleType
Definition: plasma.hpp:116
void for_one_species(int isp, F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:181
View< double **, CLayout, HostType > f0_temp_global
Equilibrium temperature at vertices.
Definition: plasma.hpp:92
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:205
Definition: plasma.hpp:113
View< double **, CLayout, HostType > f0_fg_vth_inv
thermal velocity from f_grid norm. temp. at nodes (to avoid sqrt ops)
Definition: plasma.hpp:48
Definition: NamelistReader.hpp:193
View< double **, CLayout, HostType > f0_fg_T_ev
f_Grid normalization temperature at nodes
Definition: plasma.hpp:47
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:84
int idx
Index in all_species.
Definition: species.hpp:78
VGridDistribution< HostType > f0_f0g
Definition: plasma.hpp:38
bool f0_grid
Definition: plasma.hpp:31
View< double **, CLayout, HostType > f0_flow
Equilibrium flow at nodes.
Definition: plasma.hpp:53
void for_all_nonadiabatic_species(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:132
View< double **, CLayout, HostType > f0_grid_vol_vonly
Grid volume (v only) at nodes.
Definition: plasma.hpp:51
Equilibrium equil
The object containing information about the magnetic equilibrium.
Definition: magnetic_field.hpp:32
View< double **, CLayout, HostType > f0_den
Equilibrium density at nodes.
Definition: plasma.hpp:52
bool default_residence_option()
Definition: species.hpp:35
int n_ptl
Number of particles.
Definition: species.hpp:104
int node_offset
Offset of first mesh node belonging to this MPI rank.
Definition: domain_decomposition.hpp:55
std::vector< Species< DeviceType > > all_species
Every particle species in the simulation.
Definition: plasma.hpp:33
void resize_f0_f0g(const DomainDecomposition< DeviceType > &pol_decomp, const VelocityGrid &vgrid)
Definition: plasma.hpp:269
int nnodes
Number of nodes belonging to this MPI rank.
Definition: domain_decomposition.hpp:56
Definition: plasma.hpp:117
Cabana::AoSoA< ParticleDataTypes, Device, VEC_LEN > particles_d
Particles on device.
Definition: species.hpp:108
View< double **, CLayout, HostType > f0_T_ev
Equilibrium temperature at nodes.
Definition: plasma.hpp:46
void set_unmanaged_f0_species_view(const T_in &view_in, int isp, T_out &view_out)
Definition: plasma.hpp:262
int particles_d_owner
Which species, if any, owns the device particles allocation.
Definition: plasma.hpp:19
void f0_init_decomposed_ptrs(double *f0_T_ev_cpp, double *f0_fg_T_ev_cpp, double *f0_inv_grid_vol_cpp, double *f0_grid_vol_cpp, double *f0_grid_vol_vonly_cpp, double *f0_den_cpp, double *f0_flow_cpp)
double axis_r
r coordinate of axis
Definition: equil.hpp:89
double get_main_ion_toroidal_transit_time(const MagneticField< DeviceType > &magnetic_field) const
Definition: plasma.hpp:334
void f0_init_global_arrays(double *f0_den_global, double *f0_temp_global)
int largest_n_ptl(bool check_backup)
Definition: plasma.hpp:186
DevicePtlOpt
Definition: plasma.hpp:111
View< double **, CLayout, HostType > f0_delta_T
Flux-surface averaged change of temperature.
Definition: plasma.hpp:89
Definition: plasma.hpp:45
int nspecies
Number of species including electrons.
Definition: plasma.hpp:94
void for_all_species(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:123
int n_nonadiabatic_species
Number of nonadiabatic species.
Definition: plasma.hpp:95
View< double **, CLayout, HostType > f0_inv_grid_vol
Inverse grid volume at nodes.
Definition: plasma.hpp:49
void set_f0_f0g_ptr(int f0_inode1, int f0_inode2, double *f0_f0g_loc)
Definition: xgc_io.hpp:24
Definition: plasma.hpp:112
DecomposedRecalculableF0Arrays()
Definition: plasma.hpp:56
Definition: globals.hpp:85
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:126
void for_electrons(F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:147
View< double **, CLayout, HostType > f0_delta_n
Flux-surface averaged change of density.
Definition: plasma.hpp:87
Definition: plasma.hpp:14
Definition: plasma.hpp:118
void for_all(ParticleType particle_type, F func, DevicePtlOpt device_ptl_opt=UseDevicePtl)
Definition: plasma.hpp:169
bool species_share_particles_d_ownership
Whether to use the device particles sharing scheme.
Definition: plasma.hpp:17
View< double *, CLayout, HostType > f0_node_cost
Definition: plasma.hpp:39
Plasma()
Definition: plasma.hpp:100
Definition: species.hpp:75
void transfer_particles_d_ownership(int isp)
Definition: plasma.hpp:288
View< double **, CLayout, HostType > f0_grid_vol
Grid volume at nodes.
Definition: plasma.hpp:50
View< double **, CLayout, HostType > f0_delta_u
Flux-surface averaged change of parallel flow.
Definition: plasma.hpp:88
std::vector< std::string > sp_names
Definition: plasma.hpp:97
double main_ion_characteristic_energy
Definition: plasma.hpp:27
int nnode
Number of grid nodes.
Definition: grid.hpp:202
DecomposedRecalculableF0Arrays(int nsp, const DomainDecomposition< DeviceType > &pol_decomp)
Definition: plasma.hpp:58
constexpr double TWOPI
Definition: constants.hpp:9