30 real** offload_array) {
33 int n = offload_data->
n;
34 real rmin = (*offload_array)[0], rmax = (*offload_array)[0];
35 real zmin = (*offload_array)[n], zmax = (*offload_array)[n];
36 for(
int i=0; i<n; i++) {
37 rmin = fmin(rmin, (*offload_array)[i]);
38 rmax = fmax(rmax, (*offload_array)[i]);
39 zmin = fmin(zmin, (*offload_array)[n+i]);
40 zmax = fmax(zmax, (*offload_array)[n+i]);
45 " R extend = [%2.2f, %2.2f], z extend = [%2.2f, %2.2f]\n",
46 n, rmin, rmax, zmin, zmax);
63 real** offload_array) {
65 *offload_array = NULL;
79 real* offload_array) {
80 w->
n = offload_data->
n;
81 w->
wall_r = &offload_array[0];
82 w->
wall_z = &offload_array[offload_data->
n];
103 for(
int i = 0; i < w->
n; i++) {
104 real wr1, wr2, wz1, wz2;
117 real ri = wr1 + (wz1*(wr2-wr1)) / (wz1-wz2);
171 for(
int i=0; i<w->
n; i++) {
185 real div = (r1 - r2) * (z3 - z4) - (z1 - z2) * (r3 - r4);
186 real t = ( (r1 - r3) * (z3 - z4) - (z1 - z3) * (r3 - r4) ) / div;
187 real u = ( (r1 - r3) * (z1 - z2) - (z1 - z3) * (r1 - r2) ) / div;
188 if(0 <= t && t <= 1.0 && 0 <= u && u <= 1.0 && t < t0) {
Main header file for ASCOT5.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
void wall_2d_free_offload(wall_2d_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
int wall_2d_find_intersection(real r1, real z1, real r2, real z2, wall_2d_data *w, real *w_coll)
Find intersection between the wall element and line segment.
void wall_2d_init(wall_2d_data *w, wall_2d_offload_data *offload_data, real *offload_array)
Initialize 2D wall data struct on target.
int wall_2d_inside(real r, real z, wall_2d_data *w)
Check if coordinates are within 2D polygon wall.
int wall_2d_init_offload(wall_2d_offload_data *offload_data, real **offload_array)
Load 2D wall data and prepare parameters.
int wall_2d_hit_wall(real r1, real phi1, real z1, real r2, real phi2, real z2, wall_2d_data *w, real *w_coll)
Check if trajectory from (r1, phi1, z1) to (r2, phi2, z2) intersects the wall.
Header file for wall_2d.c.