ASCOT5
Loading...
Searching...
No Matches
Data Structures | Functions
wall_2d.h File Reference

Header file for wall_2d.c. More...

#include "../ascot5.h"
#include "../offload_acc_omp.h"

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.
 

Detailed Description

Header file for wall_2d.c.

Definition in file wall_2d.h.

Function Documentation

◆ wall_2d_init_offload()

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.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array
Returns
zero to indicate success

Definition at line 29 of file wall_2d.c.

◆ wall_2d_free_offload()

void wall_2d_free_offload ( wall_2d_offload_data * offload_data,
real ** offload_array )

Free offload array and reset parameters.

This function deallocates the offload_array.

This function is host only.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array

Definition at line 62 of file wall_2d.c.

◆ wall_2d_init()

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.

Parameters
wpointer to data struct on target
offload_datapointer to offload data struct
offload_arraythe offload array

Definition at line 78 of file wall_2d.c.

◆ wall_2d_inside()

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

Parameters
rr coordinate [m]
zz coordinate [m]
w2D wall data structure

Definition at line 101 of file wall_2d.c.

◆ wall_2d_hit_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.

Parameters
r1start point R coordinate [m]
phi1start point phi coordinate [rad]
z1start point z coordinate [m]
r2end point R coordinate [m]
phi2end point phi coordinate [rad]
z2end point z coordinate [m]
wpointer to data struct on target
w_collpointer 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 142 of file wall_2d.c.

◆ wall_2d_find_intersection()

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.

Parameters
r1R1 coordinate of the line segment [P1,P2] [m]
z1z1 coordinate of the line segment [P1,P2] [m]
r2R2 coordinate of the line segment [P1,P2] [m]
z2z2 coordinate of the line segment [P1,P2] [m]
wpointer to the wall data
w_collpointer 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 167 of file wall_2d.c.