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

Header file for B_3DS.c. More...

#include "../offload_acc_omp.h"
#include "../ascot5.h"
#include "../error.h"
#include "../spline/interp.h"

Go to the source code of this file.

Data Structures

struct  B_3DS_offload_data
 3D magnetic field parameters on the host More...
 
struct  B_3DS_data
 3D magnetic field parameters on the target More...
 

Functions

int B_3DS_init_offload (B_3DS_offload_data *offload_data, real **offload_array)
 Initialize magnetic field offload data.
 
void B_3DS_free_offload (B_3DS_offload_data *offload_data, real **offload_array)
 Free offload array.
 
void B_3DS_init (B_3DS_data *Bdata, B_3DS_offload_data *offload_data, real *offload_array)
 Initialize magnetic field data struct on target.
 
a5err B_3DS_eval_psi (real *psi, real r, real phi, real z, B_3DS_data *Bdata)
 Evaluate poloidal flux psi.
 
DECLARE_TARGET_END a5err B_3DS_eval_psi_dpsi (real psi_dpsi[4], real r, real phi, real z, B_3DS_data *Bdata)
 Evaluate poloidal flux psi and its derivatives.
 
DECLARE_TARGET_END a5err B_3DS_eval_rho_drho (real rho_drho[4], real r, real phi, real z, B_3DS_data *Bdata)
 Evaluate normalized poloidal flux rho and its derivatives.
 
DECLARE_TARGET_END a5err B_3DS_eval_B (real B[3], real r, real phi, real z, B_3DS_data *Bdata)
 Evaluate magnetic field.
 
DECLARE_TARGET_END a5err B_3DS_eval_B_dB (real B_dB[12], real r, real phi, real z, B_3DS_data *Bdata)
 Evaluate magnetic field and its derivatives.
 
DECLARE_TARGET_END a5err B_3DS_get_axis_rz (real rz[2], B_3DS_data *Bdata)
 Return magnetic axis R-coordinate.
 

Detailed Description

Header file for B_3DS.c.

Definition in file B_3DS.h.

Function Documentation

◆ B_3DS_init_offload()

int B_3DS_init_offload ( B_3DS_offload_data * offload_data,
real ** offload_array )

Initialize magnetic field offload data.

This function takes pre-initialized offload data struct and offload array as inputs. The data is used to fill rest of the offload struct and to construct bicubic splines whose coefficients are stored in re-allocated offload array.

The offload data struct must have the following fields initialized:

B_3DS_offload_data.offload_array_length is set here.

The offload array must contain the following data:

  • offload_array[ j*Bn_r*Bn_phi + z*Bn_r + i] = B_R(R_i, phi_z, z_j) [T]
  • offload_array[ Bn_r*Bn_z*Bn_phi + j*Bn_r*Bn_phi + z*Bn_r + i] = B_phi(R_i, phi_z, z_j) [T]
  • offload_array[2*Bn_r*Bn_z*Bn_phi + j*Bn_r*Bn_phi + z*Bn_r + i] = B_z(R_i, phi_z, z_j) [T]
  • offload_array[3*Bn_r*Bn_z*Bn_phi + j*n_r + i] = psi(R_i, z_j) [V*s*m^-1]

Sanity checks are printed if data was initialized succesfully.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to offload array which is reallocated here
Returns
zero if initialization succeeded

Definition at line 93 of file B_3DS.c.

◆ B_3DS_free_offload()

void B_3DS_free_offload ( B_3DS_offload_data * offload_data,
real ** offload_array )

Free offload array.

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

Definition at line 202 of file B_3DS.c.

◆ B_3DS_init()

void B_3DS_init ( B_3DS_data * Bdata,
B_3DS_offload_data * offload_data,
real * offload_array )

Initialize magnetic field data struct on target.

Parameters
Bdatapointer to data struct on target
offload_datapointer to offload data struct
offload_arrayoffload array

Definition at line 215 of file B_3DS.c.

◆ B_3DS_eval_psi()

a5err B_3DS_eval_psi ( real * psi,
real r,
real phi,
real z,
B_3DS_data * Bdata )

Evaluate poloidal flux psi.

Parameters
psipointer where psi [V*s*m^-1] value will be stored
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 285 of file B_3DS.c.

◆ B_3DS_eval_psi_dpsi()

DECLARE_TARGET_END a5err B_3DS_eval_psi_dpsi ( real psi_dpsi[4],
real r,
real phi,
real z,
B_3DS_data * Bdata )

Evaluate poloidal flux psi and its derivatives.

Parameters
psi_dpsipointer for storing psi [V*s*m^-1] and its derivatives
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 309 of file B_3DS.c.

◆ B_3DS_eval_rho_drho()

DECLARE_TARGET_END a5err B_3DS_eval_rho_drho ( real rho_drho[4],
real r,
real phi,
real z,
B_3DS_data * Bdata )

Evaluate normalized poloidal flux rho and its derivatives.

Parameters
rho_drhopointer where rho and its derivatives will be stored
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 340 of file B_3DS.c.

◆ B_3DS_eval_B()

DECLARE_TARGET_END a5err B_3DS_eval_B ( real B[3],
real r,
real phi,
real z,
B_3DS_data * Bdata )

Evaluate magnetic field.

Parameters
Bpointer to array where magnetic field values are stored
rR coordinate [m]
phiphi coordinate [deg]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 378 of file B_3DS.c.

◆ B_3DS_eval_B_dB()

DECLARE_TARGET_END a5err B_3DS_eval_B_dB ( real B_dB[12],
real r,
real phi,
real z,
B_3DS_data * Bdata )

Evaluate magnetic field and its derivatives.

Parameters
B_dBpointer to array where the field and its derivatives are stored
rR coordinate [m]
phiphi coordinate [deg]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 425 of file B_3DS.c.

◆ B_3DS_get_axis_rz()

DECLARE_TARGET_END a5err B_3DS_get_axis_rz ( real rz[2],
B_3DS_data * Bdata )

Return magnetic axis R-coordinate.

Parameters
rzpointer where axis R and z [m] values will be stored
Bdatapointer to magnetic field data struct
Returns
Zero a5err value as this function can't fail.

Definition at line 489 of file B_3DS.c.