-
Notifications
You must be signed in to change notification settings - Fork 0
/
flux.m
49 lines (37 loc) · 1.28 KB
/
flux.m
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
function Fhat = flux(FL,FR,rhoL,rhouL,EL,rhoR,rhouR,ER,SR,SL)
global gamma type
UR = [rhoR;rhouR;ER]; UL = [rhoL;rhouL;EL];
switch type
case 1
%% L-F Flux
Fhat = 0.5*(FR + FL - max(abs(SR),abs(SL))*(UR - UL));
case 2
%% HLL Flux
if SL >= 0
Fhat = FL;
elseif SR <= 0
Fhat = FR;
else
Fhat = (SR*FL - SL*FR + SL*SR*(UR - UL))/(SR - SL);
end
case 3
%% HLLC Flux
if SL >= 0
Fhat = FL;
elseif SR <= 0
Fhat = FR;
else
uL = rhouL/rhoL;
uR = rhouR/rhoR;
pL = (gamma - 1)*(EL - 0.5*rhoL*uL^2);
pR = (gamma - 1)*(ER - 0.5*rhoR*uR^2);
Sstar = (pR - pL + rhoL*uL*(SL - uL) - rhoR*uR*(SR - uR))/(rhoL*(SL - uL) - rhoR*(SR - uR));
Dstar = [0;1;Sstar];
if SL < 0 && Sstar >= 0
Fhat = ( Sstar*(SL*UL - FL) + SL*(pL + rhoL*(SL - uL)*(Sstar - uL))*Dstar )/(SL - Sstar);
else
Fhat = ( Sstar*(SR*UR - FR) + SR*(pR + rhoR*(SR - uR)*(Sstar - uR))*Dstar )/(SR - Sstar);
end
end
end
end