ASCOT5
|
Electric field interface. More...
#include <stdio.h>
#include "ascot5.h"
#include "error.h"
#include "print.h"
#include "E_field.h"
#include "B_field.h"
#include "Efield/E_TC.h"
#include "Efield/E_1DS.h"
Go to the source code of this file.
Functions | |
int | E_field_init_offload (E_field_offload_data *offload_data, real **offload_array) |
Load electric field data and prepare parameters. | |
void | E_field_free_offload (E_field_offload_data *offload_data, real **offload_array) |
Free offload array and reset parameters. | |
int | E_field_init (E_field_data *Edata, E_field_offload_data *offload_data, real *offload_array) |
Initialize electric field data struct on target. | |
a5err | E_field_eval_E (real E[3], real r, real phi, real z, real t, E_field_data *Edata, B_field_data *Bdata) |
Evaluate electric field. | |
Electric field interface.
This is an interface through which electric field data is initialized and accessed. Reading e.g. from disk is done elsewhere.
To add a new electric field instance, make sure these functions are implemented and called from this interface, and that E_field.h contains enum type for the new instance.
The interface checks which instance given data corresponds to from E_field_offload_data.type and E_field_data.type from the struct that is given as an argument, and calls the relevant function for that instance.
Definition in file E_field.c.
int E_field_init_offload | ( | E_field_offload_data * | offload_data, |
real ** | offload_array ) |
Load electric field data and prepare parameters.
This function fills the relevant electric field offload struct with parameters and allocates and fills the offload array.
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.
offload_data | pointer to offload data struct |
offload_array | pointer to pointer to offload array |
void E_field_free_offload | ( | E_field_offload_data * | offload_data, |
real ** | offload_array ) |
int E_field_init | ( | E_field_data * | Edata, |
E_field_offload_data * | offload_data, | ||
real * | offload_array ) |
Initialize electric field data struct on target.
This function copies the electric field parameters from the offload struct to the struct on target and sets the electric field data pointers to correct offsets in the offload array.
This function returns error if the offload data has not been initialized. The instances themselves should not return an error since all they do is assign pointers and values.
Edata | pointer to data struct on target |
offload_data | pointer to offload data struct |
offload_array | the offload array |
a5err E_field_eval_E | ( | real | E[3], |
real | r, | ||
real | phi, | ||
real | z, | ||
real | t, | ||
E_field_data * | Edata, | ||
B_field_data * | Bdata ) |
Evaluate electric field.
This function evaluates the electric field at the given coordinates. Note that magnetic field data is also required in case electric field is e.g. a flux quantity.
The values are stored in the given array as:
This is a SIMD function.
E | pointer to array where electric field values are stored |
r | R coordinate [m] |
phi | phi coordinate [deg] |
z | z coordinate [m] |
t | time coordinate [s] |
Edata | pointer to electric field data struct |
Bdata | pointer to magnetic field data struct |