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
37using namespace std;
38
39namespace Nektar
40{
41std::string AverageSolver::solverName =
43 "Average", AverageSolver::create, "Average Riemann solver");
44
47 : CompressibleSolver(pSession)
48{
49 m_pointSolve = false;
50}
51
52/**
53 * @brief Average Riemann solver.
54 *
55 * @param rhoL Density left state.
56 * @param rhoR Density right state.
57 * @param rhouL x-momentum component left state.
58 * @param rhouR x-momentum component right state.
59 * @param rhovL y-momentum component left state.
60 * @param rhovR y-momentum component right state.
61 * @param rhowL z-momentum component left state.
62 * @param rhowR z-momentum component right state.
63 * @param EL Energy left state.
64 * @param ER Energy right state.
65 * @param rhof Computed Riemann flux for density.
66 * @param rhouf Computed Riemann flux for x-momentum component
67 * @param rhovf Computed Riemann flux for y-momentum component
68 * @param rhowf Computed Riemann flux for z-momentum component
69 * @param Ef Computed Riemann flux for energy.
70 */
72 const Array<OneD, const Array<OneD, NekDouble>> &Fwd,
73 const Array<OneD, const Array<OneD, NekDouble>> &Bwd,
75{
76 size_t expDim = Fwd.size() - 2;
77 size_t i, j;
78
79 for (j = 0; j < Fwd[0].size(); ++j)
80 {
81 NekDouble tmp1 = 0.0, tmp2 = 0.0;
82 Array<OneD, NekDouble> Ufwd(expDim);
83 Array<OneD, NekDouble> Ubwd(expDim);
84
85 for (i = 0; i < expDim; ++i)
86 {
87 Ufwd[i] = Fwd[i + 1][j] / Fwd[0][j];
88 Ubwd[i] = Bwd[i + 1][j] / Bwd[0][j];
89 tmp1 += Ufwd[i] * Fwd[i + 1][j];
90 tmp2 += Ubwd[i] * Bwd[i + 1][j];
91 }
92
93 // Internal energy
94 NekDouble eFwd = (Fwd[expDim + 1][j] - 0.5 * tmp1) / Fwd[0][j];
95 NekDouble eBwd = (Bwd[expDim + 1][j] - 0.5 * tmp2) / Bwd[0][j];
96 // Pressure
97 NekDouble Pfwd = m_eos->GetPressure(Fwd[0][j], eFwd);
98 NekDouble Pbwd = m_eos->GetPressure(Bwd[0][j], eBwd);
99
100 // Compute the average flux
101 flux[0][j] = 0.5 * (Fwd[1][j] + Bwd[1][j]);
102 flux[expDim + 1][j] = 0.5 * (Ufwd[0] * (Fwd[expDim + 1][j] + Pfwd) +
103 Ubwd[0] * (Bwd[expDim + 1][j] + Pbwd));
104
105 for (i = 0; i < expDim; ++i)
106 {
107 flux[i + 1][j] = 0.5 * (Fwd[0][j] * Ufwd[0] * Ufwd[i] +
108 Bwd[0][j] * Ubwd[0] * Ubwd[i]);
109 }
110
111 // Add in pressure contribution to u field
112 flux[1][j] += 0.5 * (Pfwd + Pbwd);
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.
Definition: NekFactory.hpp:197
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
double NekDouble