Nektar++
CompressibleFlowSolver/RiemannSolvers/AverageSolver.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: AverageSolver.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: Average Riemann solver.
32//
33///////////////////////////////////////////////////////////////////////////////
34
36
37namespace Nektar
38{
39
40std::string AverageSolver::solverName =
42 "Average", AverageSolver::create, "Average Riemann solver");
43
46 : CompressibleSolver(pSession)
47{
48 m_pointSolve = false;
49}
50
51/**
52 * @brief Average 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 const Array<OneD, const Array<OneD, NekDouble>> &Fwd,
72 const Array<OneD, const Array<OneD, NekDouble>> &Bwd,
74{
75 size_t expDim = Fwd.size() - 2;
76 size_t i, j;
77
78 for (j = 0; j < Fwd[0].size(); ++j)
79 {
80 NekDouble tmp1 = 0.0, tmp2 = 0.0;
81 Array<OneD, NekDouble> Ufwd(expDim);
82 Array<OneD, NekDouble> Ubwd(expDim);
83
84 for (i = 0; i < expDim; ++i)
85 {
86 Ufwd[i] = Fwd[i + 1][j] / Fwd[0][j];
87 Ubwd[i] = Bwd[i + 1][j] / Bwd[0][j];
88 tmp1 += Ufwd[i] * Fwd[i + 1][j];
89 tmp2 += Ubwd[i] * Bwd[i + 1][j];
90 }
91
92 // Internal energy
93 NekDouble eFwd = (Fwd[expDim + 1][j] - 0.5 * tmp1) / Fwd[0][j];
94 NekDouble eBwd = (Bwd[expDim + 1][j] - 0.5 * tmp2) / Bwd[0][j];
95 // Pressure
96 NekDouble Pfwd = m_eos->GetPressure(Fwd[0][j], eFwd);
97 NekDouble Pbwd = m_eos->GetPressure(Bwd[0][j], eBwd);
98
99 // Compute the average flux
100 flux[0][j] = 0.5 * (Fwd[1][j] + Bwd[1][j]);
101 flux[expDim + 1][j] = 0.5 * (Ufwd[0] * (Fwd[expDim + 1][j] + Pfwd) +
102 Ubwd[0] * (Bwd[expDim + 1][j] + Pbwd));
103
104 for (i = 0; i < expDim; ++i)
105 {
106 flux[i + 1][j] = 0.5 * (Fwd[0][j] * Ufwd[0] * Ufwd[i] +
107 Bwd[0][j] * Ubwd[0] * Ubwd[i]);
108 }
109
110 // Add in pressure contribution to u field
111 flux[1][j] += 0.5 * (Pfwd + Pbwd);
112 }
113}
114
115} // namespace Nektar
static RiemannSolverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
AverageSolver(const LibUtilities::SessionReaderSharedPtr &pSession)
void v_ArraySolve(const Array< OneD, const Array< OneD, NekDouble > > &Fwd, const Array< OneD, const Array< OneD, NekDouble > > &Bwd, Array< OneD, Array< OneD, NekDouble > > &flux) final
Average Riemann solver.
EquationOfStateSharedPtr m_eos
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
double NekDouble