-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModShockCapturing.f90
executable file
·260 lines (181 loc) · 6.62 KB
/
ModShockCapturing.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
MODULE ModShockCapturing
CONTAINS
SUBROUTINE ComputeArtTransCoeffs
USE ModuleVariables
USE ModInputOutput
USE ModCommunicate
USE ModDecomp
USE ModDeriv
USE ModTGFilter
IMPLICIT NONE
! Compute magnitude of the Strain-Rate tensor and dilatation
CALL ComputeDilatation
CALL ComputeMgnStrRate
! Compute second derivative of MgnStrRate d2Sdxi2
CALL ProcessorCommunication(MgnStrRate)
CALL ProcessorCommunication(Tvec)
CALL ProcessorCommunication(dilvec)
CALL Compute2ndDerivativeComputational(MgnStrRate,1,d2MgnStrRatedxi2)
CALL Compute2ndDerivativeComputational(Tvec,1,d2Tvecdxi2)
CALL Compute2ndDerivativeComputational(dilvec,1,d2dilvecdxi2)
CALL Compute2ndDerivativeComputational(MgnStrRate,2,d2MgnStrRatedeta2)
CALL Compute2ndDerivativeComputational(Tvec,2,d2Tvecdeta2)
CALL Compute2ndDerivativeComputational(dilvec,2,d2dilvecdeta2)
! Compute fourth derivatives of MgnStrRate and Temperature
CALL ProcessorCommunication(d2MgnStrRatedxi2)
CALL ProcessorCommunication(d2Tvecdxi2)
CALL ProcessorCommunication(d2dilvecdxi2)
CALL ProcessorCommunication(d2MgnStrRatedeta2)
CALL ProcessorCommunication(d2Tvecdeta2)
CALL ProcessorCommunication(d2dilvecdeta2)
CALL Compute2ndDerivativeComputational(d2MgnStrRatedxi2,1,d4MgnStrRatedxi4)
CALL Compute2ndDerivativeComputational(d2Tvecdxi2,1,d4Tvecdxi4)
CALL Compute2ndDerivativeComputational(d2dilvecdxi2,1,d4dilvecdxi4)
CALL Compute2ndDerivativeComputational(d2MgnStrRatedeta2,2,d4MgnStrRatedeta4)
CALL Compute2ndDerivativeComputational(d2Tvecdeta2,2,d4Tvecdeta4)
CALL Compute2ndDerivativeComputational(d2dilvecdeta2,2,d4dilvecdeta4)
CALL ComputeTobeFilteredQuantities
! Perform the filtering and multiply by coefficients C_mu, C_beta or
! C_kappa and (Re or RePr) to get the artificial transport coefficients
CALL ProcessorCommunication(mustarQuantity)
CALL ProcessorCommunication(betastarQuantity)
CALL ProcessorCommunication(kappastarQuantity)
CALL PerformTGfilter(mustarQuantity,1,mustarQuantity)
CALL ProcessorCommunication(mustarQuantity)
CALL PerformTGfilter(mustarQuantity,2,mustar)
mustar = C_mu*Re*mustar
CALL PerformTGfilter(betastarQuantity,1,betastarQuantity)
CALL ProcessorCommunication(betastarQuantity)
CALL PerformTGfilter(betastarQuantity,2,betastar)
betastar = C_beta*Re*betastar
CALL PerformTGfilter(kappastarQuantity,1,kappastarQuantity)
CALL ProcessorCommunication(kappastarQuantity)
CALL PerformTGfilter(kappastarQuantity,2,kappastar)
kappastar = C_kappa*Re*Pr*kappastar
DO i = 1, Nz
DO j = 1, Nr
DO k = 1, 1
tmp = ( 1.0D0+tanh( 5.0D0*(zvec(i,j,k)-10.0D0) ) )/2.0D0
mustar(i,j,k) = mustar(i,j,k)*tmp
betastar(i,j,k) = betastar(i,j,k)*tmp
kappastar(i,j,k) = kappastar(i,j,k)*tmp
ENDDO
ENDDO
ENDDO
CALL UpdateTransportCoeffs
!IF(mod(iteration,noutput) .eq. 0 .and. rkStep .eq. 1)THEN
!CALL WriteVariableOutput(mustar,betastar,kappastar,muvec,muvec)
!CALL MPI_Barrier(MPI_COMM_WORLD,ierr)
!ENDIF
!CALL StopTheCode
! RHS to be called after this
END SUBROUTINE ComputeArtTransCoeffs
SUBROUTINE ComputeDilatation
USE ModuleVariables
IMPLICIT NONE
DO i =1, Nz
DO j = 1, Nr
DO k = 1, 1
IF(j .eq. 1)THEN
dilvec(i,j,k) = 2.0D0*dVrvecdr(i,j,k) + dVzvecdz(i,j,k)
ELSE
dilvec(i,j,k) = dVrvecdr(i,j,k) + Vrvec(i,j,k)/rvec(i,j,k) + dVzvecdz(i,j,k)
ENDIF
ENDDO
ENDDO
ENDDO
END SUBROUTINE ComputeDilatation
SUBROUTINE ComputeMgnStrRate
USE ModuleVariables
IMPLICIT NONE
DO i = 1, Nz
DO j = 1, Nr
DO k = 1, 1
S11 = dVrvecdr(i,j,k) - (1.0D0/3.0D0)*dilvec(i,j,k)
S12 = 0.0D0
S13 = 0.5D0*(dVrvecdz(i,j,k) + dVzvecdr(i,j,k) )
S21 = 0.0D0
S23 = 0.0D0
S31 = S13
S32 = 0.0D0
S33 = dVzvecdz(i,j,k) - (1.0D0/3.0D0)*dilvec(i,j,k)
IF(j .eq. 1)THEN
S22 = dVrvecdr(i,j,k) - (1.0D0/3.0D0)*dilvec(i,j,k)
ELSE
S22 = Vrvec(i,j,k)/rvec(i,j,k) - (1.0D0/3.0D0)*dilvec(i,j,k)
ENDIF
MgnStrRate(i,j,k) = DSQRT(S11**2+S12**2+S13**2+S21**2+S22**2+S23**2+S31**2+S32**2+S33**2)
ENDDO
ENDDO
ENDDO
END SUBROUTINE ComputeMgnStrRate
SUBROUTINE ComputeTobeFilteredQuantities
USE ModuleVariables
IMPLICIT NONE
DO i = 1, Nz
DO j = 1, Nr
DO k = 1, 1
IF(i .ge. 2 .and. i .le. Nz-1)THEN
deltaz = (zvec(i+1,j,k)-zvec(i-1,j,k))/2.0D0
ENDIF
IF(i .eq. 1)THEN
deltaz = zvec(2,j,k) - zvec(1,j,k)
ENDIF
IF(i .eq. Nz)THEN
deltaz = zvec(Nz,j,k) - zvec(Nz-1,j,k)
ENDIF
IF(j .ge. 2 .and. j .le. Nr-1)THEN
deltar = (rvec(i,j+1,k)-rvec(i,j-1,k))/2.0D0
ENDIF
IF(j .eq. 1)THEN
deltar = rvec(i,2,k) - rvec(i,1,k)
ENDIF
IF(j .eq. Nr)THEN
deltar = rvec(i,Nr,k) - rvec(i,Nr-1,k)
ENDIF
IF(j .eq. 1)THEN
dilatation = 2.0D0*dVrvecdr(i,j,k) + dVzvecdz(i,j,k)
ELSE
dilatation = dVrvecdr(i,j,k) + Vrvec(i,j,k)/rvec(i,j,k) + dVzvecdz(i,j,k)
ENDIF
vorticity = ABS( dVrvecdz(i,j,k) - dVzvecdr(i,j,k) )
minus_dilatation = -1.0D0*dilatation
CALL Heaviside(minus_dilatation,H_of_minus_dilatation)
f_sw = H_of_minus_dilatation*dilatation**2/(dilatation**2+vorticity**2+1e-15)
mustarQuantity(i,j,k) = rhovec(i,j,k)*ABS( ( d4MgnStrRatedxi4(i,j,k)*deltaz**2 + &
d4MgnStrRatedeta4(i,j,k)*deltar**2) )
!betastarQuantity(i,j,k) = rhovec(i,j,k)*f_sw*ABS( (d4MgnStrRatedxi4(i,j,k)*deltaz**2 + &
! d4MgnStrRatedeta4(i,j,k)*deltar**2) )
betastarQuantity(i,j,k) = rhovec(i,j,k)*f_sw*ABS((d4dilvecdxi4(i,j,k)*deltaz**2 + &
d4dilvecdeta4(i,j,k)*deltar**2) )
kappastarQuantity(i,j,k) = rhovec(i,j,k)/(gam*DSQRT(Tvec(i,j,k)))*ABS( (d4Tvecdxi4(i,j,k)*deltaz + &
d4Tvecdeta4(i,j,k)*deltar) )
ENDDO
ENDDO
ENDDO
END SUBROUTINE ComputeTobeFilteredQuantities
SUBROUTINE Heaviside(tmpin,tmpout)
USE ModuleVariables
IMPLICIT NONE
REAL(KIND=8) :: tmpin, tmpout
IF(tmpin .lt. 0.0D0)THEN
tmpout = 0.0D0
ELSE
tmpout = 1.0D0
ENDIF
END SUBROUTINE Heaviside
SUBROUTINE UpdateTransportCoeffs
USE ModuleVariables
IMPLICIT NONE
DO i = 1, Nz
DO j = 1, Nr
DO k = 1, 1
muvec(i,j,k) = muvec(i,j,k) + mustar(i,j,k)
betavec(i,j,k) = betavec(i,j,k) + betastar(i,j,k)
lambdavec(i,j,k) = betavec(i,j,k) - (2.0D0/3.0D0)*muvec(i,j,k)
kappavec(i,j,k) = kappavec(i,j,k) + kappastar(i,j,k)
ENDDO
ENDDO
ENDDO
END SUBROUTINE UpdateTransportCoeffs
END MODULE ModShockCapturing