ASCOT5
Loading...
Searching...
No Matches
E_field.c
Go to the documentation of this file.
1
16#include <stdio.h>
17#include "ascot5.h"
18#include "error.h"
19#include "print.h"
20#include "E_field.h"
21#include "B_field.h"
22#include "Efield/E_TC.h"
23#include "Efield/E_1DS.h"
24
42 real** offload_array) {
43 int err = 0;
44
45 switch(offload_data->type) {
46
48 err = E_1DS_init_offload(&(offload_data->E1DS), offload_array);
49 offload_data->offload_array_length =
50 offload_data->E1DS.offload_array_length;
51 break;
52
53 case E_field_type_TC:
54 err = E_TC_init_offload(&(offload_data->ETC), offload_array);
55 offload_data->offload_array_length =
56 offload_data->ETC.offload_array_length;
57 break;
58
59 default:
60 /* Unregonized input. Produce error. */
61 print_err("Error: Unregonized electric field type.");
62 err = 1;
63 break;
64 }
65
66 if(!err) {
67 print_out(VERBOSE_IO, "Estimated memory usage %.1f MB\n",
68 offload_data->offload_array_length
69 * sizeof(real) / (1024.0*1024.0) );
70 }
71
72 return err;
73}
74
86 real** offload_array) {
87 switch(offload_data->type) {
88
90 E_1DS_free_offload(&(offload_data->E1DS), offload_array);
91 break;
92
93 case E_field_type_TC:
94 E_TC_free_offload(&(offload_data->ETC), offload_array);
95 break;
96 }
97}
98
117 real* offload_array) {
118 int err = 0;
119
120 switch(offload_data->type) {
121
122 case E_field_type_1DS:
123 E_1DS_init(&(Edata->E1DS), &(offload_data->E1DS), offload_array);
124 break;
125
126 case E_field_type_TC:
127 E_TC_init(&(Edata->ETC), &(offload_data->ETC), offload_array);
128 break;
129
130 default:
131 /* Unregonized input. Produce error. */
132 print_err("Error: Unregonized electric field type.\n");
133 err = 1;
134 break;
135 }
136 Edata->type = offload_data->type;
137
138 return err;
139}
140
167 E_field_data* Edata, B_field_data* Bdata) {
168 a5err err = 0;
169
170 switch(Edata->type) {
171
172 case E_field_type_1DS:
173 err = E_1DS_eval_E(E, r, phi, z, &(Edata->E1DS), Bdata);
174 break;
175
176 case E_field_type_TC:
177 err = E_TC_eval_E(E, r, phi, z, &(Edata->ETC), Bdata);
178 break;
179
180 default:
181 /* Unregonized input. Produce error. */
182 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_E_FIELD );
183 break;
184 }
185
186 return err;
187}
Header file for B_field.c.
void E_1DS_free_offload(E_1DS_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
Definition E_1DS.c:78
int E_1DS_init_offload(E_1DS_offload_data *offload_data, real **offload_array)
Initialize 1DS electric field data.
Definition E_1DS.c:41
void E_1DS_init(E_1DS_data *Edata, E_1DS_offload_data *offload_data, real *offload_array)
Initialize 1D spline electric field data struct on target.
Definition E_1DS.c:95
a5err E_1DS_eval_E(real E[3], real r, real phi, real z, E_1DS_data *Edata, B_field_data *Bdata)
Evaluate 1D spline radial electric field.
Definition E_1DS.c:122
Header file for E_1DS.c.
void E_TC_free_offload(E_TC_offload_data *offload_data, real **offload_array)
Free offload array and return null pointer.
Definition E_TC.c:53
a5err E_TC_eval_E(real E[3], real r, real phi, real z, E_TC_data *Edata, B_field_data *Bdata)
Evaluate electric field.
Definition E_TC.c:86
void E_TC_init(E_TC_data *Edata, E_TC_offload_data *offload_data, real *offload_array)
Initialize electric field simulation data.
Definition E_TC.c:66
int E_TC_init_offload(E_TC_offload_data *offload_data, real **offload_array)
Initialize electric field data and check inputs.
Definition E_TC.c:33
Header file for E_TC.c.
int E_field_init(E_field_data *Edata, E_field_offload_data *offload_data, real *offload_array)
Initialize electric field data struct on target.
Definition E_field.c:116
int E_field_init_offload(E_field_offload_data *offload_data, real **offload_array)
Load electric field data and prepare parameters.
Definition E_field.c:41
void E_field_free_offload(E_field_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
Definition E_field.c:85
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.
Definition E_field.c:166
Header file for E_field.c.
@ E_field_type_TC
Definition E_field.h:26
@ E_field_type_1DS
Definition E_field.h:27
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Error module for ASCOT5.
unsigned long int a5err
Simulation error flag.
Definition error.h:17
@ EF_E_FIELD
Definition error.h:43
@ ERR_UNKNOWN_INPUT
Definition error.h:64
static DECLARE_TARGET_SIMD a5err error_raise(error_type type, int line, error_file file)
Raise a new error.
Definition error.h:86
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
Definition print.h:31
@ VERBOSE_IO
Definition print.h:20
#define print_err(...)
Print to standard error.
Definition print.h:42
Magnetic field simulation data.
Definition B_field.h:63
int offload_array_length
Definition E_1DS.h:24
int offload_array_length
Definition E_TC.h:21
Electric field simulation data.
Definition E_field.h:55
E_TC_data ETC
Definition E_field.h:57
E_field_type type
Definition E_field.h:56
E_1DS_data E1DS
Definition E_field.h:58
Electric field offload data.
Definition E_field.h:39
E_TC_offload_data ETC
Definition E_field.h:41
E_1DS_offload_data E1DS
Definition E_field.h:42
E_field_type type
Definition E_field.h:40