-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathisodns.cpl
255 lines (221 loc) · 8.28 KB
/
isodns.cpl
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
!==============================================================================!
! ISODNS !
! -------------- !
! !
! Direct Numerical Simulation of Homogeneous Isotropic Turbulence !
! !
! ** Main program for DNS run ** !
! !
! Program features: !
! ------------------- !
! !
! - Very Efficient velocity-vorticity formulation !
! !
! - Optional solenoidal volume force !
! !
! - SMP (Simmetric Multi-Processing) parallel implementation !
! !
! - Low storage mixed RK3/4 - CN ode schemes !
! !
!------------------------------------------------------------------------------!
! !
! Author : M. Carini (DIA-PoliMI) and D. Gatti (KIT) !
! Date : March 2015 !
! CPL version : October 2009 !
! !
!==============================================================================!
!USE rtchecks
USE isodnsdata
!------------------------------------------------------------------------------!
!------------------------ Macros's definitions --------------------------------!
#define correlations
!#define startup_AB
#define corr_msg
#define save_msg
#define cfl_msg
!#define save_all_sol_mode
!#define save_all_corr_mode
!#define no_iter_msg
!------------------------------------------------------------------------------!
!---------------------------- Run setup ---------------------------------------!
i0 = memlevels
#ifdef correlations
ARRAY(0..N,-N..N,-N..N) OF T_CORR VVms=0
#endif
FILE runfile = OPEN('input/isorun.in')
READ BY NAME FROM runfile nsteps, t0, dt, nsteps_save, nsteps_cfl, restart, \
sol_old, rhs_old, isosavepath
#ifdef runtime_stat
READ BY NAME FROM runfile restart_stat, kineps_old, spectra_old
#endif
#ifdef correlations
READ BY NAME FROM runfile restart_corr, corr_old, corrlog_old
#endif
CLOSE runfile
STRING outfile1,outfile2
!------------------------- Print echo run setup ------------------------------!
WRITE '===================================================='
WRITE ' ISODNS '
WRITE ' -------- '
WRITE ' Direct Numerical Simulation '
WRITE ' of Homogeneous Isotropic Turbulence '
WRITE '----------------------------------------------------'
WRITE ''
WRITE ' Echo of isodnsdata.in :'
WRITE ''
WRITE ' - Dealiased Fourirer modes (-N..N) N = ',N
WRITE ' - Aliased Fourier modes (0..M-1) M = ',M
WRITE ' - Forcing scales (1..kf) kf/k0 = ',kf
WRITE ' - Kolmogorov scale kd/k0 = ',kd
WRITE ' - Energy injection rate P = ',P
WRITE ''
WRITE '----------------------------------------------------'
WRITE ''
WRITE ' Echo of isorun.in :'
WRITE ''
WRITE ' - Number of time steps nsteps = ',nsteps
WRITE ' - Time step size dt = ',dt
WRITE ' - update CFL every nsteps nsteps_cfl = ',nsteps_cfl
WRITE ' - Save every nsteps nsteps_save = ',nsteps_save
WRITE ' - Save directory: ',isosavepath
IF restart THEN
WRITE ' - Restart time t0 = ',t0
WRITE ' - Restart from solution: ',sol_old
IF memlevels > 1 THEN
WRITE ' - Restart from rhs: ',rhs_old
END IF
#ifdef correlations
IF restart_corr THEN
WRITE ' - Correlations restart files: ',corr_old
WRITE ' ',corrlog_old
END IF
#endif
#ifdef runtime_stat
IF restart_stat THEN
WRITE ' - Runtime statistics restart files: ',kineps_old
WRITE ' ',spectra_old
END IF
#endif
ELSE
WRITE ' - Generation of the initial field (Rogallo) '
END IF
WRITE ''
WRITE '===================================================='
!------------------------------------------------------------------------------!
spectra = CREATE(WRITE(isosavepath'spectra'nsteps*dt+t0'-kf'kf'.dat'))
kineps = CREATE(WRITE(isosavepath'kineps'nsteps*dt+t0'-kf'kf'.dat'))
save_count = nsteps_save; cfl_count = nsteps_cfl
!------------------------------------------------------------------------------!
SUBROUTINE interface(INTEGER dummy)
IF memlevels-dummy = cfl_count THEN
getcfl; cfl_count = ~+nsteps_cfl
#ifdef cfl_msg
WRITE '------------------------'
WRITE 'CFL =', CFL
WRITE '------------------------'
#endif
END IF
#ifdef runtime_stat
update_kineps()
#else
savekineps((memlevels-dummy)*dt)
#endif
#ifdef correlations
update_iso_corr(VVms)
#endif
END interface
!------------------------------------------------------------------------------!
!-------------------- setup initial field and data ----------------------------!
IF restart THEN
readsol(sol_old,rhs_old)
#ifdef correlations
IF restart_corr THEN
read_iso_corr(VVms,corr_old,corrlog_old)
END IF
#endif
#ifdef startup_AB
set_CN_RK3_coeff; initAB(CN_RK,3,interface); i0 = memlevels +1
#endif
#ifdef runtime_stat
IF restart_stat THEN
readmkineps()
END IF
#endif
ELSE
initRogallo(E0Pope)
#ifdef startup_AB
set_CN_RK3_coeff; initAB(CN_RK,3,interface); i0 = memlevels +1
#endif
END IF
set_CN_RK3_coeff
!set_AB3IF_coeff()
!------------------------------------------------------------------------------!
!------------------------- ode integration ------------------------------------!
LOOP timeloop FOR i = i0 TO nsteps
#ifndef no_iter_msg
WRITE 'Time step n',i,'of',nsteps
#endif
timestep(CN_RK,3)
!timestep(AB3IF,1)
#ifdef correlations
update_iso_corr(VVms)
#endif
IF i = cfl_count THEN
getcfl; cfl_count = ~+nsteps_cfl
#ifdef cfl_msg
WRITE '------------------------'
WRITE 'CFL =', CFL
WRITE '------------------------'
#endif
END IF
buildspectra
#ifdef runtime_stat
update_kineps()
#else
savekineps(i*dt+t0)
#endif
IF i = save_count THEN
#ifdef runtime_stat
savemkineps()
#endif
#ifdef save_all_sol_mode
outfile1=''isosavepath'sol'save_count*dt+t0'.bin'
outfile2=''isosavepath'sol'save_count*dt+t0'.bin'
savesol(outfile1,outfile2)
#else
outfile1=''isosavepath'sol_saved.bin'
outfile2=''isosavepath'rhs_saved.bin'
savesol(outfile1,outfile2)
outfile1=''isosavepath'sol_saved_copy.bin'
outfile2=''isosavepath'rhs_saved_copy.bin'
savesol(outfile1,outfile2)
#endif
#ifdef correlations
#ifdef save_all_corr_mode
outfile1=''isosavepath'corr'save_count*dt+t0'.bin'
outfile2=''isosavepath'corr'save_count*dt+t0'.log'
save_iso_corr(VVms,outfile1,outfile2)
#else
outfile1=''isosavepath'corr_saved.bin'
outfile2=''isosavepath'log_corr.txt'
save_iso_corr(VVms,outfile1,outfile2)
outfile1=''isosavepath'corr_saved_copy.bin'
outfile2=''isosavepath'log_corr_copy.txt'
save_iso_corr(VVms,outfile1,outfile2)
#endif
#ifdef corr_msg
WRITE '-------------------'
WRITE 'Correlations saved '
WRITE '-------------------'
#endif
#endif
save_count =~+nsteps_save
#ifdef save_msg
WRITE '-------------------------------'
WRITE 'Solution saved to binary files '
WRITE '-------------------------------'
#endif
END IF
REPEAT timeloop
CLOSE kineps; CLOSE spectra
!==============================================================================!