Nektar++
RiemannSolvers/AcousticSolver.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: AcousticSolver.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: Riemann solver base classs for the APE equations.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43 /**
44  *
45  */
46 AcousticSolver::AcousticSolver(
48  : RiemannSolver(pSession)
49 {
50  m_requiresRotation = true;
51 }
52 
53 /**
54  *
55  */
57  const int nDim, const Array<OneD, const Array<OneD, NekDouble>> &Fwd,
58  const Array<OneD, const Array<OneD, NekDouble>> &Bwd,
60 {
61  int nTracePts = Fwd[0].size();
62 
63  Array<OneD, Array<OneD, NekDouble>> bfFwd(nDim + 2);
64  Array<OneD, Array<OneD, NekDouble>> bfBwd(nDim + 2);
65  for (int i = 0; i < nDim + 2; i++)
66  {
67  bfFwd[i] = Array<OneD, NekDouble>(nTracePts);
68  bfBwd[i] = Array<OneD, NekDouble>(nTracePts);
69  }
70 
71  GetRotBasefield(bfFwd, bfBwd);
72 
73  int expDim = nDim;
74  NekDouble vF, wF, rhoF;
75 
76  if (expDim == 1)
77  {
78  for (int i = 0; i < nTracePts; ++i)
79  {
80  v_PointSolve(Fwd[0][i], 0.0, Fwd[1][i], 0.0, 0.0, Bwd[0][i], 0.0,
81  Bwd[1][i], 0.0, 0.0, bfFwd[0][i], bfFwd[1][i],
82  bfFwd[2][i], 0.0, 0.0, bfBwd[0][i], bfBwd[1][i],
83  bfBwd[2][i], 0.0, 0.0, flux[0][i], rhoF, flux[1][i],
84  vF, wF);
85  }
86  }
87  else if (expDim == 2)
88  {
89  for (int i = 0; i < nTracePts; ++i)
90  {
91  v_PointSolve(Fwd[0][i], 0.0, Fwd[1][i], Fwd[2][i], 0.0, Bwd[0][i],
92  0.0, Bwd[1][i], Bwd[2][i], 0.0, bfFwd[0][i],
93  bfFwd[1][i], bfFwd[2][i], bfFwd[3][i], 0.0,
94  bfBwd[0][i], bfBwd[1][i], bfBwd[2][i], bfBwd[3][i],
95  0.0, flux[0][i], rhoF, flux[1][i], flux[2][i], wF);
96  }
97  }
98  else if (expDim == 3)
99  {
100  for (int i = 0; i < nTracePts; ++i)
101  {
102  v_PointSolve(Fwd[0][i], 0.0, Fwd[1][i], Fwd[2][i], Fwd[3][i],
103  Bwd[0][i], 0.0, Bwd[1][i], Bwd[2][i], Bwd[3][i],
104  bfFwd[0][i], bfFwd[1][i], bfFwd[2][i], bfFwd[3][i],
105  bfFwd[4][i], bfBwd[0][i], bfBwd[1][i], bfBwd[2][i],
106  bfBwd[3][i], bfBwd[4][i], flux[0][i], rhoF, flux[1][i],
107  flux[2][i], flux[3][i]);
108  }
109  }
110 }
111 
112 /**
113  *
114  */
117 {
118  ASSERTL1(CheckVectors("N"), "N not defined.");
119  ASSERTL1(CheckVectors("basefieldFwdBwd"), "basefieldFwdBwd not defined.");
120  const Array<OneD, const Array<OneD, NekDouble>> normals = m_vectors["N"]();
121  const Array<OneD, const Array<OneD, NekDouble>> basefieldFwdBwd =
122  m_vectors["basefieldFwdBwd"]();
123 
124  int nBF = basefieldFwdBwd.size() / 2;
125  int nDim = normals.size();
126 
127  Array<OneD, Array<OneD, NekDouble>> basefieldFwd(nBF);
128  Array<OneD, Array<OneD, NekDouble>> basefieldBwd(nBF);
129 
130  for (int i = 0; i < nBF; i++)
131  {
132  int j = nBF + i;
133  basefieldFwd[i] = basefieldFwdBwd[i];
134  basefieldBwd[i] = basefieldFwdBwd[j];
135  }
136 
137  Array<OneD, Array<OneD, NekDouble>> baseVecLocs(1);
138  baseVecLocs[0] = Array<OneD, NekDouble>(nDim);
139  for (int i = 0; i < nDim; ++i)
140  {
141  baseVecLocs[0][i] = i + 2;
142  }
143  rotateToNormal(basefieldFwd, normals, baseVecLocs, bfFwd);
144  rotateToNormal(basefieldBwd, normals, baseVecLocs, bfBwd);
145 }
146 
147 } // namespace Nektar
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
void GetRotBasefield(Array< OneD, Array< OneD, NekDouble >> &bfFwd, Array< OneD, Array< OneD, NekDouble >> &bfBwd)
virtual void v_Solve(const int nDim, const Array< OneD, const Array< OneD, NekDouble >> &Fwd, const Array< OneD, const Array< OneD, NekDouble >> &Bwd, Array< OneD, Array< OneD, NekDouble >> &flux) override
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)=0
The RiemannSolver class provides an abstract interface under which solvers for various Riemann proble...
Definition: RiemannSolver.h:58
SOLVER_UTILS_EXPORT void rotateToNormal(const Array< OneD, const Array< OneD, NekDouble >> &inarray, const Array< OneD, const Array< OneD, NekDouble >> &normals, const Array< OneD, const Array< OneD, NekDouble >> &vecLocs, Array< OneD, Array< OneD, NekDouble >> &outarray)
Rotate a vector field to trace normal.
bool m_requiresRotation
Indicates whether the Riemann solver requires a rotation to be applied to the velocity fields.
std::map< std::string, RSVecFuncType > m_vectors
Map of vector function types.
SOLVER_UTILS_EXPORT bool CheckVectors(std::string name)
Determine whether a vector has been defined in m_vectors.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble