Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
solvers/APESolver/RiemannSolvers/UpwindSolver.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: UpwindSolver.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 // License for the specific language governing rights and limitations under
15 // Permission is hereby granted, free of charge, to any person obtaining a
16 // copy of this software and associated documentation files (the "Software"),
17 // to deal in the Software without restriction, including without limitation
18 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 // and/or sell copies of the Software, and to permit persons to whom the
20 // Software is furnished to do so, subject to the following conditions:
21 //
22 // The above copyright notice and this permission notice shall be included
23 // in all copies or substantial portions of the Software.
24 //
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31 // DEALINGS IN THE SOFTWARE.
32 //
33 // Description: Upwind Riemann solver for the APE equations.
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 
44 std::string UpwindSolver::solverName = SolverUtils::GetRiemannSolverFactory().
45  RegisterCreatorFunction("APEUpwind", UpwindSolver::create,
46  "Upwind solver for the APE equation");
47 
48 UpwindSolver::UpwindSolver() :
49  APESolver()
50 {
51 
52 }
53 
54 
55 /**
56  * @brief Upwind Riemann solver
57  *
58  * @param pL Perturbation pressure left state
59  * @param rhoL Perturbation density left state
60  * @param pR Perturbation pressure right state
61  * @param rhoR Perturbation density right state
62  * @param uL x perturbation velocity component left state
63  * @param uR x perturbation velocity component right state
64  * @param vL y perturbation velocity component left state
65  * @param vR y perturbation velocity component right state
66  * @param wL z perturbation velocity component left state
67  * @param wR z perturbation velocity component right state
68  * @param p0 Base pressure
69  * @param rho0 Base density
70  * @param u0 Base x velocity component
71  * @param v0 Base y velocity component
72  * @param w0 Base z velocity component
73  * @param pF Computed Riemann flux for perturbation pressure
74  * @param rhoF Computed Riemann flux for perturbation density
75  * @param uF Computed Riemann flux for x perturbation velocity component
76  * @param vF Computed Riemann flux for y perturbation velocity component
77  * @param wF Computed Riemann flux for z perturbation velocity component
78  */
80  NekDouble pL, NekDouble rhoL, NekDouble uL, NekDouble vL, NekDouble wL,
81  NekDouble pR, NekDouble rhoR, NekDouble uR, NekDouble vR, NekDouble wR,
82  NekDouble p0, NekDouble rho0, NekDouble u0, NekDouble v0, NekDouble w0,
83  NekDouble &pF, NekDouble &rhoF, NekDouble &uF, NekDouble &vF, NekDouble &wF)
84 {
85  // fetch params
86  ASSERTL1(CheckParams("Gamma"), "Gamma not defined.");
87  const NekDouble &gamma = m_params["Gamma"]();
88 
89  // Speed of sound
90  NekDouble c = sqrt(gamma * p0 / rho0);
91 
92  Array<OneD, NekDouble> characteristic(4);
94  Array<OneD, NekDouble> lambda(2);
95 
96  // compute the wave speeds
97  lambda[0] = u0 + c;
98  lambda[1] = u0 - c;
99 
100  // calculate the caracteristic variables
101  //left characteristics
102  characteristic[0] = pL/2 + uL*c*rho0/2;
103  characteristic[1] = pL/2 - uL*c*rho0/2;
104  //right characteristics
105  characteristic[2] = pR/2 + uR*c*rho0/2;
106  characteristic[3] = pR/2 - uR*c*rho0/2;
107 
108  //take left or right value of characteristic variable
109  for (int j = 0; j < 2; j++)
110  {
111  if (lambda[j] >= 0)
112  {
113  W[j] = characteristic[j];
114  }
115  if (lambda[j] < 0)
116  {
117  W[j] = characteristic[j+2];
118  }
119  }
120 
121  //calculate conservative variables from characteristics
122  NekDouble p = W[0] + W[1];
123  NekDouble u = (W[0] - W[1])/(c*rho0);
124 
125  // assemble the fluxes
126  pF = rho0*u + u0*p/(c*c);
127  uF = p/rho0 + u0*u + v0*vL + w0*wL;
128  vF = 0.0;
129  wF = 0.0;
130 }
131 
132 }
133 
STL namespace.
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 p0, NekDouble rho0, NekDouble u0, NekDouble v0, NekDouble w0, NekDouble &pF, NekDouble &rhoF, NekDouble &uF, NekDouble &vF, NekDouble &wF)
Upwind Riemann solver.
RiemannSolverFactory & GetRiemannSolverFactory()
double NekDouble
std::map< std::string, RSParamFuncType > m_params
Map of parameter function types.
SOLVER_UTILS_EXPORT bool CheckParams(std::string name)
Determine whether a parameter has been defined in m_params.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191