-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhllc.F90
151 lines (125 loc) · 4.65 KB
/
hllc.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
subroutine hllc(vL,vR,Flux,dir)
#include "definition.h"
use grid_data
use primconsflux, only : prim2flux,prim2cons,cons2flux
implicit none
integer, intent(IN) :: dir
real, dimension(NUMB_VAR), intent(INOUT) :: vL,vR !prim vars
real, dimension(NSYS_VAR), intent(OUT):: Flux
real, dimension(NSYS_VAR) :: FL,FR,uL,uR,Uhll,UstarL,UstarR
real :: sL,sR,aL,aR,uStar,pStar,pTot
real :: numerL, denomL, numerR, denomR
real :: dStarL, dStarR
integer :: VELC_VAR
VELC_VAR = 1
if (.false.) then
uL = vL(DENS_VAR:ENER_VAR)
uR = vR(DENS_VAR:ENER_VAR)
!!$ call cons2flux(uL,FL,dir,vL)
!!$ call cons2flux(uR,FR,dir,vR)
else
call prim2flux(vL,FL,dir)
call prim2flux(vR,FR,dir)
call prim2cons(vL,uL)
call prim2cons(vR,uR)
end if
if (dir == XDIM) then
VELC_VAR = VELX_VAR
elseif (dir == YDIM) then
VELC_VAR = VELY_VAR
elseif (dir == ZDIM) then
VELC_VAR = VELZ_VAR
end if
! left and right sound speed a
aL = sqrt(vL(GAMC_VAR)*vL(PRES_VAR)/vL(DENS_VAR))
aR = sqrt(vR(GAMC_VAR)*vR(PRES_VAR)/vR(DENS_VAR))
! fastest left and right going velocities
sL = min(vL(VELC_VAR) - aL,vR(VELC_VAR) - aR)
sR = max(vL(VELC_VAR) + aL,vR(VELC_VAR) + aR)
! Get HLL states for later use
if (sL > 0.) then
Uhll(DENS_VAR:ENER_VAR) = uL(DENS_VAR:ENER_VAR)
elseif ((sL <= 0.) .and. (sR >= 0.)) then
Uhll(DENS_VAR:ENER_VAR) = &
( sR*uR(DENS_VAR:ENER_VAR) &
-sL*uL(DENS_VAR:ENER_VAR) &
- FR(DENS_VAR:ENER_VAR) &
+ FL(DENS_VAR:ENER_VAR)&
)/(sR - sL)
else
Uhll(DENS_VAR:ENER_VAR) = uR(DENS_VAR:ENER_VAR)
endif
! Get uStar
uStar = vR(DENS_VAR)*vR(VELC_VAR)*(sR-vR(VELC_VAR)) &
-vL(DENS_VAR)*vL(VELC_VAR)*(sL-vL(VELC_VAR)) &
+vL(PRES_VAR)-vR(PRES_VAR)
uStar = uStar/( vR(DENS_VAR)*(sR-vR(VELC_VAR)) &
-vL(DENS_VAR)*(sL-vL(VELC_VAR)))
! Convenient parameters
numerL = sL-vL(VELC_VAR)
denomL = sL-uStar
numerR = sR-vR(VELC_VAR)
denomR = sR-uStar
! Get pStar
pStar = vL(DENS_VAR)*numerL*(uStar-vL(VELC_VAR)) + vL(PRES_VAR)
! density
dStarL = uL(DENS_VAR)*numerL/denomL
dStarR = uR(DENS_VAR)*numerR/denomR
select case (dir)
case(XDIM)
! left and right star regions
UstarL(DENS_VAR) = dStarL
UstarL(MOMX_VAR) = dStarL*uStar
UstarL(MOMY_VAR) = uL(MOMY_VAR)*numerL/denomL
UstarL(MOMZ_VAR) = uL(MOMZ_VAR)*numerL/denomL
UstarL(ENER_VAR) = uL(ENER_VAR)*numerL/denomL+&
(pStar*uStar - vL(PRES_VAR)*vL(VELC_VAR))/denomL
UstarR(DENS_VAR) = dStarR
UstarR(MOMX_VAR) = dStarR*uStar
UstarR(MOMY_VAR) = uR(MOMY_VAR)*numerR/denomR
UstarR(MOMZ_VAR) = uR(MOMZ_VAR)*numerR/denomR
UstarR(ENER_VAR) = uR(ENER_VAR)*numerR/denomR+&
(pStar*uStar - vR(PRES_VAR)*vR(VELC_VAR))/denomR
case(YDIM)
! left and right star regions
UstarL(DENS_VAR) = dStarL
UstarL(MOMY_VAR) = dStarL*uStar
UstarL(MOMX_VAR) = uL(MOMX_VAR)*numerL/denomL
UstarL(MOMZ_VAR) = uL(MOMZ_VAR)*numerL/denomL
UstarL(ENER_VAR) = uL(ENER_VAR)*numerL/denomL+&
(pStar*uStar - vL(PRES_VAR)*vL(VELC_VAR))/denomL
UstarR(DENS_VAR) = dStarR
UstarR(MOMY_VAR) = dStarR*uStar
UstarR(MOMX_VAR) = uR(MOMX_VAR)*numerR/denomR
UstarR(MOMZ_VAR) = uR(MOMZ_VAR)*numerR/denomR
UstarR(ENER_VAR) = uR(ENER_VAR)*numerR/denomR+&
(pStar*uStar - vR(PRES_VAR)*vR(VELC_VAR))/denomR
case(ZDIM)
! left and right star regions
UstarL(DENS_VAR) = dStarL
UstarL(MOMZ_VAR) = dStarL*uStar
UstarL(MOMX_VAR) = uL(MOMX_VAR)*numerL/denomL
UstarL(MOMY_VAR) = uL(MOMY_VAR)*numerL/denomL
UstarL(ENER_VAR) = uL(ENER_VAR)*numerL/denomL+&
(pStar*uStar - vL(PRES_VAR)*vL(VELC_VAR))/denomL
UstarR(DENS_VAR) = dStarR
UstarR(MOMZ_VAR) = dStarR*uStar
UstarR(MOMX_VAR) = uR(MOMX_VAR)*numerR/denomR
UstarR(MOMY_VAR) = uR(MOMY_VAR)*numerR/denomR
UstarR(ENER_VAR) = uR(ENER_VAR)*numerR/denomR+&
(pStar*uStar - vR(PRES_VAR)*vR(VELC_VAR))/denomR
end select
! numerical flux
if (sL >= 0.) then
Flux(DENS_VAR:ENER_VAR) = FL(DENS_VAR:ENER_VAR)
elseif ( (sL < 0.) .and. (uStar >= 0.) ) then
Flux(DENS_VAR:ENER_VAR) = FL(DENS_VAR:ENER_VAR) &
+ sL*(UstarL(DENS_VAR:ENER_VAR) - uL(DENS_VAR:ENER_VAR))
elseif ( (uStar < 0.) .and. (sR >= 0.) ) then
Flux(DENS_VAR:ENER_VAR) = FR(DENS_VAR:ENER_VAR) &
+ sR*(UstarR(DENS_VAR:ENER_VAR) - uR(DENS_VAR:ENER_VAR))
else
Flux(DENS_VAR:ENER_VAR) = FR(DENS_VAR:ENER_VAR)
endif
return
end subroutine hllc