-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModBC_actual.f90
executable file
·463 lines (326 loc) · 10.5 KB
/
ModBC_actual.f90
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
MODULE ModBC
CONTAINS
SUBROUTINE CallBoundaryConditions
USE module_variables
IMPLICIT NONE
CALL BoundaryConditions
CALL sponge_bcs
END SUBROUTINE CallBoundaryConditions
SUBROUTINE BoundaryConditions
USE module_variables
IMPLICIT NONE
! Inflow and outflow SAT boundary condition
lam = 0.0D0
DO patch_no = 1, no_bcs
IF(patch(patch_no)%bc .eq. AXIS)CYCLE
IF(patch(patch_no)%bc_dir .eq. 1)THEN
i_start = patch(patch_no)%i_start
i_end = patch(patch_no)%i_start
j_start = patch(patch_no)%j_start
j_end = patch(patch_no)%j_end
ELSEIF(patch(patch_no)%bc_dir .eq. -1)THEN
i_start = patch(patch_no)%i_end
i_end = patch(patch_no)%i_end
j_start = patch(patch_no)%j_start
j_end = patch(patch_no)%j_end
ELSEIF(patch(patch_no)%bc_dir .eq. 2)THEN
i_start = patch(patch_no)%i_start
i_end = patch(patch_no)%i_end
j_start = patch(patch_no)%j_start
j_end = patch(patch_no)%j_start
ELSEIF(patch(patch_no)%bc_dir .eq. -2)THEN
i_start = patch(patch_no)%i_start
i_end = patch(patch_no)%i_end
j_start = patch(patch_no)%j_end
j_end = patch(patch_no)%j_end
ENDIF
IF(patch(patch_no)%bc .eq. SAT_FARFIELD)THEN
DO i = i_start, i_end
DO j = j_start, j_end
DO k = 1, 1
IF(j .eq. 1)CYCLE
IF(abs(patch(patch_no)%bc_dir) .eq. 1)THEN
CALL eigen_matrices_in_z_direction
CALL compute_SAT_RHS
DO eqn = 1, neqns
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) + sigma_1*dxidz(i,j,k)*one_by_h_44*rhs_SAT(eqn)
ENDDO
ENDIF
ENDDO !k
ENDDO !j
ENDDO !i
ENDIF ! SAT_FAR_FIELD
IF(patch(patch_no)%bc .eq. SAT_NOSLIP_WALL)THEN
DO i = i_start, i_end
DO j = j_start, j_end
DO k = 1, 1
IF(abs(patch(patch_no)%bc_dir) .eq. 1)THEN
pv_targetI(i,j,k,1) = pv(i,j,k,1)
pv_targetI(i,j,k,2) = pv(i,j,k,2)
pv_targetI(i,j,k,3) = pv(i,j,k,3)
pv_targetI(i,j,k,4) = 0.0D0
pv_targetI(i,j,k,5) = pv(i,j,k,5)
CALL eigen_matrices_in_z_direction
CALL compute_SAT_RHS
DO eqn = 1, neqns
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) + sigma_1*dxidz(i,j,k)*one_by_h_44*rhs_SAT(eqn)
ENDDO
pv_targetV(i,j,k,1) = pv(i,j,k,1)
pv_targetV(i,j,k,2:4) = 0.0D0
pv_targetV(i,j,k,5) = pv_target(i,j,k,5)
DO eqn = 1, neqns
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) + sigma_2*dxidz(i,j,k)*one_by_h_44*(pv(i,j,k,eqn)-pv_targetV(i,j,k,eqn))
ENDDO
ELSEIF(abs(patch(patch_no)%bc_dir) .eq. 2)THEN
pv_targetI(i,j,k,1) = pv(i,j,k,1)
pv_targetI(i,j,k,2) = 0.0D0
pv_targetI(i,j,k,3) = pv(i,j,k,3)
pv_targetI(i,j,k,4) = pv(i,j,k,4)
pv_targetI(i,j,k,5) = pv(i,j,k,5)
CALL eigen_matrices_in_r_direction
CALL compute_SAT_RHS
DO eqn = 1, neqns
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) + sigma_1*detadr(i,j,k)*one_by_h_44*rhs_SAT(eqn)
ENDDO
pv_targetV(i,j,k,1) = pv(i,j,k,1)
pv_targetV(i,j,k,2:4) = 0.0D0
pv_targetV(i,j,k,5) = pv_target(i,j,k,5)
DO eqn = 1, neqns
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) + sigma_2*detadr(i,j,k)*one_by_h_44*(pv(i,j,k,eqn)-pv_targetV(i,j,k,eqn))
ENDDO
ENDIF
ENDDO !k
ENDDO !j
ENDDO !i
ENDIF ! SAT_NOSLIP_WALL
IF(patch(patch_no)%bc .eq. NSCBC_NONREFLECTING)THEN
DO i = i_start, i_end
DO j = j_start, j_end
DO k = 1, 1
IF(abs(patch(patch_no)%bc_dir) .eq. 1)THEN
CALL eigen_matrices_in_z_direction
CALL ComputeNSCBCRHS
ENDIF
DO eqn = 1, neqns
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) - rhs_NSCBC(eqn)
ENDDO
ENDDO !k
ENDDO !j
ENDDO !i
ENDIF ! SAT_FAR_FIELD
ENDDO ! patch
END SUBROUTINE BoundaryConditions
SUBROUTINE eigen_matrices_in_z_direction
USE module_variables
IMPLICIT NONE
rho = rhovec(i,j,k)
Vz = Vzvec(i,j,k)
T = Tvec(i,j,k)
lam(1,1) = Vz
lam(2,2) = Vz
lam(3,3) = Vz
lam(4,4) = (Vz-DSQRT(T))
lam(5,5) = (Vz+DSQRT(T))
T_mat(1,1) = -1.0D0*rho/T
T_mat(1,2) = 0.0D0
T_mat(1,3) = 0.0D0
T_mat(1,4) = rho/((gam-1.0D0)*T)
T_mat(1,5) = rho/((gam-1.0D0)*T)
T_mat(2,1) = 0.0D0
T_mat(2,2) = 0.0D0
T_mat(2,3) = 1.0D0
T_mat(2,4) = 0.0D0
T_mat(2,5) = 0.0D0
T_mat(3,1) = 0.0D0
T_mat(3,2) = 1.0D0
T_mat(3,3) = 0.0D0
T_mat(3,4) = 0.0D0
T_mat(3,5) = 0.0D0
T_mat(4,1) = 0.0D0
T_mat(4,2) = 0.0D0
T_mat(4,3) = 0.0D0
T_mat(4,4) = -1.0D0/((gam-1.0D0)*DSQRT(T))
T_mat(4,5) = 1.0D0/((gam-1.0D0)*DSQRT(T))
T_mat(5,1) = 1.0D0
T_mat(5,2) = 0.0D0
T_mat(5,3) = 0.0D0
T_mat(5,4) = 1.0D0
T_mat(5,5) = 1.0D0
T_mat_inv(1,1) = -1.0D0*(gam-1.0D0)*T/(gam*rho)
T_mat_inv(1,2) = 0.0D0
T_mat_inv(1,3) = 0.0D0
T_mat_inv(1,4) = 0.0D0
T_mat_inv(1,5) = 1.0D0/gam
T_mat_inv(2,1) = 0.0D0
T_mat_inv(2,2) = 0.0D0
T_mat_inv(2,3) = 1.0D0
T_mat_inv(2,4) = 0.0D0
T_mat_inv(2,5) = 0.0D0
T_mat_inv(3,1) = 0.0D0
T_mat_inv(3,2) = 1.0D0
T_mat_inv(3,3) = 0.0D0
T_mat_inv(3,4) = 0.0D0
T_mat_inv(3,5) = 0.0D0
T_mat_inv(4,1) = (gam-1.0D0)*T/(2.0D0*gam*rho)
T_mat_inv(4,2) = 0.0D0
T_mat_inv(4,3) = 0.0D0
T_mat_inv(4,4) = -1.0D0*(gam-1.0D0)*DSQRT(T)/2.0D0
T_mat_inv(4,5) = (gam-1.0D0)/(2.0D0*gam)
T_mat_inv(5,1) = (gam-1.0D0)*T/(2.0D0*gam*rho)
T_mat_inv(5,2) = 0.0D0
T_mat_inv(5,3) = 0.0D0
T_mat_inv(5,4) = (gam-1.0D0)*DSQRT(T)/2.0D0
T_mat_inv(5,5) = (gam-1.0D0)/(2.0D0*gam)
PRINT*, MATMUL(MATMUL(T_mat,lam),T_mat_inv)
PRINT*, "rho ......", rho, T
STOP
END SUBROUTINE eigen_matrices_in_z_direction
SUBROUTINE eigen_matrices_in_r_direction
USE module_variables
IMPLICIT NONE
rho = rhovec(i,j,k)
Vr = Vrvec(i,j,k)
T = Tvec(i,j,k)
lam(1,1) = Vr
lam(2,2) = Vr
lam(3,3) = Vr
lam(4,4) = (Vr-DSQRT(T))
lam(5,5) = (Vr+DSQRT(T))
T_mat(1,1) = -1.0D0*rho/T
T_mat(1,2) = 0.0D0
T_mat(1,3) = 0.0D0
T_mat(1,4) = rho/((gam-1.0D0)*T)
T_mat(1,5) = rho/((gam-1.0D0)*T)
T_mat(2,1) = 0.0D0
T_mat(2,2) = 0.0D0
T_mat(2,3) = 0.0D0
T_mat(2,4) = -1.0D0/((gam-1.0D0)*DSQRT(T))
T_mat(2,5) = 1.0D0/((gam-1.0D0)*DSQRT(T))
T_mat(3,1) = 0.0D0
T_mat(3,2) = 0.0D0
T_mat(3,3) = 1.0D0
T_mat(3,4) = 0.0D0
T_mat(3,5) = 0.0D0
T_mat(4,1) = 0.0D0
T_mat(4,2) = 1.0D0
T_mat(4,3) = 0.0D0
T_mat(4,4) = 0.0D0
T_mat(4,5) = 0.0D0
T_mat(5,1) = 1.0D0
T_mat(5,2) = 0.0D0
T_mat(5,3) = 0.0D0
T_mat(5,4) = 1.0D0
T_mat(5,5) = 1.0D0
T_mat_inv(1,1) = -1.0D0*(gam-1.0D0)*T/(gam*rho)
T_mat_inv(1,2) = 0.0D0
T_mat_inv(1,3) = 0.0D0
T_mat_inv(1,4) = 0.0D0
T_mat_inv(1,5) = 1.0D0/gam
T_mat_inv(2,1) = 0.0D0
T_mat_inv(2,2) = 0.0D0
T_mat_inv(2,3) = 0.0D0
T_mat_inv(2,4) = 1.0D0
T_mat_inv(2,5) = 0.0D0
T_mat_inv(3,1) = 0.0D0
T_mat_inv(3,2) = 0.0D0
T_mat_inv(3,3) = 1.0D0
T_mat_inv(3,4) = 0.0D0
T_mat_inv(3,5) = 0.0D0
T_mat_inv(4,1) = (gam-1.0D0)*T/(2.0D0*gam*rho)
T_mat_inv(4,2) = -1.0D0*(gam-1.0D0)*DSQRT(T)/2.0D0
T_mat_inv(4,3) = 0.0D0
T_mat_inv(4,4) = 0.0D0
T_mat_inv(4,5) = (gam-1.0D0)/(2.0D0*gam)
T_mat_inv(5,1) = (gam-1.0D0)*T/(2.0D0*gam*rho)
T_mat_inv(5,2) = (gam-1.0D0)*DSQRT(T)/2.0D0
T_mat_inv(5,3) = 0.0D0
T_mat_inv(5,4) = 0.0D0
T_mat_inv(5,5) = (gam-1.0D0)/(2.0D0*gam)
END SUBROUTINE eigen_matrices_in_r_direction
SUBROUTINE compute_SAT_RHS
USE module_variables
IF(patch(patch_no)%bc_dir .gt. 0)THEN
lam = (abs(lam)+lam)/2.0D0
ELSEIF(patch(patch_no)%bc_dir .lt. 0)THEN
lam = (abs(lam)-lam)/2.0D0
ENDIF
IF(patch(patch_no)%bc .eq. SAT_FARFIELD)THEN
DO counter = 1, neqns
waveamp(counter) = pv(i,j,k,counter) - pv_target(i,j,k,counter)
ENDDO
ENDIF
IF(patch(patch_no)%bc .eq. SAT_NOSLIP_WALL)THEN
DO counter = 1, neqns
waveamp(counter) = pv(i,j,k,counter) - pv_targetI(i,j,k,counter)
ENDDO
ENDIF
waveamp = MATMUL(T_mat_inv,waveamp)
rhs_SAT = MATMUL(MATMUL(T_mat,lam),waveamp)
END SUBROUTINE compute_SAT_RHS
SUBROUTINE ComputeNSCBCRHS
USE module_variables
IMPLICIT NONE
drhodz = drhovecdz(i,j,k)
dVrdz = dVrvecdz(i,j,k)
dVtdz = dVtvecdz(i,j,k)
dVzdz = dVzvecdz(i,j,k)
dTdz = dTvecdz(i,j,k)
deriv_vector(1) = drhodz
deriv_vector(2) = dVrdz
deriv_vector(3) = dVtdz
deriv_vector(4) = dVzdz
deriv_vector(5) = dTdz
waveamp = MATMUL(T_mat_inv,deriv_vector)
IF (patch(patch_no)%bc_dir .gt. 0)THEN
DO counter = 1, neqns
IF(lam(counter,counter) .gt. 0.0D0)THEN
waveamp(counter) = 0.0D0
ENDIF
ENDDO
ELSEIF(patch(patch_no)%bc_dir .lt. 0)THEN
DO counter = 1, neqns
IF(lam(counter,counter) .lt. 0.0D0)THEN
waveamp(counter) = 0.0D0
ENDIF
ENDDO
ENDIF
rhs_NSCBC = MATMUL(MATMUL(T_mat,lam),waveamp)
END SUBROUTINE ComputeNSCBCRHS
SUBROUTINE sponge_bcs
USE module_variables
IMPLICIT NONE
! Top sponge
DO eqn = 1, neqns
DO i = 1, Nz
DO j = Nr+sponge_start_top, Nr
DO k = 1, 1
zeta = ( rvec(i,j,k) - rvec(i,Nr+sponge_start_top,k) )/( rvec(i,Nr,k) - rvec(i,Nr+sponge_start_top,k) )
rhs(i,j,k,eqn) = rhs(i,j,k,eqn) - A_sponge*zeta**n_sponge*(pv(i,j,k,eqn) - pv_target(i,j,k,eqn) )
ENDDO
ENDDO
ENDDO
ENDDO
! Inflow sponge
DO eqn = 1, neqns
DO i = 1, sponge_end_inflow
DO j = 1, Nr
DO k = 1, 1
zeta = ( zvec(sponge_end_inflow,j,k) - zvec(i,j,k) )/( zvec(sponge_end_inflow,j,k) - zvec(1,j,k) )
!rhs(i,j,k,eqn) = rhs(i,j,k,eqn) - A_sponge*zeta**n_sponge*(pv(i,j,k,eqn) - pv_target(i,j,k,eqn) )
ENDDO
ENDDO
ENDDO
ENDDO
! Outflow sponge
DO eqn = 1, neqns
DO i = Nz+sponge_start_outflow, Nz
DO j = 1, Nr
DO k = 1, 1
zeta = ( zvec(i,j,k) - zvec(Nz+sponge_start_outflow,j,k) )/( zvec(Nz,j,k) - zvec(Nz+sponge_start_outflow,j,k) )
!rhs(i,j,k,eqn) = rhs(i,j,k,eqn) - A_sponge*zeta**n_sponge*(pv(i,j,k,eqn) - pv_target(i,j,k,eqn) )
ENDDO
ENDDO
ENDDO
ENDDO
END SUBROUTINE sponge_bcs
END MODULE ModBC