-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxwell.h
165 lines (144 loc) · 2.64 KB
/
maxwell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef MAXWELL_H
#define MAXWELL_H
#include <GLFW/glfw3.h>
#define CL_TARGET_OPENCL_VERSION 300
#include <CL/cl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define SPEED_OF_LIGHT 299792458.0
#define VACUUM_PERMITTIVITY 8.854e-12
#define VACUUM_PERMEABILITY 1.2566e-6
#define DT 1e-2
#define MAX_FIELD 1e2
#define MIN_FIELD 0
#define MX_DT_SCALE 0.9
#define MX_MAX_MATERIALS 1000
#define MX_MAX_MAT_ARGS 10
#define MX_MAT_ARGC_TRIANGLE 9
#define MX_MAT_ARGC_CIRCLE 6
#define MX_MAT_BOUNDARY_PX 1
#define MX_STRING_ARGL 255
#define MX_MAX_SRC_ARGS 10
#define MX_SIMFILE_MAX_LINEL 256
#define MX_SIMDEF_NSEC 3
#define MX_MAX_SOURCES 1000
#define MX_FC_STRL 10
#define MX_SRC_ARGC_SINELINFREQ 4
#define MX_BC_DEFAULT BC_NAT
#define MX_BC_PML_DEF_LAYERS 100
#define MX_BC_PML_DEF_SIGMA 1e-4
#define MX_BC_PML_DEF_SIGPOLYORDER 1
#define MX_BC_PML_ARGC 3
typedef enum {
VIS_TE_1 = 0,
VIS_TE_2,
VIS_MAX
} VisualizationFunction;
typedef enum {
BC_UNK = 0,
BC_NAT,
BC_PEC,
BC_PML
} BoundaryCondition;
typedef struct {
float* Epsilon;
float* Mu;
float* Ex;
float* Ey;
float* Ez;
float* Hx;
float* Hy;
float* Hz;
float ezMin;
float ezMax;
float* Sigma;
} Field;
typedef struct {
int width;
int height;
float time;
float dt;
float dx;
float dy;
int sourcec;
int materialc;
VisualizationFunction vis_fxn;
float* image;
float* matBoundMask;
int frame;
int pml_layers;
float pml_conductivity;
int pml_sigma_polyorder;
clock_t start_time;
cl_mem Ez_kbuf;
cl_mem Hx_kbuf;
cl_mem Hy_kbuf;
cl_mem Epsilon_kbuf;
cl_mem Mu_kbuf;
cl_mem image_kbuf;
cl_mem matBoundMask_kbuf;
cl_mem Sigma_kbuf;
cl_context context;
cl_command_queue queue;
cl_program program;
cl_kernel E_kernel;
cl_kernel H_kernel;
cl_kernel VIS_TE_1_kernel;
cl_kernel VIS_TE_2_kernel;
cl_kernel drawMatBounds_kernel;
BoundaryCondition boundary_condition;
} Simulation;
typedef enum {
TYPE_INT,
TYPE_DOUBLE,
TYPE_FLOAT,
TYPE_STRING
} ArgType;
typedef union {
int intVal;
double doubleVal;
float floatVal;
char stringVal[MX_STRING_ARGL];
} ArgValue;
typedef struct {
ArgType type;
ArgValue value;
} Argument;
typedef enum {
SINELINFREQ
} SourceFunction;
typedef enum {
FC_EPS,
FC_MU,
FC_EX,
FC_EY,
FC_EZ,
FC_HX,
FC_HY,
FC_HZ
} FieldComponent;
typedef struct {
SourceFunction fxn;
FieldComponent fc;
int argc;
Argument argv[MX_MAX_SRC_ARGS];
} Source;
typedef enum {
MG_UNKNOWN,
MG_TRIANGLE,
MG_CIRCLE
} MaterialGeometry;
typedef struct {
MaterialGeometry geom;
float rel_eps;
float rel_mu;
float sigma;
int argc;
Argument argv[MX_MAX_MAT_ARGS];
int* boundary;
} Material;
#endif