ASCOT5
Loading...
Searching...
No Matches
Functions
wall.c File Reference

Wall interface. More...

#include <stdio.h>
#include <math.h>
#include "ascot5.h"
#include "print.h"
#include "wall.h"
#include "wall/wall_2d.h"
#include "wall/wall_3d.h"

Go to the source code of this file.

Functions

int wall_init_offload (wall_offload_data *offload_data, real **offload_array, int **int_offload_array)
 Load wall data and prepare parameters.
 
void wall_free_offload (wall_offload_data *offload_data, real **offload_array, int **int_offload_array)
 Free offload array and reset parameters.
 
int wall_init (wall_data *w, wall_offload_data *offload_data, real *offload_array, int *int_offload_array)
 Initialize wall data struct on target.
 
int wall_hit_wall (real r1, real phi1, real z1, real r2, real phi2, real z2, wall_data *w, real *w_coll)
 Check if a given directed line segment intersects the wall.
 
int wall_get_n_elements (wall_data *w)
 Return the number of wall elements.
 

Detailed Description

Wall interface.

This is an interface through which wall data is initialized and accessed. Reading e.g. from disk is done elsewhere.

To add a new wall instance, make sure these functions are implemented and called from this interface, and that wall.h contains enum type for the new instance.

The interface checks which instance given data corresponds to from the "type"-field in wall_offload_data or wall_data that is given as an argument, and calls the relevant function for that instance.

Definition in file wall.c.

Function Documentation

◆ wall_init_offload()

int wall_init_offload ( wall_offload_data * offload_data,
real ** offload_array,
int ** int_offload_array )

Load wall data and prepare parameters.

This function fills the relevant wall offload struct with parameters and allocates and fills the offload array. Sets offload array length in the offload struct.

The offload data has to have a type when this function is called as it should be set when the offload data is constructed from inputs.

This function is host only.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array
int_offload_arraypointer to pointer to offload array storing integers
Returns
zero if initialization succeeded

Definition at line 42 of file wall.c.

◆ wall_free_offload()

void wall_free_offload ( wall_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.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array
int_offload_arraypointer to pointer to offload array storing integers

Definition at line 91 of file wall.c.

◆ wall_init()

int wall_init ( wall_data * w,
wall_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.

Parameters
wpointer to data struct on target
offload_datapointer to offload data struct
offload_arraypointer to offload array
int_offload_arraypointer to pointer to offload array storing integers
Returns
zero on success

Definition at line 119 of file wall.c.

◆ wall_hit_wall()

int wall_hit_wall ( real r1,
real phi1,
real z1,
real r2,
real phi2,
real z2,
wall_data * w,
real * w_coll )

Check if a given directed line segment intersects the wall.

This function is intended to be used to check whether a marker collides with the wall. If there is a collision, this function returns an identification number specific to that wall tile. If the marker hits multiple wall elements, only the first one is returned.

This is a SIMD function.

Parameters
r1start point R coordinate [m]
phi1start point phi coordinate [rad]
z1start point z coordinate [rad]
r2end point R coordinate [m]
phi2end point phi coordinate [rad]
z2end point z coordinate [rad]
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 163 of file wall.c.

◆ wall_get_n_elements()

int wall_get_n_elements ( wall_data * w)

Return the number of wall elements.

Parameters
wpointer to wall data struct on target
Returns
Number of wall elements or zero on failure.

Definition at line 187 of file wall.c.