37void sim_monitor(
char* filename,
volatile int* n,
volatile int* finished);
89 n_queue_size = n_particles;
103 print_err(
"Only GO and GC mode ported to GPU. Please set SIM_MODE=1 or 2.");
107 print_err(
"ENABLE_ICRH=1 not ported to GPU. Please disable it.");
111 print_err(
"RECORD_MODE=1 not ported to GPU. Please disable it.");
115 print_err(
"Atomic not yet ported to GPU. Please set ENABLE_ATOMIC=0.");
119 print_err(
"MHD not yet ported to GPU. Please set ENABLE_MHD=0.");
124 "ENABLE_ORBITWRITE=1 not ported to GPU. Please disable it.");
129 "ENABLE_TRANSCOEF=1 not ported to GPU. Please disable it.");
136 GPU_MAP_TO_DEVICE(sim[0:1])
162 for(
int i = 0; i < data_size * n_queue_size; ++i) {
166 GPU_MAP_TO_DEVICE(sim->
random_data[0:data_size * n_queue_size])
178 for(
int i = 0; i < n_particles; i++) {
186 for(
int i = 0; i < n_particles; i++) {
187 pq.
p[pq.
next++] = &p[i];
193 omp_get_max_threads());
202 omp_set_max_active_levels(2);
204#if !defined(GPU) && VERBOSE > 1
205 #pragma omp parallel sections num_threads(2)
218 OMP_PARALLEL_CPU_ONLY
222 OMP_PARALLEL_CPU_ONLY
227 OMP_PARALLEL_CPU_ONLY
231 OMP_PARALLEL_CPU_ONLY
235#if !defined(GPU) && VERBOSE > 1
241 char filename[519], outfn[256];
243 outfn[strlen(outfn)-3] =
'\0';
244 sprintf(filename,
"%s_%s.stdout", outfn, sim->
qid);
264 for(
int i = 0; i < pq.
n; i++) {
285 for(
int i = 0; i < pq.
n; i++) {
293#if !defined(GPU) && VERBOSE > 1
294 #pragma omp parallel sections num_threads(2)
299 OMP_PARALLEL_CPU_ONLY
302#if !defined(GPU) && VERBOSE > 1
307 char filename[519], outfn[256];
309 outfn[strlen(outfn)-3] =
'\0';
310 sprintf(filename,
"%s_%s.stdout", outfn, sim->
qid);
365void sim_monitor(
char* filename,
volatile int* n,
volatile int* finished) {
367 FILE *f = fopen(filename,
"w");
370 "Warning. %s could not be opened for progress updates.\n",
377 int n_temp, finished_temp;
381 finished_temp = *finished;
382 real fracprog = ((
real) finished_temp)/n_temp;
385 if(n_temp == finished_temp) {
390 fprintf(f,
"No marker has finished simulation yet. "
391 "Time spent: %.2f h\n", timespent/3600);
394 fprintf(f,
"Progress: %d/%d, %.2f %%. Time spent: %.2f h, "
395 "estimated time to finish: %.2f h\n", finished_temp, n_temp,
396 100*fracprog, timespent/3600,
397 (1/fracprog-1)*timespent/3600);
403 fprintf(f,
"Simulation finished.\n");
void B_field_offload(B_field_data *data)
Offload data to the accelerator.
Header file for B_field.c.
void E_field_offload(E_field_data *data)
Offload data to the accelerator.
Header file for E_field.c.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
#define A5_PRINTPROGRESSINTERVAL
How often progress is being written (s) in the stdout file.
#define A5_WTIME
Wall time.
void asigma_extrapolate(int extrapolate)
Toggle extrapolation when evaluating cross sections.
void asigma_offload(asigma_data *data)
Offload data to the accelerator.
Header file for asigma.c.
void boozer_offload(boozer_data *data)
Offload data to the accelerator.
Header file for boozer.c.
void diag_offload(diag_data *data)
Offload data to the accelerator.
void diag_onload(diag_data *data)
Onload data back to the host.
int diag_init(diag_data *data, int Nmrk)
Initializes diagnostics data.
Header file for endcond.c.
void mccc_init(mccc_data *mdata, int include_energy, int include_pitch, int include_gcdiff)
Set collision operator data.
Header file for mccc package.
void mhd_offload(mhd_data *data)
Offload data to the accelerator.
void neutral_offload(neutral_data *data)
Offload data to the accelerator.
Header file for neutral.c.
Header file for particle.c.
void plasma_offload(plasma_data *data)
Offload data to the accelerator.
Header file for plasma.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
#define print_err(...)
Print to standard error.
Header file for random.c.
#define random_init(data, seed)
Contains the functions to be called from the simulation loop when using ICRH.
void simulate(int n_particles, particle_state *p, sim_data *sim)
Execute marker simulation.
void simulate_init(sim_data *sim)
Initialize simulation data struct.
void sim_monitor(char *filename, volatile int *n, volatile int *finished)
Monitor simulation progress.
Header file for simulate.c.
void simulate_fo_fixed(particle_queue *pq, sim_data *sim, int mrk_array_size)
Simulates particles using fixed time-step.
Header file for simulate_fo_fixed.c.
void simulate_gc_adaptive(particle_queue *pq, sim_data *sim, int mrk_array_size)
Simulates guiding centers using adaptive time-step.
Header file for simulate_gc_adaptive.c.
void simulate_gc_fixed(particle_queue *pq, sim_data *sim, int mrk_array_size)
Simulates guiding centers using fixed time-step.
Header file for simulate_gc_fixed.c.
void simulate_ml_adaptive(particle_queue *pq, sim_data *sim)
Simulates magnetic field-lines using adaptive time-step.
Header file for simulate_ml_adaptive.c.
General representation of a marker.
random_data * random_data
neutral_data neutral_data
void wall_offload(wall_data *data)
Offload data to the accelerator.
int wall_hit_wall(real r1, real phi1, real z1, real r2, real phi2, real z2, wall_data *w, real *w_coll)
Check if a given directed line segment intersects the wall.