Header file for wall_2d.c.
More...
#include "../ascot5.h"
#include "../offload.h"
Go to the source code of this file.
|
| 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.
|
| |
| 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.
|
| |
Header file for wall_2d.c.
Definition in file wall_2d.h.
◆ wall_2d_init()
Load 2D wall data and prepare parameters.
- Parameters
-
| data | pointer to the data struct |
| nelements | number of elements in the wall polygon |
| r | R coordinates for the wall polygon points |
| z | z coordinates for the wall polygon points |
- Returns
- zero to indicate success
Definition at line 22 of file wall_2d.c.
◆ wall_2d_free()
Free allocated resources.
- Parameters
-
| data | pointer to the data struct |
Definition at line 53 of file wall_2d.c.
◆ wall_2d_offload()
Offload data to the accelerator.
- Parameters
-
| data | pointer to the data struct |
Definition at line 63 of file wall_2d.c.
◆ wall_2d_inside()
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
- Parameters
-
| r | r coordinate [m] |
| z | z coordinate [m] |
| w | 2D wall data structure |
Definition at line 87 of file wall_2d.c.
◆ wall_2d_hit_wall()
Check if trajectory from (r1, phi1, z1) to (r2, phi2, z2) intersects the wall.
- Parameters
-
| 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. |
- Returns
- wall element ID if hit, zero otherwise
Definition at line 128 of file wall_2d.c.
◆ wall_2d_find_intersection()
Find intersection between the wall element and line segment.
If there are multiple intersections, the one that is closest to P1 is returned.
- Parameters
-
| 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. |
- Returns
- int wall element id if hit, zero otherwise
Definition at line 149 of file wall_2d.c.