| 
    ASCOT5
    
   | 
 
2D wall collision checks More...
#include <stdio.h>#include <stdlib.h>#include <math.h>#include "../ascot5.h"#include "../print.h"#include "wall_2d.h"Go to the source code of this file.
Functions | |
| int | wall_2d_init (wall_2d_data *data, int nelements, real *r, real *z, int *flag) | 
| Load 2D wall data and prepare parameters.   | |
| void | wall_2d_free (wall_2d_data *data) | 
| Free allocated resources.   | |
| void | wall_2d_offload (wall_2d_data *data) | 
| Offload data to the accelerator.   | |
| int | wall_2d_inside (real r, real z, wall_2d_data *w) | 
| Check if coordinates are within 2D polygon wall.   | |
| 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.   | |
| 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.   | |
2D wall collision checks
Definition in file wall_2d.c.
| int wall_2d_init | ( | wall_2d_data * | data, | 
| int | nelements, | ||
| real * | r, | ||
| real * | z, | ||
| int * | flag ) | 
| void wall_2d_free | ( | wall_2d_data * | data | ) | 
| void wall_2d_offload | ( | wall_2d_data * | data | ) | 
| int wall_2d_inside | ( | real | r, | 
| real | z, | ||
| wall_2d_data * | w ) | 
Check if coordinates are within 2D polygon wall.
This function checks if the given coordinates are within the walls defined by a 2D polygon using a modified axis crossing method [1]. Origin is moved to the coordinates and the number of wall segments crossing the positive r-axis are calculated. If this is odd, the point is inside the polygon.
[1] D.G. Alciatore, R. Miranda. A Winding Number and Point-in-Polygon Algorithm. Technical report, Colorado State University, 1995. https://www.engr.colostate.edu/~dga/documents/papers/point_in_polygon.pdf
| r | r coordinate [m] | 
| z | z coordinate [m] | 
| w | 2D wall data structure | 
| 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.
| r1 | start point R coordinate [m] | 
| phi1 | start point phi coordinate [rad] | 
| z1 | start point z coordinate [m] | 
| r2 | end point R coordinate [m] | 
| phi2 | end point phi coordinate [rad] | 
| z2 | end point z coordinate [m] | 
| w | pointer to data struct on target | 
| w_coll | pointer for storing the parameter in P = P1 + w_coll * (P2-P1), where P is the point where the collision occurred. | 
| 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.
If there are multiple intersections, the one that is closest to P1 is returned.
| r1 | R1 coordinate of the line segment [P1,P2] [m] | 
| z1 | z1 coordinate of the line segment [P1,P2] [m] | 
| r2 | R2 coordinate of the line segment [P1,P2] [m] | 
| z2 | z2 coordinate of the line segment [P1,P2] [m] | 
| w | pointer to the wall data | 
| w_coll | pointer for storing the parameter in P = P1 + w_coll * (P2-P1), where P is the point where the collision occurred. |