Nektar++
RoeSolver.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: RoeSolver.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: Roe Riemann solver.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
36 
38 
39 namespace Nektar
40 {
41 std::string RoeSolver::solverName =
43  "Roe",
45  "Roe Riemann solver");
46 
48  : CompressibleSolver(pSession)
49 {
50  // m_pointSolve = false;
51 }
52 
53 /// programmatic ctor
55 {
56  // m_pointSolve = false;
57 }
58 
59 /**
60  * @brief Roe Riemann solver.
61  *
62  * Stated equations numbers are from:
63  *
64  * "Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical
65  * Introduction", E. F. Toro (3rd edition, 2009).
66  *
67  * We follow the algorithm prescribed following equation 11.70.
68  *
69  * @param rhoL Density left state.
70  * @param rhoR Density right state.
71  * @param rhouL x-momentum component left state.
72  * @param rhouR x-momentum component right state.
73  * @param rhovL y-momentum component left state.
74  * @param rhovR y-momentum component right state.
75  * @param rhowL z-momentum component left state.
76  * @param rhowR z-momentum component right state.
77  * @param EL Energy left state.
78  * @param ER Energy right state.
79  * @param rhof Computed Riemann flux for density.
80  * @param rhouf Computed Riemann flux for x-momentum component
81  * @param rhovf Computed Riemann flux for y-momentum component
82  * @param rhowf Computed Riemann flux for z-momentum component
83  * @param Ef Computed Riemann flux for energy.
84  */
86  double rhoL, double rhouL, double rhovL, double rhowL, double EL,
87  double rhoR, double rhouR, double rhovR, double rhowR, double ER,
88  double &rhof, double &rhouf, double &rhovf, double &rhowf, double &Ef)
89 {
90  static NekDouble gamma = m_params["gamma"]();
91 
92  RoeKernel(
93  rhoL, rhouL, rhovL, rhowL, EL,
94  rhoR, rhouR, rhovR, rhowR, ER,
95  rhof, rhouf, rhovf, rhowf, Ef,
96  gamma);
97 }
98 
99 
101  const Array<OneD, const Array<OneD, NekDouble> > &fwd,
102  const Array<OneD, const Array<OneD, NekDouble> > &bwd,
104 {
105  static auto gamma = m_params["gamma"]();
106  static auto nVars = fwd.size();
107  static auto spaceDim = nVars-2;
108 
109  using namespace tinysimd;
110  using vec_t = simd<NekDouble>;
111 
112  // get limit of vectorizable chunk
113  size_t sizeScalar = fwd[0].size();
114  size_t sizeVec = (sizeScalar / vec_t::width) * vec_t::width;
115 
116  // SIMD loop
117  size_t i = 0;
118  for (; i < sizeVec; i+=vec_t::width)
119  {
120  vec_t rhoL{}, rhouL{}, rhovL{}, rhowL{}, EL{};
121  vec_t rhoR{}, rhouR{}, rhovR{}, rhowR{}, ER{};
122 
123  // load
124  rhoL.load(&(fwd[0][i]), is_not_aligned);
125  rhouL.load(&(fwd[1][i]), is_not_aligned);
126  EL.load(&(fwd[spaceDim+1][i]), is_not_aligned);
127  rhoR.load(&(bwd[0][i]), is_not_aligned);
128  rhouR.load(&(bwd[1][i]), is_not_aligned);
129  ER.load(&(bwd[spaceDim+1][i]), is_not_aligned);
130 
131  if (spaceDim == 2)
132  {
133  rhovL.load(&(fwd[2][i]), is_not_aligned);
134  rhovR.load(&(bwd[2][i]), is_not_aligned);
135  }
136  else if (spaceDim == 3)
137  {
138  rhovL.load(&(fwd[2][i]), is_not_aligned);
139  rhowL.load(&(fwd[3][i]), is_not_aligned);
140  rhovR.load(&(bwd[2][i]), is_not_aligned);
141  rhowR.load(&(bwd[3][i]), is_not_aligned);
142  }
143 
144  vec_t rhof{}, rhouf{}, rhovf{}, rhowf{}, Ef{};
145 
146  RoeKernel(
147  rhoL, rhouL, rhovL, rhowL, EL,
148  rhoR, rhouR, rhovR, rhowR, ER,
149  rhof, rhouf, rhovf, rhowf, Ef,
150  gamma);
151 
152  // store
153  rhof.store(&(flux[0][i]), is_not_aligned);
154  rhouf.store(&(flux[1][i]), is_not_aligned);
155  Ef.store(&(flux[nVars-1][i]), is_not_aligned);
156  if (spaceDim == 2)
157  {
158  rhovf.store(&(flux[2][i]), is_not_aligned);
159  }
160  else if (spaceDim == 3)
161  {
162  rhovf.store(&(flux[2][i]), is_not_aligned);
163  rhowf.store(&(flux[3][i]), is_not_aligned);
164  }
165 
166  } // avx loop
167 
168 
169  // spillover loop
170  for (; i < sizeScalar; ++i)
171  {
172  NekDouble rhoL{}, rhouL{}, rhovL{}, rhowL{}, EL{};
173  NekDouble rhoR{}, rhouR{}, rhovR{}, rhowR{}, ER{};
174 
175  // load
176  rhoL = fwd[0][i];
177  rhouL = fwd[1][i];
178  EL = fwd[spaceDim+1][i];
179  rhoR = bwd[0][i];
180  rhouR = bwd[1][i];
181  ER = bwd[spaceDim+1][i];
182 
183  if (spaceDim == 2)
184  {
185  rhovL = fwd[2][i];
186  rhovR = bwd[2][i];
187  }
188  else if (spaceDim == 3)
189  {
190  rhovL = fwd[2][i];
191  rhowL = fwd[3][i];
192  rhovR = bwd[2][i];
193  rhowR = bwd[3][i];
194  }
195 
196  NekDouble rhof{}, rhouf{}, rhovf{}, rhowf{}, Ef{};
197 
198  RoeKernel(
199  rhoL, rhouL, rhovL, rhowL, EL,
200  rhoR, rhouR, rhovR, rhowR, ER,
201  rhof, rhouf, rhovf, rhowf, Ef,
202  gamma);
203 
204  // store
205  flux[0][i] = rhof;
206  flux[1][i] = rhouf;
207  flux[nVars-1][i] = Ef;
208  if (spaceDim == 2)
209  {
210  flux[2][i] = rhovf;
211  }
212  else if (spaceDim == 3)
213  {
214  flux[2][i] = rhovf;
215  flux[3][i] = rhowf;
216  }
217 
218  } // loop
219 
220 }
221 
222 } // namespace Nektar
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
void v_PointSolve(ND rhoL, ND rhouL, ND rhovL, ND rhowL, ND EL, ND rhoR, ND rhouR, ND rhovR, ND rhowR, ND ER, ND &rhof, ND &rhouf, ND &rhovf, ND &rhowf, ND &Ef) final
Roe Riemann solver.
Definition: RoeSolver.cpp:85
void v_ArraySolve(const Array< OneD, const Array< OneD, ND > > &Fwd, const Array< OneD, const Array< OneD, ND > > &Bwd, Array< OneD, Array< OneD, ND > > &flux) final
Definition: RoeSolver.cpp:100
RoeSolver()
programmatic ctor
Definition: RoeSolver.cpp:54
static RiemannSolverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: RoeSolver.h:45
static std::string solverName
Definition: RoeSolver.h:52
std::map< std::string, RSParamFuncType > m_params
Map of parameter function types.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
void RoeKernel(T &rhoL, T &rhouL, T &rhovL, T &rhowL, T &EL, T &rhoR, T &rhouR, T &rhovR, T &rhowR, T &ER, T &rhof, T &rhouf, T &rhovf, T &rhowf, T &Ef, NekDouble gamma)
Definition: RoeSolver.h:79
tinysimd::simd< NekDouble > vec_t
double NekDouble
static constexpr struct tinysimd::is_not_aligned_t is_not_aligned
typename abi< ScalarType >::type simd
Definition: tinysimd.hpp:83