forked from zuowangda/Fast-Fluid-Dynamics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_structure.h
315 lines (278 loc) · 8.32 KB
/
data_structure.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#ifndef _DATA_STRUCTURE_H_
#define _DATA_STRUCTURE_H_
///////////////////////////////////////////////////////////////////////////////
//
// Filename: data_structure.h
//
// Written by: Wangda Zuo
//
// Last Modified: Wangda Zuo on 7/10/2013
//
// Task: Defines the data structure of FFD
//
//////////////////////////////////////////////////////////////////////////////
#include <time.h>
#ifdef _MSC_VER
#include <windows.h>
#include <conio.h>
#endif
#define IX(i,j,k) ((i)+(IMAX)*(j)+(IJMAX)*(k))
#define FOR_EACH_CELL for(i=1; i<=imax; i++) { for(j=1; j<=jmax; j++) { for(k=1; k<=kmax; k++) {
#define FOR_ALL_CELL for(k=0; k<=kmax+1; k++) { for(j=0; j<=jmax+1; j++) { for(i=0; i<=imax+1; i++) {
#define FOR_U_CELL for(k=1; k<=kmax; k++) { for(j=1; j<=jmax; j++) { for(i=1; i<=imax-1; i++) {
#define FOR_V_CELL for(i=1; i<=imax; i++) { for(j=1; j<=jmax-1; j++) { for(k=1; k<=kmax; k++) {
#define FOR_W_CELL for(i=1; i<=imax; i++) { for(j=1; j<=jmax; j++) { for(k=1; k<=kmax-1; k++) {
#define FOR_KI for(i=1; i<=imax; i++) { for(k=1; k<=kmax; k++) {{
#define FOR_IJ for(i=1; i<=imax; i++) { for(j=1; j<=jmax; j++) {{
#define FOR_JK for(j=1; j<=jmax; j++) { for(k=1; k<=kmax; k++) {{
#define END_FOR }}}
#define REAL float
#ifndef max
#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
#endif
#define PI 3.1415926
#define X 0
#define Y 1
#define Z 2
#define VX 3
#define VY 4
#define VZ 5
#define VXM 6
#define VYM 7
#define VZM 8
#define VXS 9
#define VYS 10
#define VZS 11
#define DEN 12
#define DENS 13
#define IP 14
#define TMP1 15
#define TMP2 16
#define TMP3 17
#define TEMP 18
#define TEMPS 19
#define TEMPM 20
#define AP 21
#define AN 22
#define AS 23
#define AW 24
#define AE 25
#define AF 26
#define AB 27
#define B 28
#define GX 29
#define GY 30
#define GZ 31
#define AP0 32
#define PP 33
#define FLAGP 34
#define FLAGU 35
#define FLAGV 36
#define FLAGW 37
#define LOCMIN 38
#define LOCMAX 39
#define VXBC 40
#define VYBC 41
#define VZBC 42
#define TEMPBC 43
#define QFLUXBC 44 // Heat flux on the boundary
#define QFLUX 45 // Heat flux
typedef enum{NOSLIP, SLIP, INFLOW, OUTFLOW, PERIODIC,SYMMETRY} BCTYPE;
typedef enum{TCONST, QCONST, ADIBATIC} BCTTYPE;
typedef enum{GS, TDMA} SOLVERTYPE;
typedef enum{SEMI, LAX, UPWIND, UPWIND_NEW} ADVECTION;
typedef enum{LAM, CHEN, CONSTANT} TUR_MODEL;
typedef enum{BILINEAR, FSJ, HYBRID} INTERPOLATION;
typedef enum{DEMO, DEBUG, RUN} VERSION;
typedef enum{FFD, SCI, TECPLOT} FILE_FORMAT;
typedef enum{FFD_WARNING, FFD_ERROR, FFD_NORMAL, FFD_NEW} FFD_MSG_TYPE;
typedef struct
{
REAL t;
int status;
REAL number[3];
char message[20];
}ffdSharedData;
typedef struct
{
REAL t;
int status;
REAL arr[3];
char message[30];
}otherSharedData;
// Parameter for geometry and mesh
typedef struct
{
REAL Lx; // Domain size in x-direction (meter)
REAL Ly; // Domain size in y-direction (meter)
REAL Lz; // Domain size in z-direction (meter)
int imax; // Number of interior cells in x-direction
int jmax; // Number of interior cells in y-direction
int kmax; // Number of interior cells in z-direction
int index; // Total number of boundary cells
REAL dx; // Length delta_x of one cell in x-direction for uniform grid only
REAL dy; // Length delta_y of one cell in y-direction for uniform grid only
REAL dz; // Length delta_z of one cell in z-direction for uniform grid only
int uniform; // Only for generating grid by FFD. 1: uniform grid; 0: non-uniform grid
int i1; // Fixme: May be deleted
int i2;
int i3;
int i4;
int i5;
int i6;
int i7;
int i8;
int i9;
int i10;
int i11;
int i12;
int i13;
int i14;
REAL x1; // Fixme: May be deleted
REAL x2;
REAL x3;
REAL x4;
REAL x5;
REAL x6;
REAL x7;
REAL x8;
REAL x9;
REAL x10;
REAL x11;
REAL x12;
REAL x13;
REAL x14;
int j1; // Fixme: May be deleted
int j2;
int j3;
int j4;
int j5;
int j6;
int j7;
int j8;
int j9;
int j10;
REAL y1; // Fixme: May be deleted
REAL y2;
REAL y3;
REAL y4;
REAL y5;
REAL y6;
REAL y7;
REAL y8;
REAL y9;
REAL y10;
int k1; // Fixme: May be deleted
int k2;
int k3;
int k4;
REAL z1;
REAL z2;
REAL z3;
REAL z4;
} GEOM_DATA;
typedef struct{
int cal_mean; // 1: Calculate mean value; 0: False
REAL v_ref; // Reference velocity for visualization
REAL Temp_ref; // Reference temperature for visualizations
REAL v_length; // Change of velocity vector length in demo window
int i_N; // Number of grids plotted in x direction
int j_N; // Number of grids plotted in y direction
int winx; // Resolution of screen at x direction in pixel
int winy; // Resolution of screen at y direction in pixel
int omx; // Internal
int omy; // Internal
int mx; // Internal
int my; // Internal
int win_id; // Internal: Windows id
int mouse_down[3]; // Internal: Record for mouse action
VERSION version; // DEMO, DEBUG, RUN
int screen; // Screen for display: 1 velocity; 2: temperature; 3: contaminant
int tstep_display; // Number of time steps to update the visualziation
} OUTP_DATA;
typedef struct{
FILE_FORMAT parameter_file_format; // Foramt of extra parameter file
char parameter_file_name[50]; // Name of extra parameter file
int read_old_ffd_file; // 1: Read previous FFD file; 0: False
char old_ffd_file_name[50]; // Name of previous FFD simulation data file
} INPU_DATA;
typedef struct{
REAL nu; // Kinematic viscosity
REAL rho; // Density
REAL diff; // Diffusivity for contaminants
REAL alpha; // Thermal diffusity
REAL coeff_h; // Convective heat transfer coefficient near the wall
REAL gravx; // Gravity in x direction
REAL gravy; // Gravity in y direction
REAL gravz; // Gravity in z direction
REAL beta; // Thermal expansion coefficient
REAL cond; // Conductivity
//REAL trefmax; // T Reference max defined by SCI
REAL Cp; // Specific heat capacity
REAL force; // Force to be added in demo window for velocity when left-click on mouse
REAL source; // Source to be added in demo window for contaminants when right click on mouse
int movie; // Output data for making animation (1:yes, 0:no)
int output; // Internl: 0: have not been written; 1: done
TUR_MODEL tur_model; // LAM, CHEN, CONSTANT
REAL chen_a; // Coefficeint of Chen's zero euqation turbulence model
REAL Prt; // Turbulent Prandl number
REAL Temp_Buoyancy; // Reference temperature for calucating buoyancy force
}PROB_DATA;
typedef struct{
int nb_inlet; // Number of inlet boundaries, provided by SCI
int nb_outlet; // Number of outlet boundaries, provided by SCI
int nb_block; // Number of internal block boundaries, provided by SCI
int nb_wall; // Number of wall boundaries, provided by SCI
int nb_source; // Number of sources, provided by SCI
int nb_bc; // Number of boundaries, provided by SCI
char** bcname;
char ffdbcid[100]; // BC id stored in FFD
char otherbcid[100]; // BC id for the other program
}BC_DATA;
typedef struct
{
REAL dt; // FFD simulation time step size
REAL t; // Internal: current time
REAL t_steady; // Necessary time for reaching the steady state from initial condition
REAL dt_cosim; // Time step for co-simulation data exchange
int step_total; // The interval of iteration step to output data
int step_current; // Internal: current iteration step
clock_t t_start; // Internal: clock time when simulation starts
clock_t t_end; // Internal: clock time when simulaiton ends
}TIME_DATA;
typedef struct
{
SOLVERTYPE solver; // Solver type: GS, TDMA
int check_residual; // 1: check, 0: donot check
ADVECTION advection_solver; // Tyep of advection solver: SEMI, LAX, UPWIND, UPWIND_NEW
INTERPOLATION interpolation; // Internploation in semi-Lagrangian method: BILINEAR, FSJ, HYBRID
int cosimulation; // 0: single; 1: cosimulation
int nextstep; // Internal: 1: yes; 0: no, wait
}SOLV_DATA;
typedef struct
{
GEOM_DATA *geom;
INPU_DATA *inpu;
OUTP_DATA *outp;
PROB_DATA *prob;
TIME_DATA *mytime;
BC_DATA *bc;
SOLV_DATA *solv;
}PARA_DATA;
typedef struct {
double number0;
double number1;
int command;
} ReceivedData;
typedef struct {
int feedback;
} SentCommand;
typedef struct {
double number0;
double number1;
int command;
}SentData;
typedef struct {
int feedback;
}ReceivedCommand;
#endif