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