Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: HLL Riemann solver.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 namespace Nektar
39 {
40  std::string HLLSolver::solverName =
42  "HLL",
44  "HLL Riemann solver");
45 
47  {
48 
49  }
50 
51  /**
52  * @brief HLL Riemann solver
53  *
54  * @param rhoL Density left state.
55  * @param rhoR Density right state.
56  * @param rhouL x-momentum component left state.
57  * @param rhouR x-momentum component right state.
58  * @param rhovL y-momentum component left state.
59  * @param rhovR y-momentum component right state.
60  * @param rhowL z-momentum component left state.
61  * @param rhowR z-momentum component right state.
62  * @param EL Energy left state.
63  * @param ER Energy right state.
64  * @param rhof Computed Riemann flux for density.
65  * @param rhouf Computed Riemann flux for x-momentum component
66  * @param rhovf Computed Riemann flux for y-momentum component
67  * @param rhowf Computed Riemann flux for z-momentum component
68  * @param Ef Computed Riemann flux for energy.
69  */
71  double rhoL, double rhouL, double rhovL, double rhowL, double EL,
72  double rhoR, double rhouR, double rhovR, double rhowR, double ER,
73  double &rhof, double &rhouf, double &rhovf, double &rhowf, double &Ef)
74  {
75  static NekDouble gamma = m_params["gamma"]();
76 
77  // Left and Right velocities
78  NekDouble uL = rhouL / rhoL;
79  NekDouble vL = rhovL / rhoL;
80  NekDouble wL = rhowL / rhoL;
81  NekDouble uR = rhouR / rhoR;
82  NekDouble vR = rhovR / rhoR;
83  NekDouble wR = rhowR / rhoR;
84 
85  // Left and right pressures
86  NekDouble pL = (gamma - 1.0) *
87  (EL - 0.5 * (rhouL * uL + rhovL * vL + rhowL * wL));
88  NekDouble pR = (gamma - 1.0) *
89  (ER - 0.5 * (rhouR * uR + rhovR * vR + rhowR * wR));
90  NekDouble cL = sqrt(gamma * pL / rhoL);
91  NekDouble cR = sqrt(gamma * pR / rhoR);
92  NekDouble hL = (EL + pL) / rhoL;
93  NekDouble hR = (ER + pR) / rhoR;
94 
95  // Square root of rhoL and rhoR.
96  NekDouble srL = sqrt(rhoL);
97  NekDouble srR = sqrt(rhoR);
98  NekDouble srLR = srL + srR;
99 
100  // Velocity Roe averages
101  NekDouble uRoe = (srL * uL + srR * uR) / srLR;
102  NekDouble vRoe = (srL * vL + srR * vR) / srLR;
103  NekDouble wRoe = (srL * wL + srR * wR) / srLR;
104  NekDouble hRoe = (srL * hL + srR * hR) / srLR;
105  NekDouble cRoe = sqrt((gamma - 1.0)*(hRoe - 0.5 *
106  (uRoe * uRoe + vRoe * vRoe + wRoe * wRoe)));
107 
108  // Maximum wave speeds
109  NekDouble SL = std::min(uL-cL, uRoe-cRoe);
110  NekDouble SR = std::max(uR+cR, uRoe+cRoe);
111 
112  // HLL Riemann fluxes (positive case)
113  if (SL >= 0)
114  {
115  rhof = rhouL;
116  rhouf = rhouL * uL + pL;
117  rhovf = rhouL * vL;
118  rhowf = rhouL * wL;
119  Ef = uL * (EL + pL);
120  }
121  // HLL Riemann fluxes (negative case)
122  else if (SR <= 0)
123  {
124  rhof = rhouR;
125  rhouf = rhouR * uR + pR;
126  rhovf = rhouR * vR;
127  rhowf = rhouR * wR;
128  Ef = uR * (ER + pR);
129  }
130  // HLL Riemann fluxes (general case (SL < 0 | SR > 0)
131  else
132  {
133  NekDouble tmp1 = 1.0 / (SR - SL);
134  NekDouble tmp2 = SR * SL;
135  rhof = (SR * rhouL - SL * rhouR + tmp2 * (rhoR - rhoL)) * tmp1;
136  rhouf = (SR * (rhouL * uL + pL) - SL * (rhouR * uR + pR) +
137  tmp2 * (rhouR - rhouL)) * tmp1;
138  rhovf = (SR * rhouL * vL - SL * rhouR * vR +
139  tmp2 * (rhovR - rhovL)) * tmp1;
140  rhowf = (SR * rhouL * wL - SL * rhouR * wR +
141  tmp2 * (rhowR - rhowL)) * tmp1;
142  Ef = (SR * uL * (EL + pL) - SL * uR * (ER + pR) +
143  tmp2 * (ER - EL)) * tmp1;
144  }
145  }
146 }