-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtimeStep.f90
162 lines (143 loc) · 4.82 KB
/
timeStep.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
!> @file timeStep.f90
!!
!! Computation of the time step.
!
! *****************************************************************************
!
! (c) J. Blazek, CFD Consulting & Analysis, www.cfd-ca.de
! Created February 25, 2014
! Last modification: June 3, 2014
!
! *****************************************************************************
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License
! as published by the Free Software Foundation; either version 2
! of the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! *****************************************************************************
!> Computes maximum stable time step.
!!
subroutine TimeStep
use ModDataTypes
use ModGeometry
use ModNumerics
use ModPhysics
use ModInterfaces, only : CompTheta
implicit none
! local variables
integer :: i
real(rtype) :: sx, sy, ds, rrho, u, v, vc, cs, rhop, rhoT, hT, q2, &
theta, ra1g, a1, a4, a5, fmue, f1, f2, fac, dtv, cfac, &
lambdac, lambdav, tsmin
! *****************************************************************************
if (kequs == "E") then
! - preconditioned Euler equations
if (kprecond == "Y") then
do i=1,nndint
sx = sproj(1,i)
sy = sproj(2,i)
ds = sx + sy
u = Abs(cv(2,i)/cv(1,i))
v = Abs(cv(3,i)/cv(1,i))
rhop = cv(1,i)/dv(1,i)
rhoT = -cv(1,i)/dv(2,i)
hT = dv(5,i)
q2 = u*u + v*v
theta = CompTheta( dv(4,i),dv(3,i),q2 )
a1 = cv(1,i)*rhop*hT + rhoT
ra1g = 1.D0/(cv(1,i)*theta*hT+rhoT)
a4 = a1*ra1g
a5 = cv(1,i)*hT*ra1g
vc = (sx*u+sy*v)/ds
cs = Sqrt((vc*vc)*((a4-1.D0)*(a4-1.D0))+4.D0*a5)
tstep(i) = (2.D0*vol(i))/((vc*(a4+1.D0)+cs)*ds)
enddo
! - Euler equations
else
do i=1,nndint
sx = sproj(1,i)
sy = sproj(2,i)
u = Abs(cv(2,i)/cv(1,i))
v = Abs(cv(3,i)/cv(1,i))
vc = sx*u + sy*v
cs = dv(3,i)*(sx+sy)
tstep(i) = vol(i)/(vc+cs)
enddo
endif
else ! kequs == "N"
if (iorder > 1) then
cfac = 1.D0
else
cfac = 2.D0
endif
! - preconditioned Navier-Stokes equations (laminar)
if (kprecond == "Y") then
do i=1,nndint
sx = sproj(1,i)
sy = sproj(2,i)
ds = sx + sy
rrho = 1.D0/cv(1,i)
u = Abs(cv(2,i)*rrho)
v = Abs(cv(3,i)*rrho)
rhop = cv(1,i)/dv(1,i)
rhoT = -cv(1,i)/dv(2,i)
hT = dv(5,i)
q2 = u*u + v*v
theta = CompTheta( dv(4,i),dv(3,i),q2 )
a1 = cv(1,i)*rhop*hT + rhoT
ra1g = 1.D0/(cv(1,i)*theta*hT+rhoT)
a4 = a1*ra1g
a5 = cv(1,i)*hT*ra1g
vc = (sx*u+sy*v)/ds
cs = Sqrt((vc*vc)*((a4-1.D0)*(a4-1.D0))+4.D0*a5)
fmue = dv(6,i)/prlam
f1 = (4.D0*rrho)/3.D0
f2 = dv(4,i)*rrho
fac = Max(f1,f2)
dtv = (fac*fmue)/vol(i)
lambdac = 0.5D0*((a4+1.D0)*vc+cs)*ds
lambdav = dtv*(sx*sx+sy*sy)
tstep(i) = vol(i)/(lambdac+cfac*lambdav)
enddo
! - Navier-Stokes equations (laminar)
else
do i=1,nndint
sx = sproj(1,i)
sy = sproj(2,i)
rrho = 1.D0/cv(1,i)
u = Abs(cv(2,i)*rrho)
v = Abs(cv(3,i)*rrho)
fmue = dv(6,i)/prlam
f1 = (4.D0*rrho)/3.D0
f2 = dv(4,i)*rrho
fac = Max(f1,f2)
dtv = (fac*fmue)/vol(i)
vc = sx*u + sy*v
cs = dv(3,i)*(sx+sy)
lambdac = vc + cs
lambdav = dtv*(sx*sx+sy*sy)
tstep(i) = vol(i)/(lambdac+cfac*lambdav)
enddo
endif ! kprecond
endif ! kequs
! in case of global time-stepping - find min. time step in domain -------------
if (ktimst == "G") then
tsmin = 1.D+32
do i=1,nndint
tsmin = Min(tsmin,tstep(i))
enddo
do i=1,nndint
tstep(i) = tsmin
enddo
endif
end subroutine TimeStep