 |
Peano
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
5 /*******************************
6 * Flux and source preparation *
7 ******************************/
9 double fluxRight[NumberOfUnknowns] {0.0};
10 double fluxLeft[NumberOfUnknowns] {0.0};
11 double sourceRight[NumberOfUnknowns] {0.0};
12 double sourceLeft[NumberOfUnknowns] {0.0};
14 flux(QL, x, h, t, dt, normal, fluxLeft);
15 flux(QR, x, h, t, dt, normal, fluxRight);
18 sourceLeft[Shortcuts::rhoU + 1] = -GRAVITY * QL[Shortcuts::rho];
19 sourceLeft[Shortcuts::rhoE] = -GRAVITY * QL[Shortcuts::rhoU + 1];
21 sourceRight[Shortcuts::rhoU + 1] = -GRAVITY * QR[Shortcuts::rho];
22 sourceRight[Shortcuts::rhoE] = -GRAVITY * QR[Shortcuts::rhoU + 1];
25 std::fill_n(FL, NumberOfUnknowns, 0.0);
26 std::fill_n(FR, NumberOfUnknowns, 0.0);
33 const auto rhoL = QL[Shortcuts::rho];
34 const auto sqrtRhoL = sqrt(rhoL);
35 const auto uL = QL[Shortcuts::rhoU + 0] / rhoL;
36 const auto vL = QL[Shortcuts::rhoU + 1] / rhoL;
38 const auto wL = QL[Shortcuts::rhoU + 2] / rhoL;
39 const auto uSqL = uL * uL + vL * vL + wL * wL;
41 const auto uSqL = uL * uL + vL * vL;
43 const auto EL = QL[Shortcuts::rhoE];
44 const auto pL = (GAMMA - 1.0) * (EL - 0.5 * rhoL * uSqL);
46 #if defined(GPUOffloadingOff)
47 assertion1(rhoL > 0, rhoL);
48 assertion1(EL > 0, EL);
49 assertion1(pL > 0, pL);
53 const auto rhoR = QR[Shortcuts::rho];
54 const auto sqrtRhoR = sqrt(rhoR);
55 const auto uR = QR[Shortcuts::rhoU + 0] / rhoR;
56 const auto vR = QR[Shortcuts::rhoU + 1] / rhoR;
58 const auto wR = QR[Shortcuts::rhoU + 2] / rhoR;
59 const auto uSqR = uR * uR + vR * vR + wR * wR;
61 const auto uSqR = uR * uR + vR * vR;
63 const auto ER = QR[Shortcuts::rhoE];
64 const auto pR = (GAMMA - 1.0) * (ER - 0.5 * rhoR * uSqR);
66 #if defined(GPUOffloadingOff)
67 assertion1(rhoR > 0, rhoR);
68 assertion1(ER > 0, ER);
69 assertion1(pR > 0, pR);
72 /********************************************
73 * Roe averages from LeVeque Chapter 15.3.4 *
74 *******************************************/
76 const auto iSumSqrtRho = 1.0 / (sqrtRhoL + sqrtRhoR);
78 const auto gammaAvg = GAMMA;
85 tarch::la::Vector<DIMENSIONS, double> roeAveragedVelocities(0.0);
86 roeAveragedVelocities(0) = (sqrtRhoL * uL + sqrtRhoR * uR) * iSumSqrtRho;
87 roeAveragedVelocities(1) = (sqrtRhoL * vL + sqrtRhoR * vR) * iSumSqrtRho;
89 roeAveragedVelocities(2) = (sqrtRhoL * wL + sqrtRhoR * wR) * iSumSqrtRho;
91 const auto qSquared = 0.5 * (roeAveragedVelocities * roeAveragedVelocities);
92 const auto speedOfSoundRoe = sqrt((gammaAvg - 1) * (HRoe - qSquared));
94 /*************************************************************
95 * Roe Eigenvalues from LeVeque Chapter 18.8, Equation 18.47 *
96 ************************************************************/
98 // in x-direction, these are uRoe - speedOfSoundRoe, DIMENSIONS x uRoe, and uRoe + speedOfSoundRoe
99 tarch::la::Vector<NumberOfUnknowns, double> roeEigenvalues(0.0);
101 // first eigenvalue is left uRoe - speedOfSoundRoe
102 roeEigenvalues(0) = roeAveragedVelocities(normal) - speedOfSoundRoe;
105 for (int eigenvalue = 1; eigenvalue <= DIMENSIONS; eigenvalue++) {
106 roeEigenvalues(eigenvalue) = roeAveragedVelocities(normal);
109 // last eigenvalue is right uRoe + speedOfSoundRoe
110 roeEigenvalues(DIMENSIONS + 1) = roeAveragedVelocities(normal) + speedOfSoundRoe;
112 /***********************************************
113 * Delta values from Bale et al. Equation 1.17 *
114 **********************************************/
116 tarch::la::Vector<NumberOfUnknowns, double> delta(0.0);
118 for (int unknown = 0; unknown < NumberOfUnknowns; ++unknown) {
119 delta(unknown) = fluxRight[unknown] - fluxLeft[unknown];
120 delta(unknown) -= 0.5 * h(normal) * (sourceLeft[unknown] + sourceRight[unknown]);
123 /****************************************************************
124 * Right Eigenvectors from LeVeque Chapter 18.8, Equation 18.48 *
125 ***************************************************************/
127 // @todo figure out for 3D
128 // => github.com/clawpack/riemann/blob/master/src/rpn3_euler.f90
130 const int transverse = normal == 0 ? 1 : 0;
132 // first right Eigenvector
133 tarch::la::Vector<NumberOfUnknowns, double> r1(0.0);
135 r1(1 + normal) = roeAveragedVelocities(normal) - speedOfSoundRoe;
136 r1(1 + transverse) = roeAveragedVelocities(transverse);
137 r1(3) = HRoe - roeAveragedVelocities(normal) * speedOfSoundRoe;
139 // second right Eigenvector
140 tarch::la::Vector<NumberOfUnknowns, double> r2(0.0);
142 r2(1 + normal) = 0.0;
143 r2(1 + transverse) = 1.0;
144 r2(3) = roeAveragedVelocities(transverse);
146 // third right Eigenvector
147 tarch::la::Vector<NumberOfUnknowns, double> r3(0.0);
149 r3(1) = roeAveragedVelocities(0);
150 r3(2) = roeAveragedVelocities(1);
153 // fourth right Eigenvector
154 tarch::la::Vector<NumberOfUnknowns, double> r4(0.0);
156 r4(1 + normal) = roeAveragedVelocities(normal) + speedOfSoundRoe;
157 r4(1 + transverse) = roeAveragedVelocities(transverse);
158 r4(3) = HRoe + roeAveragedVelocities(normal) * speedOfSoundRoe;
160 /***************************************************
161 * Beta values following Bale et al. Equation 1.14 *
162 **************************************************/
163 // inverted Eigenvectors taken from https://github.com/clawpack/riemann/blob/master/src/rpn2_euler_4wave.f90
165 // @todo figure out for 3D
166 tarch::la::Vector<NumberOfUnknowns, double> beta(0.0);
169 (HRoe - 2 * qSquared) * delta(0)
170 + roeAveragedVelocities(normal) * delta(1 + normal)
171 + roeAveragedVelocities(transverse) * delta(1 + transverse)
173 ) / (HRoe - qSquared);
175 beta(1) = delta(1 + transverse) - roeAveragedVelocities(transverse) * delta(0);
179 + (speedOfSoundRoe - roeAveragedVelocities(normal)) * delta(0)
180 - speedOfSoundRoe * beta(2)
181 ) / (2 * speedOfSoundRoe);
183 beta(0) = delta(0) - beta(2) - beta(3);
189 const tarch::la::Vector<NumberOfUnknowns, double> fWaves[NumberOfUnknowns] = {
196 for (int wave = 0; wave < NumberOfUnknowns; ++wave) {
197 const auto eigenvalue = roeEigenvalues(wave);
198 if (eigenvalue < 0.0) {
200 for (int unknown = 0; unknown < NumberOfUnknowns; ++unknown) {
201 FL[unknown] += fWaves[wave](unknown);
205 for (int unknown = 0; unknown < NumberOfUnknowns; ++unknown) {
206 FR[unknown] -= fWaves[wave](unknown);
211 return tarch::la::maxAbs(roeEigenvalues);