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 
36 #include <boost/core/ignore_unused.hpp>
37 
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
44 
45 std::string APEUpwindSolver::solverName =
47  "APEUpwind", APEUpwindSolver::create,
48  "Upwind solver for the APE equation");
49 
50 APEUpwindSolver::APEUpwindSolver(
52  : AcousticSolver(pSession)
53 {
54 }
55 
56 /**
57  * @brief Upwind Riemann solver
58  *
59  * The fluxes are straight out of sympy, so lets just hope the compiler
60  * optimizes them for us.
61  *
62  * @param pL Perturbation pressure left state
63  * @param rhoL Perturbation density left state
64  * @param pR Perturbation pressure right state
65  * @param rhoR Perturbation density right state
66  * @param uL x perturbation velocity component left state
67  * @param uR x perturbation velocity component right state
68  * @param vL y perturbation velocity component left state
69  * @param vR y perturbation velocity component right state
70  * @param wL z perturbation velocity component left state
71  * @param wR z perturbation velocity component right state
72  * @param c0sqL Base pressure left state
73  * @param c0sqR Base pressure right state
74  * @param rho0L Base density left state
75  * @param rho0R Base density right state
76  * @param u0L Base x velocity component left state
77  * @param u0R Base x velocity component right state
78  * @param v0L Base y velocity component left state
79  * @param v0R Base y velocity component right state
80  * @param w0L Base z velocity component left state
81  * @param w0R Base z velocity component right state
82  * @param pF Computed Riemann flux for perturbation pressure
83  * @param rhoF Computed Riemann flux for perturbation density
84  * @param uF Computed Riemann flux for x perturbation velocity component
85  * @param vF Computed Riemann flux for y perturbation velocity component
86  * @param wF Computed Riemann flux for z perturbation velocity component
87  */
89  NekDouble pL, NekDouble rhoL, NekDouble uL, NekDouble vL, NekDouble wL,
90  NekDouble pR, NekDouble rhoR, NekDouble uR, NekDouble vR, NekDouble wR,
91  NekDouble c0sqL, NekDouble rho0L, NekDouble u0L, NekDouble v0L, NekDouble w0L,
92  NekDouble c0sqR, NekDouble rho0R, NekDouble u0R, NekDouble v0R, NekDouble w0R,
93  NekDouble &pF, NekDouble &rhoF, NekDouble &uF, NekDouble &vF, NekDouble &wF)
94 {
95  boost::ignore_unused(rhoL, rhoR, rhoF);
96 
97  // Speed of sound
98  NekDouble c0L = sqrt(c0sqL);
99  NekDouble c0R = sqrt(c0sqR);
100  NekDouble c0M = (c0L + c0R) / 2.0;
101 
102  NekDouble u0M = (u0L + u0R) / 2.0;
103 
104  pF = 0.0;
105  uF = 0.0;
106  vF = 0.0;
107  wF = 0.0;
108 
109  // lambda_3
110  if (u0M - c0M > 0)
111  {
112  pF = pF + 0.5 * (c0L - u0L) *
113  (-rho0L * v0L * vL * (c0L * u0L + c0sqL) -
114  rho0L * w0L * wL * (c0L * u0L + c0sqL) +
115  (c0sqL - pow(u0L, 2)) * (rho0L * c0L * uL - pL)) /
116  (c0sqL - pow(u0L, 2));
117 
118  uF = uF +
119  0.5 * (c0L - u0L) *
120  (rho0L * c0L * (c0L * u0L + c0sqL) * (v0L * vL + w0L * wL) -
121  rho0L * c0sqL * uL * (c0sqL - pow(u0L, 2)) +
122  c0L * pL * (c0sqL - pow(u0L, 2))) /
123  (rho0L * c0sqL * (c0sqL - pow(u0L, 2)));
124  }
125  else
126  {
127  pF = pF + 0.5 * (c0R - u0R) *
128  (-rho0R * v0R * vR * (c0R * u0R + c0sqR) -
129  rho0R * w0R * wR * (c0R * u0R + c0sqR) +
130  (c0sqR - pow(u0R, 2)) * (rho0R * c0R * uR - pR)) /
131  (c0sqR - pow(u0R, 2));
132 
133  uF = uF +
134  0.5 * (c0R - u0R) *
135  (rho0R * c0R * (c0R * u0R + c0sqR) * (v0R * vR + w0R * wR) -
136  rho0R * c0sqR * uR * (c0sqR - pow(u0R, 2)) +
137  c0R * pR * (c0sqR - pow(u0R, 2))) /
138  (rho0R * c0sqR * (c0sqR - pow(u0R, 2)));
139  }
140 
141  // lambda_4
142  if (u0M + c0M > 0)
143  {
144  pF = pF + 0.5 * (c0L + u0L) *
145  (-rho0L * v0L * vL * (c0L * u0L - c0sqL) -
146  rho0L * w0L * wL * (c0L * u0L - c0sqL) +
147  (c0sqL - pow(u0L, 2)) * (rho0L * c0L * uL + pL)) /
148  (c0sqL - pow(u0L, 2));
149 
150  uF = uF +
151  0.5 * (c0L + u0L) *
152  (-rho0L * c0L * (c0L * u0L - c0sqL) * (v0L * vL + w0L * wL) +
153  rho0L * c0sqL * uL * (c0sqL - pow(u0L, 2)) +
154  c0L * pL * (c0sqL - pow(u0L, 2))) /
155  (rho0L * c0sqL * (c0sqL - pow(u0L, 2)));
156  }
157  else
158  {
159  pF = pF + 0.5 * (c0R + u0R) *
160  (-rho0R * v0R * vR * (c0R * u0R - c0sqR) -
161  rho0R * w0R * wR * (c0R * u0R - c0sqR) +
162  (c0sqR - pow(u0R, 2)) * (rho0R * c0R * uR + pR)) /
163  (c0sqR - pow(u0R, 2));
164 
165  uF = uF +
166  0.5 * (c0R + u0R) *
167  (-rho0R * c0R * (c0R * u0R - c0sqR) * (v0R * vR + w0R * wR) +
168  rho0R * c0sqR * uR * (c0sqR - pow(u0R, 2)) +
169  c0R * pR * (c0sqR - pow(u0R, 2))) /
170  (rho0R * c0sqR * (c0sqR - pow(u0R, 2)));
171  }
172 }
173 
174 } // namespace Nektar
virtual 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)
Upwind Riemann solver.
STL namespace.
RiemannSolverFactory & GetRiemannSolverFactory()
double NekDouble
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
std::shared_ptr< SessionReader > SessionReaderSharedPtr