19 return (
size_t)(i_mu) * step_2
20 + (
size_t)(i_Ekin) * step_1
30 offload_data->
n_mu = 0;
50 dist_data->
n_mu = offload_data->
n_mu;
62 size_t n_Ptor = (size_t)(dist_data->
n_Ptor);
63 size_t n_Ekin = (size_t)(dist_data->
n_Ekin);
64 dist_data->
step_2 = n_Ptor * n_Ekin;
65 dist_data->
step_1 = n_Ptor;
81 GPU_PARALLEL_LOOP_ALL_LEVELS
82 for(
int i = 0; i < p_f->
n_mrk; i++) {
84 real Ekin, Ptor, Bnorm, psi, mu, xi, pnorm, ppar;
98 int i_mu = floor((mu - dist->
min_mu)
102 int i_Ekin = floor((Ekin - dist->
min_Ekin)
107 int i_Ptor = floor((Ptor - dist->
min_Ptor)
110 if(i_mu >= 0 && i_mu <= dist->n_mu - 1 &&
111 i_Ekin >= 0 && i_Ekin <= dist->n_Ekin - 1 &&
112 i_Ptor >= 0 && i_Ptor <= dist->n_Ptor - 1 ) {
145 for(
int i = 0; i <
NSIMD; i++) {
146 if(p_f->running[i]) {
147 real Ekin, Ptor, B, psi;
150 p_f->time[i], Bdata);
152 B =
math_normc(p_f->B_r[i], p_f->B_phi[i], p_f->B_z[i]);
153 i_mu[i] = floor((p_f->mu[i] - dist->
min_mu)
158 i_Ekin[i] = floor((Ekin - dist->
min_Ekin)
163 i_Ptor[i] = floor((Ptor - dist->
min_Ptor)
166 if(i_mu[i] >= 0 && i_mu[i] <= dist->
n_mu - 1 &&
167 i_Ekin[i] >= 0 && i_Ekin[i] <= dist->
n_Ekin - 1 &&
168 i_Ptor[i] >= 0 && i_Ptor[i] <= dist->
n_Ptor - 1 ) {
170 weight[i] = p_f->weight[i] * (p_f->time[i] - p_i->time[i]);
178 for(
int i = 0; i <
NSIMD; i++) {
179 if(p_f->running[i] && ok[i]) {
a5err B_field_eval_psi(real *psi, real r, real phi, real z, real t, B_field_data *Bdata)
Evaluate poloidal flux psi.
Main header file for ASCOT5.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
Header file containing physical and mathematical constants.
void dist_COM_update_fo(dist_COM_data *dist, B_field_data *Bdata, particle_simd_fo *p_f, particle_simd_fo *p_i)
Update the histogram from full-orbit markers.
void dist_COM_free_offload(dist_COM_offload_data *offload_data)
Frees the offload data.
size_t dist_COM_index(int i_mu, int i_Ekin, int i_Ptor, size_t step_2, size_t step_1)
Internal function calculating the index in the histogram array.
void dist_COM_init(dist_COM_data *dist_data, dist_COM_offload_data *offload_data, real *offload_array)
Initializes distribution from offload data.
void dist_COM_update_gc(dist_COM_data *dist, B_field_data *Bdata, particle_simd_gc *p_f, particle_simd_gc *p_i)
Update the histogram from guiding center markers.
Header file for dist_com.c.
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
#define math_normc(a1, a2, a3)
Calculate norm of 3D vector from its components a1, a2, a3.
Header file for particle.c.
Methods to evaluate elementary physical quantities.
#define phys_ptoroid_fo(q, R, pphi, psi)
Evaluate toroidal canonical momentum for particle.
#define physlib_Ekin_ppar(m, mu, ppar, B)
Evaluate kinetic energy [J] from parallel momentum.
#define physlib_Ekin_pnorm(m, p)
Evaluate kinetic energy [J] from momentum norm.
#define phys_ptoroid_gc(q, R, ppar, psi, B, Bphi)
Evaluate toroidal canonical momentum for guiding center.
#define physlib_gc_mu(m, p, xi, B)
Evaluate guiding center magnetic moment [J/T] from momentum norm and pitch.
Magnetic field simulation data.
Histogram parameters on target.
Histogram parameters that will be offloaded to target.
Struct representing NSIMD particle markers.
Struct representing NSIMD guiding center markers.