Nektar++
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// 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: HLLC Riemann solver for the Nonlinear Shallow Water Equations.
32//
33///////////////////////////////////////////////////////////////////////////////
34
36
37namespace Nektar
38{
39std::string HLLCSolver::solverName =
41 "HLLC", HLLCSolver::create, "HLLC Riemann solver");
42
44 : NonlinearSWESolver(pSession)
45{
46}
47
48/**
49 * @brief HLLC Riemann solver for the Nonlinear Shallow Water Equations
50 *
51 * @param hL Water depth left state.
52 * @param hR Water depth right state.
53 * @param huL x-momentum component left state.
54 * @param huR x-momentum component right state.
55 * @param hvL y-momentum component left state.
56 * @param hvR y-momentum component right state.
57 * @param hf Computed Riemann flux for density.
58 * @param huf Computed Riemann flux for x-momentum component
59 * @param hvf Computed Riemann flux for y-momentum component
60 */
61void HLLCSolver::v_PointSolve(NekDouble hL, NekDouble huL, NekDouble hvL,
62 NekDouble hR, NekDouble huR, NekDouble hvR,
63 NekDouble &hf, NekDouble &huf, NekDouble &hvf)
64{
65 static NekDouble g = m_params["gravity"]();
66
67 // Left and Right velocities
68 NekDouble uL = huL / hL;
69 NekDouble vL = hvL / hL;
70 NekDouble uR = huR / hR;
71 NekDouble vR = hvR / hR;
72
73 // Left and right wave speeds
74 NekDouble cL = sqrt(g * hL);
75 NekDouble cR = sqrt(g * hR);
76
77 // the two-rarefaction wave assumption
78 NekDouble hC, huC, hvC, SL, SR, hstar, ustar, Sstar;
79 hstar = 0.5 * (cL + cR) + 0.25 * (uL - uR);
80 hstar *= hstar;
81 hstar *= (1.0 / g);
82 ustar = 0.5 * (uL + uR) + cL - cR;
83
84 // Compute SL
85 if (hstar > hL)
86 {
87 SL = uL - cL * sqrt(0.5 * ((hstar * hstar + hstar * hL) / (hL * hL)));
88 }
89 else
90 {
91 SL = uL - cL;
92 }
93
94 // Compute SR
95 if (hstar > hR)
96 {
97 SR = uR + cR * sqrt(0.5 * ((hstar * hstar + hstar * hR) / (hR * hR)));
98 }
99 else
100 {
101 SR = uR + cR;
102 }
103
104 if (fabs(hR * (uR - SR) - hL * (uL - SL)) <= 1.0e-10)
105 {
106 Sstar = ustar;
107 }
108 else
109 {
110 Sstar = (SL * hR * (uR - SR) - SR * hL * (uL - SL)) /
111 (hR * (uR - SR) - hL * (uL - SL));
112 }
113
114 if (SL >= 0)
115 {
116 hf = hL * uL;
117 huf = uL * uL * hL + 0.5 * g * hL * hL;
118 hvf = hL * uL * vL;
119 }
120 else if (SR <= 0)
121 {
122 hf = hR * uR;
123 huf = uR * uR * hR + 0.5 * g * hR * hR;
124 hvf = hR * uR * vR;
125 }
126 else if ((SL < 0) && (Sstar >= 0))
127 {
128 hC = hL * ((SL - uL) / (SL - Sstar));
129 huC = hC * Sstar;
130 hvC = hC * vL;
131
132 hf = hL * uL + SL * (hC - hL);
133 huf = (uL * uL * hL + 0.5 * g * hL * hL) + SL * (huC - hL * uL);
134 hvf = (uL * vL * hL) + SL * (hvC - hL * vL);
135 }
136 else if ((SR > 0) && (Sstar <= 0))
137 {
138 hC = hR * ((SR - uR) / (SR - Sstar));
139 huC = hC * Sstar;
140 hvC = hC * vR;
141
142 hf = hR * uR + SR * (hC - hR);
143 huf = (uR * uR * hR + 0.5 * g * hR * hR) + SR * (huC - hR * uR);
144 hvf = (uR * vR * hR) + SR * (hvC - hR * vR);
145 }
146 else
147 {
148 NEKERROR(ErrorUtil::efatal,
149 "Error in HLLC solver -- non physical combination of "
150 "SR, SL and Sstar");
151 }
152}
153} // namespace Nektar
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
static RiemannSolverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
HLLCSolver(const LibUtilities::SessionReaderSharedPtr &pSession)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294