Nektar++
CompressibleFlowSolver/RiemannSolvers/LaxFriedrichsSolver.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: LaxFriedrichsSolver.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: LaxFriedrichs Riemann solver.
32//
33///////////////////////////////////////////////////////////////////////////////
34
36
37namespace Nektar
38{
41 "LaxFriedrichs", LaxFriedrichsSolver::create,
42 "Lax-Friedrichs Riemann solver");
43
46 : CompressibleSolver(pSession)
47{
48}
49
50/**
51 * @brief Lax-Friedrichs Riemann solver
52 *
53 * @param rhoL Density left state.
54 * @param rhoR Density right state.
55 * @param rhouL x-momentum component left state.
56 * @param rhouR x-momentum component right state.
57 * @param rhovL y-momentum component left state.
58 * @param rhovR y-momentum component right state.
59 * @param rhowL z-momentum component left state.
60 * @param rhowR z-momentum component right state.
61 * @param EL Energy left state.
62 * @param ER Energy right state.
63 * @param rhof Computed Riemann flux for density.
64 * @param rhouf Computed Riemann flux for x-momentum component
65 * @param rhovf Computed Riemann flux for y-momentum component
66 * @param rhowf Computed Riemann flux for z-momentum component
67 * @param Ef Computed Riemann flux for energy.
68 */
69void LaxFriedrichsSolver::v_PointSolve(double rhoL, double rhouL, double rhovL,
70 double rhowL, double EL, double rhoR,
71 double rhouR, double rhovR, double rhowR,
72 double ER, double &rhof, double &rhouf,
73 double &rhovf, double &rhowf, double &Ef)
74{
75 // Left and right velocities
76 NekDouble uL = rhouL / rhoL;
77 NekDouble vL = rhovL / rhoL;
78 NekDouble wL = rhowL / rhoL;
79 NekDouble uR = rhouR / rhoR;
80 NekDouble vR = rhovR / rhoR;
81 NekDouble wR = rhowR / rhoR;
82
83 // Internal energy (per unit mass)
84 NekDouble eL = (EL - 0.5 * (rhouL * uL + rhovL * vL + rhowL * wL)) / rhoL;
85 NekDouble eR = (ER - 0.5 * (rhouR * uR + rhovR * vR + rhowR * wR)) / rhoR;
86
87 // Pressure
88 NekDouble pL = m_eos->GetPressure(rhoL, eL);
89 NekDouble pR = m_eos->GetPressure(rhoR, eR);
90
91 // Left and right total enthalpy
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 // Roe average state
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 URoe2 = uRoe * uRoe + vRoe * vRoe + wRoe * wRoe;
105 NekDouble HRoe = (srL * HL + srR * HR) / srLR;
106 NekDouble cRoe = GetRoeSoundSpeed(rhoL, pL, eL, HL, srL, rhoR, pR, eR, HR,
107 srR, HRoe, URoe2, srLR);
108
109 // Maximum eigenvalue
110 NekDouble URoe = fabs(uRoe) + cRoe;
111
112 // Lax-Friedrichs flux formula
113 rhof = 0.5 * (rhouL + rhouR - URoe * (rhoR - rhoL));
114 rhouf = 0.5 * (pL + rhouL * uL + pR + rhouR * uR - URoe * (rhouR - rhouL));
115 rhovf = 0.5 * (rhouL * vL + rhouR * vR - URoe * (rhovR - rhovL));
116 rhowf = 0.5 * (rhouL * wL + rhouR * wR - URoe * (rhowR - rhowL));
117 Ef = 0.5 * (uL * (EL + pL) + uR * (ER + pR) - URoe * (ER - EL));
118}
119} // 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
Lax-Friedrichs Riemann solver.
static RiemannSolverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
LaxFriedrichsSolver(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