Nektar++
CompressibleFlowSolver/RiemannSolvers/HLLSolver.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: HLLSolver.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: HLL Riemann solver.
32//
33///////////////////////////////////////////////////////////////////////////////
34
36
37namespace Nektar
38{
39
40std::string HLLSolver::solverName =
42 "HLL", HLLSolver::create, "HLL Riemann solver");
43
45 : CompressibleSolver(pSession)
46{
47}
48
49/**
50 * @brief HLL Riemann solver
51 *
52 * @param rhoL Density left state.
53 * @param rhoR Density right state.
54 * @param rhouL x-momentum component left state.
55 * @param rhouR x-momentum component right state.
56 * @param rhovL y-momentum component left state.
57 * @param rhovR y-momentum component right state.
58 * @param rhowL z-momentum component left state.
59 * @param rhowR z-momentum component right state.
60 * @param EL Energy left state.
61 * @param ER Energy right state.
62 * @param rhof Computed Riemann flux for density.
63 * @param rhouf Computed Riemann flux for x-momentum component
64 * @param rhovf Computed Riemann flux for y-momentum component
65 * @param rhowf Computed Riemann flux for z-momentum component
66 * @param Ef Computed Riemann flux for energy.
67 */
68void HLLSolver::v_PointSolve(double rhoL, double rhouL, double rhovL,
69 double rhowL, double EL, double rhoR, double rhouR,
70 double rhovR, double rhowR, double ER,
71 double &rhof, double &rhouf, double &rhovf,
72 double &rhowf, double &Ef)
73{
74 // Left and Right velocities
75 NekDouble uL = rhouL / rhoL;
76 NekDouble vL = rhovL / rhoL;
77 NekDouble wL = rhowL / rhoL;
78 NekDouble uR = rhouR / rhoR;
79 NekDouble vR = rhovR / rhoR;
80 NekDouble wR = rhowR / rhoR;
81
82 // Internal energy (per unit mass)
83 NekDouble eL = (EL - 0.5 * (rhouL * uL + rhovL * vL + rhowL * wL)) / rhoL;
84 NekDouble eR = (ER - 0.5 * (rhouR * uR + rhovR * vR + rhowR * wR)) / rhoR;
85 // Pressure
86 NekDouble pL = m_eos->GetPressure(rhoL, eL);
87 NekDouble pR = m_eos->GetPressure(rhoR, eR);
88 // Speed of sound
89 NekDouble cL = m_eos->GetSoundSpeed(rhoL, eL);
90 NekDouble cR = m_eos->GetSoundSpeed(rhoR, eR);
91
92 // Left and right total enthalpy
93 NekDouble HL = (EL + pL) / rhoL;
94 NekDouble HR = (ER + pR) / rhoR;
95
96 // Square root of rhoL and rhoR.
97 NekDouble srL = sqrt(rhoL);
98 NekDouble srR = sqrt(rhoR);
99 NekDouble srLR = srL + srR;
100
101 // Roe average state
102 NekDouble uRoe = (srL * uL + srR * uR) / srLR;
103 NekDouble vRoe = (srL * vL + srR * vR) / srLR;
104 NekDouble wRoe = (srL * wL + srR * wR) / srLR;
105 NekDouble URoe2 = uRoe * uRoe + vRoe * vRoe + wRoe * wRoe;
106 NekDouble HRoe = (srL * HL + srR * HR) / srLR;
107 NekDouble cRoe = GetRoeSoundSpeed(rhoL, pL, eL, HL, srL, rhoR, pR, eR, HR,
108 srR, HRoe, URoe2, srLR);
109
110 // Maximum wave speeds
111 NekDouble SL = std::min(uL - cL, uRoe - cRoe);
112 NekDouble SR = std::max(uR + cR, uRoe + cRoe);
113
114 // HLL Riemann fluxes (positive case)
115 if (SL >= 0)
116 {
117 rhof = rhouL;
118 rhouf = rhouL * uL + pL;
119 rhovf = rhouL * vL;
120 rhowf = rhouL * wL;
121 Ef = uL * (EL + pL);
122 }
123 // HLL Riemann fluxes (negative case)
124 else if (SR <= 0)
125 {
126 rhof = rhouR;
127 rhouf = rhouR * uR + pR;
128 rhovf = rhouR * vR;
129 rhowf = rhouR * wR;
130 Ef = uR * (ER + pR);
131 }
132 // HLL Riemann fluxes (general case (SL < 0 | SR > 0)
133 else
134 {
135 NekDouble tmp1 = 1.0 / (SR - SL);
136 NekDouble tmp2 = SR * SL;
137 rhof = (SR * rhouL - SL * rhouR + tmp2 * (rhoR - rhoL)) * tmp1;
138 rhouf = (SR * (rhouL * uL + pL) - SL * (rhouR * uR + pR) +
139 tmp2 * (rhouR - rhouL)) *
140 tmp1;
141 rhovf =
142 (SR * rhouL * vL - SL * rhouR * vR + tmp2 * (rhovR - rhovL)) * tmp1;
143 rhowf =
144 (SR * rhouL * wL - SL * rhouR * wR + tmp2 * (rhowR - rhowL)) * tmp1;
145 Ef = (SR * uL * (EL + pL) - SL * uR * (ER + pR) + tmp2 * (ER - EL)) *
146 tmp1;
147 }
148}
149
150} // namespace Nektar
ND GetRoeSoundSpeed(ND rhoL, ND pL, ND eL, ND HL, ND srL, ND rhoR, ND pR, ND eR, ND HR, ND srR, ND HRoe, ND URoe2, ND srLR)
EquationOfStateSharedPtr m_eos
void v_PointSolve(double rhoL, double rhouL, double rhovL, double rhowL, double EL, double rhoR, double rhouR, double rhovR, double rhowR, double ER, double &rhof, double &rhouf, double &rhovf, double &rhowf, double &Ef) override
HLL Riemann solver.
HLLSolver(const LibUtilities::SessionReaderSharedPtr &pSession)
static RiemannSolverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:285