Peka2D_v5  v5.0
define.h
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <string.h>
5 #include <math.h>
6 #include <time.h>
7 #include <omp.h>
8 
9 #define LINUX_COMPILATION 1
10 
11 #if LINUX_COMPILATION==1
12 
16  #ifndef SOLVER
17  #define SOLVER 1
18  #endif
19 
24  #ifndef SET_SIMGPU
25  #define SET_SIMGPU 1
26  #endif
27 
28  #if SET_SIMGPU
29  #define SET_OPENMP 0 //always disableb for GPU compilation
30  #else
35  #define SET_OPENMP 4
36  #endif
37 
42  #ifndef SET_SOLUTE
43  #define SET_SOLUTE 1
44  #endif
45 
46 #endif
47 
52 #ifndef RECONSTRUC_ACTIVE
53  #define RECONSTRUC_ACTIVE 1
54  #define nIterArrangeActElem 200
55 #endif
56 
61 #define BINARY_VTK 1
62 
69 #define APP_MODE 0
70 
74 #define EXPORT_DLL_MODE 0
75 #if EXPORT_DLL_MODE==1
76  #ifndef EXPORT_DLL
77  #define EXPORT_DLL extern "C" __declspec(dllexport)
78  #endif
79 #else
80  #define EXPORT_DLL
81 #endif
82 
83 
84 #define FT2MFACT (1/3.2808)
85 #define M2FTFACT (3.2808)
86 #define LB2KGFACT (1/2.2046)
87 #define KG2LBFACT (2.2046)
88 #define FT32M3FACT ((1/3.2808)*(1/3.2808)*(1/3.2808))
89 #define M32FT3FACT (3.2808*3.2808*3.2808)
90 #define PSI2PASCFACT (6894.75729)
91 #define FT22M2FACT ((1/3.2808)*(1/3.2808))
92 #define BTU2JOULE (1055.056)
93 
94 
95 
96 //Program's config
97 #define WRITE_STATE 1
98 #define WRITE_MASS 1
99 #define threadsPerBlock 128
100 
101 
102 //Other definitions
103 #define IBC_WEIR 1
104 #define IBC_GATE 2
105 #define IBC_RATING_TABLE 3
106 #define IBC_DAMBREACH 4
107 
108 //Constants and flags
109 #ifndef SIGN
110  #define SIGN(x) ((x > 0.) - (x < 0.))
111 #endif
112 
113 #ifndef MIN
114  #define MIN(x,y) (((x)<(y))?(x):(y))
115 #endif
116 
117 #ifndef MAX
118  #define MAX(x,y) (((x)>(y))?(x):(y))
119 #endif
120 
121 #ifndef MINMAX
122  #define MINMAX(x,y,z) (((z) < (x)) ? (x) : (((z) > (y)) ? (y) : (z)))
123 #endif
124 
125 #if defined(_WIN32) || defined(_WIN64)
126  #ifndef WIN32
127  #define WIN32
128  #endif
129  #ifndef CBRT
130  #define CBRT(x) (pow(x,1./3.))
131  #endif
132  #pragma warning (disable:4996)
133  #define snprintf sprintf_s
134 #else
135  #ifndef CBRT
136  #define CBRT(x) (cbrt(x))
137  #endif
138 #endif
139 
140 #define MAXHMIN 0.01
141 #define MINHMIN 0.0005
142 #define MAX_ANGLE_HYDRONIA_MESH 15.0
143 
144 #define _X_ 0
145 #define _Y_ 1
146 
147 #define TOL3 1e-3
148 #define TOL4 1e-4
149 #define TOL5 1e-5
150 #define TOL6 1e-6
151 #define TOL9 1e-9
152 #define TOL12 1e-12
153 #define TOL14 1e-14
154 #define TOL16 1e-16
155 
156 #ifndef _PI_
157  #define _PI_ 3.1415926535897
158 #endif
159 #ifndef _g_
160  #define _g_ 9.80665
161 #endif
162 #ifndef _e_
163  #define _e_ 2.71828
164 #endif
165 #define _raizg_ 3.1315571206669694 //sqrt(_g_)
166 #define _atan1_ 0.785398163397448 //atan(1.0)
167 #define _dospi_ 6.283185307179584 //2*pi
168 
169 #define _rhow_ 1000.0 // Water density (kg/m3)
170 #define _nu_ 0.00000151 // Water kinematic viscosity (m2/s)
171 #define _cp_ 4182.0
172 
173 // NOTIFICATIONS
174 #define MSG_ERROR -10
175 #define MSG_WARN -1
176 #define MSG_L0 0
177 #define MSG_L1 1
178 #define MSG_L2 2
179 #define MSG_L3 3
180 
181 //DEBUGS
182 #define DISPLAY 1
183 
184 // colors
185 #define KNRM "\x1B[0m"
186 #define KRED "\x1B[31m"
187 #define KGRN "\x1B[32m"
188 #define KYEL "\x1B[33m"
189 #define KBLU "\x1B[34m"
190 #define KMAG "\x1B[35m"
191 #define KCYN "\x1B[36m"
192 #define KWHT "\x1B[37m"
193 // bold
194 #define BOLD "\x1B[1m"
195 #define BRED "\x1B[1;31m"
196 #define BGRN "\x1B[1;32m"
197 #define BYEL "\x1B[1;33m"
198 #define BBLU "\x1B[1;34m"
199 #define BMAG "\x1B[1;35m"
200 #define BCYN "\x1B[1;36m"
201 #define BWHT "\x1B[1;37m"
202 
203 #ifndef MSGERROR
204  #if defined(_WIN32)
205  #define MSGERROR " [FAIL] "
206  #else
207  #define MSGERROR " \033[1;31m[FAIL]\033[0m "
208  #endif
209 #endif
210 
211 #ifndef MSGOK
212  #if defined(_WIN32)
213  #define MSGOK " [_OK_] "
214  #else
215  #define MSGOK " \033[1;32m[_OK_]\033[0m "
216  #endif
217 #endif
218 
219 #ifndef MSGINFO
220  #if defined(_WIN32)
221  #define MSGINFO " [INFO] "
222  #else
223  #define MSGINFO " \033[1;35m__ii__\033[0m "
224  #endif
225 #endif
226 
227 #ifndef MSGLOAD
228  #if defined(_WIN32)
229  #define MSGLOAD " [LOAD] "
230  #else
231  #define MSGLOAD " \033[1;36m[LOAD]\033[0m "
232  #endif
233 #endif
234 
235 #ifndef MSGMEMO
236  #if defined(_WIN32)
237  #define MSGMEMO " [MEMO] "
238  #else
239  #define MSGMEMO " \033[1;34m[MEMO]\033[0m "
240  #endif
241 #endif
242 
243 #ifndef MSGREAD
244  #if defined(_WIN32)
245  #define MSGREAD " [READ] "
246  #else
247  #define MSGREAD " \033[1;34m[READ]\033[0m "
248  #endif
249 #endif
250 
251 #ifndef MSGGPU
252  #if defined(_WIN32)
253  #define MSGGPU " [GPU_] "
254  #else
255  #define MSGGPU " \033[1;36m[CUDA]\033[0m "
256  #endif
257 #endif
258 
259 #ifndef MSGEXC
260  #if defined(_WIN32)
261  #define MSGEXC " [EXC_] "
262  #else
263  #define MSGEXC " \033[1;34m[EXEC]\033[0m "
264  #endif
265 #endif
266 
267 #ifndef MSGWARN
268  #if defined(_WIN32)
269  #define MSGWARN " [WARN] "
270  #else
271  #define MSGWARN " \033[1;33m[WARN]\033[0m "
272  #endif
273 #endif
274 
275 
276 #define DEBUGMSG printf("file '%s' in line %i\n",\
277  __FILE__, __LINE__ );
278 
279 #define CUT_CHECK_ERROR(errorMessage) do {\
280  cudaThreadSynchronize();\
281  cudaError_t err = cudaGetLastError();\
282  if( cudaSuccess != err) {\
283  fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n",\
284  errorMessage, __FILE__, __LINE__, cudaGetErrorString( err) );\
285  exit(EXIT_FAILURE);\
286  } } while (0)
287 
288 
289 #define DUMPDELTAT 0
290 #define DEBUG 0
291 #define DEBUG_READ_BOUNDS 0
292 #define DEBUG_READ_SECTIONS 0
293 #define DEBUG_READ_SOURCES 0
294 #define WRITE_FROUDE 0
295 
296 
297 //flux limiters
298 #define FLUX_LIMITER 0 //0--> minMod 1--> Van Albada 2-->sweby beta=1.5 MinMod recommended
299 
300 #define functionPhi0(y) MAX(0.0,MIN(1.0,y)) //minMod
301 #define functionPhi1(y) (y*y + y)/(y*y+1) //van Albada
302 #define functionPhi2(y) MAX(0.0,(MIN(1.5*y,1.0),MIN(y,1.5))) //sweby
303 
304 #if FLUX_LIMITER==0
305  #define functionPhi(y) functionPhi0(y)
306 #endif
307 
308 #if FLUX_LIMITER==1
309  #define functionPhi(y) functionPhi1(y)
310 #endif
311 
312 #if FLUX_LIMITER==2
313  #define functionPhi(y) functionPhi2(y)
314 #endif
315 
316 
317 // Hydrodynamic friction models
318 #define HFM_MANNING 0
319 #define HFM_CHEZY 1
320 #define HFM_DW 2
321 // By default the Manning model is used. You should choose the friction model at compilation time. You can do this when calling the makefile by specifying FRICTION=your_chosen_model_index
322 #ifndef HYDRO_FRICTION
323  #define HYDRO_FRICTION HGM_MANNING
324 #endif