Nektar++
APEUpwindSolver.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: APEUpwindSolver.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2015 Kilian Lackhove
10// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
11// Department of Aeronautics, Imperial College London (UK), and Scientific
12// Computing and Imaging Institute, University of Utah (USA).
13//
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: Upwind Riemann solver for the APE equations.
33//
34///////////////////////////////////////////////////////////////////////////////
35
37
38using namespace std;
39
40namespace Nektar
41{
42
45 "APEUpwind", APEUpwindSolver::create,
46 "Upwind solver for the APE equation");
47
50 : AcousticSolver(pSession)
51{
52}
53
54/**
55 * @brief Upwind Riemann solver
56 *
57 * The fluxes are straight out of sympy, so lets just hope the compiler
58 * optimizes them for us.
59 *
60 * @param pL Perturbation pressure left state
61 * @param rhoL Perturbation density left state
62 * @param pR Perturbation pressure right state
63 * @param rhoR Perturbation density right state
64 * @param uL x perturbation velocity component left state
65 * @param uR x perturbation velocity component right state
66 * @param vL y perturbation velocity component left state
67 * @param vR y perturbation velocity component right state
68 * @param wL z perturbation velocity component left state
69 * @param wR z perturbation velocity component right state
70 * @param c0sqL Base pressure left state
71 * @param c0sqR Base pressure right state
72 * @param rho0L Base density left state
73 * @param rho0R Base density right state
74 * @param u0L Base x velocity component left state
75 * @param u0R Base x velocity component right state
76 * @param v0L Base y velocity component left state
77 * @param v0R Base y velocity component right state
78 * @param w0L Base z velocity component left state
79 * @param w0R Base z velocity component right state
80 * @param pF Computed Riemann flux for perturbation pressure
81 * @param rhoF Computed Riemann flux for perturbation density
82 * @param uF Computed Riemann flux for x perturbation velocity component
83 * @param vF Computed Riemann flux for y perturbation velocity component
84 * @param wF Computed Riemann flux for z perturbation velocity component
85 */
87 NekDouble pL, [[maybe_unused]] NekDouble rhoL, NekDouble uL, NekDouble vL,
88 NekDouble wL, NekDouble pR, [[maybe_unused]] NekDouble rhoR, NekDouble uR,
89 NekDouble vR, NekDouble wR, NekDouble c0sqL, NekDouble rho0L, NekDouble u0L,
90 NekDouble v0L, NekDouble w0L, NekDouble c0sqR, NekDouble rho0R,
91 NekDouble u0R, NekDouble v0R, NekDouble w0R, NekDouble &pF,
92 [[maybe_unused]] NekDouble &rhoF, NekDouble &uF, NekDouble &vF,
93 NekDouble &wF)
94{
95 // Speed of sound
96 NekDouble c0L = sqrt(c0sqL);
97 NekDouble c0R = sqrt(c0sqR);
98 NekDouble c0M = (c0L + c0R) / 2.0;
99
100 NekDouble u0M = (u0L + u0R) / 2.0;
101
102 pF = 0.0;
103 uF = 0.0;
104 vF = 0.0;
105 wF = 0.0;
106
107 // lambda_3
108 if (u0M - c0M > 0)
109 {
110 pF = pF + 0.5 * (c0L - u0L) *
111 (-rho0L * v0L * vL * (c0L * u0L + c0sqL) -
112 rho0L * w0L * wL * (c0L * u0L + c0sqL) +
113 (c0sqL - pow(u0L, 2)) * (rho0L * c0L * uL - pL)) /
114 (c0sqL - pow(u0L, 2));
115
116 uF = uF +
117 0.5 * (c0L - u0L) *
118 (rho0L * c0L * (c0L * u0L + c0sqL) * (v0L * vL + w0L * wL) -
119 rho0L * c0sqL * uL * (c0sqL - pow(u0L, 2)) +
120 c0L * pL * (c0sqL - pow(u0L, 2))) /
121 (rho0L * c0sqL * (c0sqL - pow(u0L, 2)));
122 }
123 else
124 {
125 pF = pF + 0.5 * (c0R - u0R) *
126 (-rho0R * v0R * vR * (c0R * u0R + c0sqR) -
127 rho0R * w0R * wR * (c0R * u0R + c0sqR) +
128 (c0sqR - pow(u0R, 2)) * (rho0R * c0R * uR - pR)) /
129 (c0sqR - pow(u0R, 2));
130
131 uF = uF +
132 0.5 * (c0R - u0R) *
133 (rho0R * c0R * (c0R * u0R + c0sqR) * (v0R * vR + w0R * wR) -
134 rho0R * c0sqR * uR * (c0sqR - pow(u0R, 2)) +
135 c0R * pR * (c0sqR - pow(u0R, 2))) /
136 (rho0R * c0sqR * (c0sqR - pow(u0R, 2)));
137 }
138
139 // lambda_4
140 if (u0M + c0M > 0)
141 {
142 pF = pF + 0.5 * (c0L + u0L) *
143 (-rho0L * v0L * vL * (c0L * u0L - c0sqL) -
144 rho0L * w0L * wL * (c0L * u0L - c0sqL) +
145 (c0sqL - pow(u0L, 2)) * (rho0L * c0L * uL + pL)) /
146 (c0sqL - pow(u0L, 2));
147
148 uF = uF +
149 0.5 * (c0L + u0L) *
150 (-rho0L * c0L * (c0L * u0L - c0sqL) * (v0L * vL + w0L * wL) +
151 rho0L * c0sqL * uL * (c0sqL - pow(u0L, 2)) +
152 c0L * pL * (c0sqL - pow(u0L, 2))) /
153 (rho0L * c0sqL * (c0sqL - pow(u0L, 2)));
154 }
155 else
156 {
157 pF = pF + 0.5 * (c0R + u0R) *
158 (-rho0R * v0R * vR * (c0R * u0R - c0sqR) -
159 rho0R * w0R * wR * (c0R * u0R - c0sqR) +
160 (c0sqR - pow(u0R, 2)) * (rho0R * c0R * uR + pR)) /
161 (c0sqR - pow(u0R, 2));
162
163 uF = uF +
164 0.5 * (c0R + u0R) *
165 (-rho0R * c0R * (c0R * u0R - c0sqR) * (v0R * vR + w0R * wR) +
166 rho0R * c0sqR * uR * (c0sqR - pow(u0R, 2)) +
167 c0R * pR * (c0sqR - pow(u0R, 2))) /
168 (rho0R * c0sqR * (c0sqR - pow(u0R, 2)));
169 }
170}
171
172} // namespace Nektar
APEUpwindSolver(const LibUtilities::SessionReaderSharedPtr &pSession)
static std::string solverName
void v_PointSolve(NekDouble pL, NekDouble rhoL, NekDouble uL, NekDouble vL, NekDouble wL, NekDouble pR, NekDouble rhoR, NekDouble uR, NekDouble vR, NekDouble wR, NekDouble c0sqL, NekDouble rho0L, NekDouble u0L, NekDouble v0L, NekDouble w0L, NekDouble c0sqR, NekDouble rho0R, NekDouble u0R, NekDouble v0R, NekDouble w0R, NekDouble &pF, NekDouble &rhoF, NekDouble &uF, NekDouble &vF, NekDouble &wF) override
Upwind Riemann solver.
static RiemannSolverSharedPtr create(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