forked from mdelorme/fv2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRiemannSolvers.h
126 lines (102 loc) · 2.85 KB
/
RiemannSolvers.h
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
#pragma once
namespace fv2d {
KOKKOS_INLINE_FUNCTION
void hll(State &qL, State &qR, State& flux, real_t &pout, const Params ¶ms) {
const real_t aL = speedOfSound(qL, params);
const real_t aR = speedOfSound(qR, params);
// Davis' estimates for the signal speed
const real_t sminL = qL[IU] - aL;
const real_t smaxL = qL[IU] + aL;
const real_t sminR = qR[IU] - aR;
const real_t smaxR = qR[IU] + aR;
const real_t SL = fmin(sminL, sminR);
const real_t SR = fmax(smaxL, smaxR);
auto computeFlux = [&](State &q, const Params ¶ms) {
const real_t Ek = 0.5 * q[IR] * (q[IU] * q[IU] + q[IV] * q[IV]);
const real_t E = (q[IP] / (params.gamma0-1.0) + Ek);
State fout {
q[IR]*q[IU],
q[IR]*q[IU]*q[IU] + q[IP],
q[IR]*q[IU]*q[IV],
(q[IP] + E) * q[IU]
};
return fout;
};
State FL = computeFlux(qL, params);
State FR = computeFlux(qR, params);
if (SL >= 0.0) {
flux = FL;
pout = qL[IP];
}
else if (SR <= 0.0) {
flux = FR;
pout = qR[IP];
}
else {
State uL = primToCons(qL, params);
State uR = primToCons(qR, params);
pout = 0.5 * (qL[IP] + qR[IP]);
flux = (SR*FL - SL*FR + SL*SR*(uR-uL)) / (SR-SL);
}
}
KOKKOS_INLINE_FUNCTION
void hllc(State &qL, State &qR, State &flux, real_t &pout, const Params ¶ms) {
const real_t rL = qL[IR];
const real_t uL = qL[IU];
const real_t vL = qL[IV];
const real_t pL = qL[IP];
const real_t rR = qR[IR];
const real_t uR = qR[IU];
const real_t vR = qR[IV];
const real_t pR = qR[IP];
const real_t entho = 1.0 / (params.gamma0-1.0);
const real_t ekL = 0.5 * rL * (uL * uL + vL * vL);
const real_t EL = ekL + pL * entho;
const real_t ekR = 0.5 * rR * (uR * uR + vR * vR);
const real_t ER = ekR + pR * entho;
const real_t cfastL = speedOfSound(qL, params);
const real_t cfastR = speedOfSound(qR, params);
const real_t SL = fmin(uL, uR) - fmax(cfastL, cfastR);
const real_t SR = fmax(uL, uR) + fmax(cfastL, cfastR);
const real_t rcL = rL*(uL-SL);
const real_t rcR = rR*(SR-uR);
const real_t uS = (rcR*uR + rcL*uL + (pL-pR))/(rcR+rcL);
const real_t pS = (rcR*pL+rcL*pR+rcL*rcR*(uL-uR))/(rcR+rcL);
const real_t rSL = rL*(SL-uL)/(SL-uS);
const real_t ESL = ((SL-uL)*EL-pL*uL+pS*uS)/(SL-uS);
const real_t rSR = rR*(SR-uR)/(SR-uS);
const real_t ESR = ((SR-uR)*ER-pR*uR+pS*uS)/(SR-uS);
State st;
real_t E;
if (SL > 0.0) {
st = qL;
E = EL;
pout = pL;
}
else if (uS > 0.0) {
st[IR] = rSL;
st[IU] = uS;
st[IV] = qL[IV];
st[IP] = pS;
E = ESL;
pout = pS;
}
else if (SR > 0.0) {
st[IR] = rSR;
st[IU] = uS;
st[IV] = qR[IV];
st[IP] = pS;
E = ESR;
pout = pS;
}
else {
st = qR;
E = ER;
pout = pR;
}
flux[IR] = st[IR]*st[IU];
flux[IU] = st[IR]*st[IU]*st[IU]+st[IP];
flux[IV] = flux[IR]*st[IV];
flux[IE] = (E + st[IP])*st[IU];
}
}