Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShallowWaterSolver/RiemannSolvers/HLLCSolver.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: HLLCSolver.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: HLLC Riemann solver for the Nonlinear Shallow Water Equations.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 namespace Nektar
39 {
40  std::string HLLCSolver::solverName =
42  "HLLC",
44  "HLLC Riemann solver");
45 
46  HLLCSolver::HLLCSolver() : NonlinearSWESolver()
47  {
48 
49  }
50 
51  /**
52  * @brief HLLC 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 hC,huC,hvC,SL,SR,hstar,ustar,Sstar;
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  if (hstar > hL)
92  SL = uL - cL * sqrt(0.5*((hstar*hstar + hstar*hL)/(hL*hL)));
93  else
94  SL = uL - cL;
95 
96  // Compute SR
97  if (hstar > hR)
98  SR = uR + cR * sqrt(0.5*((hstar*hstar + hstar*hR)/(hR*hR)));
99  else
100  SR = uR + cR;
101 
102  if (fabs(hR*(uR-SR)-hL*(uL-SL)) <= 1.0e-10)
103  Sstar = ustar;
104  else
105  Sstar = (SL*hR*(uR-SR)-SR*hL*(uL-SL))/(hR*(uR-SR)-hL*(uL-SL));
106 
107  if (SL >= 0)
108  {
109  hf = hL * uL;
110  huf = uL * uL * hL + 0.5 * g * hL * hL;
111  hvf = hL * uL * vL;
112  }
113  else if (SR <= 0)
114  {
115  hf = hR * uR;
116  huf = uR * uR * hR + 0.5 * g * hR * hR;
117  hvf = hR * uR *vR;
118  }
119  else if ((SL < 0) && (Sstar >= 0))
120  {
121  hC = hL * ((SL - uL) / (SL - Sstar));
122  huC = hC * Sstar;
123  hvC = hC * vL;
124 
125  hf = hL*uL + SL * (hC - hL);
126  huf = (uL*uL*hL+0.5*g*hL*hL) + SL * (huC - hL*uL);
127  hvf = (uL*vL*hL) + SL * (hvC - hL*vL);
128  }
129  else if ((SR > 0) && (Sstar <= 0))
130  {
131  hC = hR * ((SR - uR) / (SR - Sstar));
132  huC = hC * Sstar;
133  hvC = hC * vR;
134 
135  hf = hR*uR + SR * (hC - hR);
136  huf = (uR*uR*hR+0.5*g*hR*hR) + SR * (huC - hR*uR);
137  hvf = (uR*vR*hR) + SR * (hvC - hR*vR);
138  }
139  else
140  {
141  ASSERTL0(false,"Error in HLLC solver -- non physical combination of SR, SL and Sstar");
142  }
143  }
144 }