Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShallowWaterSolver/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 for the Nonlinear Shallow Water Equations.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 namespace Nektar
39 {
40  std::string HLLSolver::solverName =
42  "HLL",
44  "HLL Riemann solver");
45 
46  HLLSolver::HLLSolver() : NonlinearSWESolver()
47  {
48 
49  }
50 
51  /**
52  * @brief HLL Riemann solver for the Nonlinear Shallow Water Equations
53  *
54  * @param hL Water depth left state.
55  * @param hR Water depth right state.
56  * @param huL x-momentum component left state.
57  * @param huR x-momentum component right state.
58  * @param hvL y-momentum component left state.
59  * @param hvR y-momentum component right state.
60  * @param hf Computed Riemann flux for density.
61  * @param huf Computed Riemann flux for x-momentum component
62  * @param hvf Computed Riemann flux for y-momentum component
63  */
65  double hL, double huL, double hvL,
66  double hR, double huR, double hvR,
67  double &hf, double &huf, double &hvf)
68  {
69  static NekDouble g = m_params["gravity"]();
70 
71  // Left and Right velocities
72  NekDouble uL = huL / hL;
73  NekDouble vL = hvL / hL;
74  NekDouble uR = huR / hR;
75  NekDouble vR = hvR / hR;
76 
77 
78  // Left and right wave speeds
79  NekDouble cL = sqrt(g * hL);
80  NekDouble cR = sqrt(g * hR);
81 
82  // the two-rarefaction wave assumption
83  NekDouble hstar,ustar,fL,fR;
84  hstar = 0.5 * (cL + cR) + 0.25 * (uL - uR);
85  hstar *= hstar;
86  hstar *= (1.0/g);
87  ustar = 0.5*(uL + uR) + cL - cR;
88 
89 
90  // Compute SL
91  NekDouble SL;
92  if (hstar > hL)
93  SL = uL - cL * sqrt(0.5*((hstar*hstar + hstar*hL)/(hL*hL)));
94  else
95  SL = uL - cL;
96 
97  // Compute SR
98  NekDouble SR;
99  if (hstar > hR)
100  SR = uR + cR * sqrt(0.5*((hstar*hstar + hstar*hR)/(hR*hR)));
101  else
102  SR = uR + cR;
103 
104  if (SL >= 0)
105  {
106  hf = hL * uL;
107  huf = uL * uL * hL + 0.5 * g * hL * hL;
108  hvf = hL * uL * vL;
109  }
110  else if (SR <= 0)
111  {
112  hf = hR * uR;
113  huf = uR * uR * hR + 0.5 * g * hR * hR;
114  hvf = hR * uR *vR;
115  }
116  else
117  {
118  hf = (SR * hL * uL - SL * hR * uR +
119  SL * SR * (hR - hL)) / (SR - SL);
120  fL = uL * uL * hL + 0.5 * g * hL * hL;
121  fR = uR * uR * hR + 0.5 * g * hR * hR;
122  huf =(SR * fL - SL * fR +
123  SL * SR * (hR * uR - hL * uL)) / (SR - SL);
124  fL = uL * vL * hL;
125  fR = uR * vR * hR;
126  hvf =(SR * fL - SL * fR +
127  SL * SR * (hR * vR - hL * vL)) / (SR - SL);
128  }
129  }
130 }