ASCOT5
|
Header file for wall_3d.c. More...
Go to the source code of this file.
Data Structures | |
struct | wall_3d_offload_data |
3D wall offload data More... | |
struct | wall_3d_data |
3D wall data parameters More... | |
Macros | |
#define | WALL_EPSILON 1e-9 |
Functions | |
int | wall_3d_init_offload (wall_3d_offload_data *offload_data, real **offload_array, int **int_offload_array) |
Initialize 3D wall data and check inputs. | |
void | wall_3d_free_offload (wall_3d_offload_data *offload_data, real **offload_array, int **int_offload_array) |
Free offload array and reset parameters. | |
void | wall_3d_init_octree (wall_3d_offload_data *w, real *offload_array, int **int_offload_array) |
Construct wall octree recursively. | |
void | wall_3d_init (wall_3d_data *w, wall_3d_offload_data *offload_data, real *offload_array, int *int_offload_array) |
Initialize wall data struct on target. | |
int | wall_3d_hit_wall (real r1, real phi1, real z1, real r2, real phi2, real z2, wall_3d_data *w, real *w_coll) |
Check if trajectory from (r1, phi1, z1) to (r2, phi2, z2) intersects the wall using the octree structure. | |
DECLARE_TARGET_END int | wall_3d_hit_wall_full (real r1, real phi1, real z1, real r2, real phi2, real z2, wall_3d_data *w, real *w_coll) |
Check if trajectory from (r1, phi1, z1) to (r2, phi2, z2) intersects the wall against all triangles. | |
DECLARE_TARGET_END GPU_DECLARE_TARGET_SIMD double | wall_3d_tri_collision (real q1[3], real q2[3], real t1[3], real t2[3], real t3[3]) |
Check if a line segment intersects a triangle. | |
DECLARE_TARGET_END DECLARE_TARGET void | wall_3d_init_tree (wall_3d_data *w, real *offload_array) |
Construct wall octree iteratively. | |
DECLARE_TARGET_END DECLARE_TARGET int | wall_3d_tri_in_cube (real t1[3], real t2[3], real t3[3], real bb1[3], real bb2[3]) |
Check if any part of a triangle is inside a box. | |
DECLARE_TARGET_END DECLARE_TARGET int | wall_3d_quad_collision (real q1[3], real q2[3], real t1[3], real t2[3], real t3[3], real t4[3]) |
Check if a line segment intersects a quad (assumed planar) | |
#define WALL_EPSILON 1e-9 |
int wall_3d_init_offload | ( | wall_3d_offload_data * | offload_data, |
real ** | offload_array, | ||
int ** | int_offload_array ) |
Initialize 3D wall data and check inputs.
Before calling this function, the offload struct is expected to hold triangle positions as
[x1_1, y1_1, z1_1, x2_1, y2_1, z2_1, x3_1, y3_1, z3_1,... ],
where first index is for the triangle vertex and second for the triangle itself.
This function fill rest of the offload struct and constructs the octree, while also printing some values as sanity check.
The default octree depth is defined by macro WALL_OCTREE_DEPTH in wall_3d.h.
offload_data | pointer to offload data struct |
offload_array | pointer to offload array |
int_offload_array | pointer to offload array containing integers |
void wall_3d_free_offload | ( | wall_3d_offload_data * | offload_data, |
real ** | offload_array, | ||
int ** | int_offload_array ) |
Free offload array and reset parameters.
This function deallocates the offload_array.
This function is host only.
offload_data | pointer to offload data struct |
offload_array | pointer to offload array |
int_offload_array | pointer to offload array containing integers |
void wall_3d_init_octree | ( | wall_3d_offload_data * | w, |
real * | offload_array, | ||
int ** | tree_array ) |
Construct wall octree recursively.
Constructs the octree array by iterating through all wall triangles and placing them into an octree structure
w | pointer to wall data |
offload_array | the offload array |
tree_array | pointer to array storing what octree cells contain which triangles |
void wall_3d_init | ( | wall_3d_data * | w, |
wall_3d_offload_data * | offload_data, | ||
real * | offload_array, | ||
int * | int_offload_array ) |
Initialize wall data struct on target.
This function copies the wall parameters from the offload struct to the struct on target and sets the wall data pointers to correct offsets in the offload array.
w | pointer to data struct on target |
offload_data | pointer to offload data struct |
offload_array | offload array |
int_offload_array | offload array containing integers |
int wall_3d_hit_wall | ( | real | r1, |
real | phi1, | ||
real | z1, | ||
real | r2, | ||
real | phi2, | ||
real | z2, | ||
wall_3d_data * | wdata, | ||
real * | w_coll ) |
Check if trajectory from (r1, phi1, z1) to (r2, phi2, z2) intersects the wall using the octree structure.
r1 | start point R coordinate [m] |
phi1 | start point phi coordinate [rad] |
z1 | start point z coordinate [rad] |
r2 | end point R coordinate [m] |
phi2 | end point phi coordinate [rad] |
z2 | end point z coordinate [rad] |
wdata | 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. |
DECLARE_TARGET_END int wall_3d_hit_wall_full | ( | real | r1, |
real | phi1, | ||
real | z1, | ||
real | r2, | ||
real | phi2, | ||
real | z2, | ||
wall_3d_data * | wdata, | ||
real * | w_coll ) |
Check if trajectory from (r1, phi1, z1) to (r2, phi2, z2) intersects the wall against all triangles.
r1 | start point R coordinate [m] |
phi1 | start point phi coordinate [rad] |
z1 | start point z coordinate [rad] |
r2 | end point R coordinate [m] |
phi2 | end point phi coordinate [rad] |
z2 | end point z coordinate [rad] |
wdata | 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. |
DECLARE_TARGET_END GPU_DECLARE_TARGET_SIMD double wall_3d_tri_collision | ( | real | q1[3], |
real | q2[3], | ||
real | t1[3], | ||
real | t2[3], | ||
real | t3[3] ) |
Check if a line segment intersects a triangle.
This routine implements the Möller-Trumbore algorithm.
q1 | line segment start point xyz coordinates [m] |
q2 | line segment end point xyz coordinates [m] |
t1 | xyz coordinates of first triangle vertex [m] |
t2 | xyz coordinates of second triangle vertex [m] |
t3 | xyz coordinates of third triangle vertex [m] |
DECLARE_TARGET_END DECLARE_TARGET void wall_3d_init_tree | ( | wall_3d_data * | w, |
real * | offload_array ) |
Construct wall octree iteratively.
Constructs the octree array by iterating through all wall triangles and octree grid to identify triangles belonging to each grid cell.
Slow, only for testing purposes.
w | pointer to wall data |
offload_array | offload array |
DECLARE_TARGET_END DECLARE_TARGET int wall_3d_tri_in_cube | ( | real | t1[3], |
real | t2[3], | ||
real | t3[3], | ||
real | bb1[3], | ||
real | bb2[3] ) |
Check if any part of a triangle is inside a box.
t1 | xyz coordinates of first triangle vertex [m] |
t2 | xyz coordinates of second triangle vertex [m] |
t3 | xyz coordinates of third triangle vertex [m] |
bb1 | bounding box minimum xyz coordinates [m] |
bb2 | bounding box maximum xyz coordinates [m] |
DECLARE_TARGET_END DECLARE_TARGET int wall_3d_quad_collision | ( | real | q1[3], |
real | q2[3], | ||
real | t1[3], | ||
real | t2[3], | ||
real | t3[3], | ||
real | t4[3] ) |
Check if a line segment intersects a quad (assumed planar)
q1 | line segment start point xyz coordinates [m] |
q2 | line segment end point xyz coordinates [m] |
t1 | xyz coordinates of first quad vertex [m] |
t2 | xyz coordinates of second quad vertex [m] |
t3 | xyz coordinates of third quad vertex [m] |
t4 | xyz coordinates of fourth quad vertex [m] |