1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "rusanovFlux.H"
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 void Foam::rusanovFlux::evaluateFlux
44 const scalar& CvRight,
49 // Step 1: decode rho left and right:
50 scalar rhoLeft = pLeft/(RLeft*TLeft);
51 scalar rhoRight = pRight/(RRight*TRight);
53 // Decode left and right total energy:
54 scalar eLeft = CvLeft*TLeft+0.5*magSqr(ULeft);
55 scalar eRight = CvRight*TRight+0.5*magSqr(URight);
57 // Adiabatic exponent is constant for ideal gas but if Cp=Cp(T)
58 // it must be computed for each cell and evaluated at each face
59 // through reconstruction
60 const scalar kappaLeft = (CvLeft+RLeft)/CvLeft;
61 const scalar kappaRight = (CvRight+RRight)/CvRight;
64 vector normalVector = Sf/magSf;
66 // Compute left and right contravariant velocities:
67 const scalar contrVLeft = (ULeft & normalVector);
68 const scalar contrVRight = (URight & normalVector);
70 // Compute left and right total enthalpies:
71 const scalar hLeft = eLeft + pLeft/rhoLeft;
72 const scalar hRight = eRight + pRight/rhoRight;
74 // Step 2: compute Roe averged quantities for face:
75 const scalar rhoTilde = sqrt(max(rhoLeft*rhoRight, SMALL));
77 // Some temporary variables:
78 const scalar rhoLeftSqrt = sqrt(max(rhoLeft, SMALL));
79 const scalar rhoRightSqrt = sqrt(max(rhoRight, SMALL));
81 const scalar wLeft = rhoLeftSqrt/(rhoLeftSqrt + rhoRightSqrt);
82 const scalar wRight = 1 - wLeft;
84 const vector UTilde = ULeft*wLeft + URight*wRight;
85 const scalar hTilde = hLeft*wLeft + hRight*wRight;
86 const scalar qTildeSquare = magSqr(UTilde);
87 const scalar kappaTilde = kappaLeft*wLeft + kappaRight*wRight;
91 sqrt(max((kappaTilde - 1)*(hTilde - 0.5*qTildeSquare), SMALL));
93 // Roe averaged contravariant velocity
94 const scalar contrVTilde = (UTilde & normalVector);
96 // Step 3: compute primitive differences:
97 const scalar deltaP = pRight - pLeft;
98 const scalar deltaRho = rhoRight - rhoLeft;
99 const vector deltaU = URight - ULeft;
100 const scalar deltaContrV = (deltaU & normalVector);
102 // Step 4: compute wave strengths:
104 // Roe and Pike - formulation
106 (deltaP - rhoTilde*cTilde*deltaContrV)/(2.0*sqr(cTilde));
107 const scalar r2 = deltaRho - deltaP/sqr(cTilde);
109 (deltaP + rhoTilde*cTilde*deltaContrV)/(2.0*sqr(cTilde));
111 // Step 5: compute l vectors
114 const scalar l1rho = 1;
115 const scalar l2rho = 1;
116 const scalar l3rho = 0;
117 const scalar l4rho = 1;
120 const vector l1U = UTilde - cTilde*normalVector;
123 const vector l2U = UTilde;
126 const vector l3U = deltaU - deltaContrV*normalVector;
129 const vector l4U = UTilde + cTilde*normalVector;
132 const scalar l1e = hTilde - cTilde*contrVTilde;
133 const scalar l2e = 0.5*qTildeSquare;
134 const scalar l3e = (UTilde & deltaU) - contrVTilde*deltaContrV;
135 const scalar l4e = hTilde + cTilde*contrVTilde;
137 // Step 6: compute eigenvalues
139 // derived from algebra by hand, only for Euler equation usefull
140 scalar lambda1 = mag(contrVTilde - cTilde);
141 scalar lambda2 = mag(contrVTilde);
142 scalar lambda3 = mag(contrVTilde + cTilde);
144 scalar lambdaMax = max(max(lambda1,lambda2),lambda3);
146 // Step 7: Compute flux differences
148 // Components of deltaF1
149 const scalar diffF11 = lambdaMax*r1*l1rho;
150 const vector diffF124 = lambdaMax*r1*l1U;
151 const scalar diffF15 = lambdaMax*r1*l1e;
153 // Components of deltaF2
154 const scalar diffF21 = lambdaMax*(r2*l2rho + rhoTilde*l3rho);
155 const vector diffF224 = lambdaMax*(r2*l2U + rhoTilde*l3U);
156 const scalar diffF25 = lambdaMax*(r2*l2e + rhoTilde*l3e);
158 // Components of deltaF3
159 const scalar diffF31 = lambdaMax*r3*l4rho;
160 const vector diffF324 = lambdaMax*r3*l4U;
161 const scalar diffF35 = lambdaMax*r3*l4e;
163 // Step 8: compute left and right fluxes
165 // Left flux 5-vector
166 const scalar fluxLeft11 = rhoLeft*contrVLeft;
167 const vector fluxLeft124 = ULeft*fluxLeft11 + normalVector*pLeft;
168 const scalar fluxLeft15 = hLeft*fluxLeft11;
170 // Right flux 5-vector
171 const scalar fluxRight11 = rhoRight*contrVRight;
172 const vector fluxRight124 = URight*fluxRight11 + normalVector*pRight;
173 const scalar fluxRight15 = hRight*fluxRight11;
175 // Step 10: compute face flux 5-vector
177 0.5*(fluxLeft11 + fluxRight11 - (diffF11 + diffF21 + diffF31));
178 const vector flux24 =
179 0.5*(fluxLeft124 + fluxRight124 - (diffF124 + diffF224 + diffF324));
181 0.5*(fluxLeft15 + fluxRight15 - (diffF15 + diffF25 + diffF35));
183 // Compute private data
184 rhoFlux = flux1*magSf;
185 rhoUFlux = flux24*magSf;
186 rhoEFlux = flux5*magSf;
189 // ************************************************************************* //