ASCOT5
|
Header file for wall_2d.c. More...
Go to the source code of this file.
Data Structures | |
struct | wall_2d_offload_data |
2D wall offload data More... | |
struct | wall_2d_data |
2D wall data parameters More... | |
Functions | |
int | wall_2d_init_offload (wall_2d_offload_data *offload_data, real **offload_array) |
Load 2D wall data and prepare parameters. | |
void | wall_2d_free_offload (wall_2d_offload_data *offload_data, real **offload_array) |
Free offload array and reset parameters. | |
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. | |
DECLARE_TARGET_END 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. | |
int wall_2d_init_offload | ( | wall_2d_offload_data * | offload_data, |
real ** | offload_array ) |
Load 2D wall data and prepare parameters.
This function assumes offload data is already finished and the offload array is allocated and initialized with values
&(*offload_array)[0] = Wall polygon R coordinates &(*offload_array)[n] = Wall polygon z coordinates
Since this data requires no initialization, the only thing this function does is that it prints some values as sanity check.
offload_data | pointer to offload data struct |
offload_array | pointer to pointer to offload array |
void wall_2d_free_offload | ( | wall_2d_offload_data * | offload_data, |
real ** | offload_array ) |
void wall_2d_init | ( | wall_2d_data * | w, |
wall_2d_offload_data * | offload_data, | ||
real * | offload_array ) |
Initialize 2D wall data struct on target.
Copies the 2D wall parameters from the offload struct to the struct on on target and sets the wall data pointer inside to the offload array.
w | pointer to data struct on target |
offload_data | pointer to offload data struct |
offload_array | the offload array |
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 |
DECLARE_TARGET_END 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. |