Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
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: Average Riemann solver.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42  std::string AverageSolver::solverName =
44  "Average",
45  AverageSolver::create,
46  "Average Riemann solver");
47 
48  AverageSolver::AverageSolver() : CompressibleSolver()
49  {
50  m_pointSolve = false;
51  }
52 
53  /**
54  * @brief Average Riemann solver.
55  *
56  * @param rhoL Density left state.
57  * @param rhoR Density right state.
58  * @param rhouL x-momentum component left state.
59  * @param rhouR x-momentum component right state.
60  * @param rhovL y-momentum component left state.
61  * @param rhovR y-momentum component right state.
62  * @param rhowL z-momentum component left state.
63  * @param rhowR z-momentum component right state.
64  * @param EL Energy left state.
65  * @param ER Energy right state.
66  * @param rhof Computed Riemann flux for density.
67  * @param rhouf Computed Riemann flux for x-momentum component
68  * @param rhovf Computed Riemann flux for y-momentum component
69  * @param rhowf Computed Riemann flux for z-momentum component
70  * @param Ef Computed Riemann flux for energy.
71  */
73  const Array<OneD, const Array<OneD, NekDouble> > &Fwd,
74  const Array<OneD, const Array<OneD, NekDouble> > &Bwd,
75  Array<OneD, Array<OneD, NekDouble> > &flux)
76  {
77  static NekDouble gamma = m_params["gamma"]();
78 
79  int expDim = Fwd.num_elements()-2;
80  int i, j;
81 
82  for (j = 0; j < Fwd[0].num_elements(); ++j)
83  {
84  NekDouble tmp1 = 0.0, tmp2 = 0.0;
85  Array<OneD, NekDouble> Ufwd(expDim);
86  Array<OneD, NekDouble> Ubwd(expDim);
87 
88  for (i = 0; i < expDim; ++i)
89  {
90  Ufwd[i] = Fwd[i+1][j]/Fwd[0][j];
91  Ubwd[i] = Bwd[i+1][j]/Bwd[0][j];
92  tmp1 += Ufwd[i]*Fwd[i+1][j];
93  tmp2 += Ubwd[i]*Bwd[i+1][j];
94  }
95 
96  NekDouble Pfwd = (gamma - 1.0) * (Fwd[expDim+1][j] - 0.5 * tmp1);
97  NekDouble Pbwd = (gamma - 1.0) * (Bwd[expDim+1][j] - 0.5 * tmp2);
98 
99  // Compute the average flux
100  flux[0][j] = 0.5 * (Fwd[1][j] + Bwd[1][j]);
101  flux[expDim+1][j] = 0.5 * (Ufwd[0] * (Fwd[expDim+1][j] + Pfwd) +
102  Ubwd[0] * (Bwd[expDim+1][j] + Pbwd));
103 
104  for (i = 0; i < expDim; ++i)
105  {
106  flux[i+1][j] = 0.5 * (Fwd[0][j] * Ufwd[0] * Ufwd[i] +
107  Bwd[0][j] * Ubwd[0] * Ubwd[i]);
108  }
109 
110  // Add in pressure contribution to u field
111  flux[1][j] += 0.5 * (Pfwd + Pbwd);
112  }
113  }
114 }