Nektar++
IsentropicVortex.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File IsentropicVortex.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: Euler equations for isentropic vortex
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43  string IsentropicVortex::className =
45  "IsentropicVortex", IsentropicVortex::create,
46  "Euler equations for the isentropic vortex test case.");
47 
48  IsentropicVortex::IsentropicVortex(
51  : UnsteadySystem(pSession, pGraph),
52  EulerCFE(pSession, pGraph)
53  {
54  }
55 
56  /**
57  * @brief Destructor for EulerCFE class.
58  */
60  {
61  }
62 
63  /**
64  * @brief Print out a summary with some relevant information.
65  */
67  {
69  SolverUtils::AddSummaryItem(s, "Problem Type", "Isentropic Vortex");
70  }
71 
72  /**
73  * @brief Set the initial conditions.
74  */
76  NekDouble initialtime,
77  bool dumpInitialConditions,
78  const int domain)
79  {
80  boost::ignore_unused(domain);
81 
82  int nTotQuadPoints = GetTotPoints();
83  Array<OneD, NekDouble> x(nTotQuadPoints);
84  Array<OneD, NekDouble> y(nTotQuadPoints);
85  Array<OneD, NekDouble> z(nTotQuadPoints);
87 
88  m_fields[0]->GetCoords(x, y, z);
89 
90  for (int i = 0; i < m_spacedim + 2; ++i)
91  {
92  u[i] = Array<OneD, NekDouble>(nTotQuadPoints);
93  }
94 
95  EvaluateIsentropicVortex(x, y, z, u, initialtime);
96 
97  // Forward transform to fill the coefficient space
98  for(int i = 0; i < m_fields.size(); ++i)
99  {
100  Vmath::Vcopy(nTotQuadPoints, u[i], 1, m_fields[i]->UpdatePhys(), 1);
101  m_fields[i]->SetPhysState(true);
102  m_fields[i]->FwdTrans(m_fields[i]->GetPhys(),
103  m_fields[i]->UpdateCoeffs());
104  }
105 
106  if (dumpInitialConditions && m_checksteps)
107  {
108  // Dump initial conditions to file
110  }
111  }
112 
113  /**
114  * @brief Get the exact solutions for isentropic vortex and Ringleb
115  * flow problems.
116  */
118  unsigned int field,
119  Array<OneD, NekDouble> &outfield,
120  const NekDouble time)
121  {
122  int nTotQuadPoints = GetTotPoints();
123  Array<OneD, NekDouble> x(nTotQuadPoints);
124  Array<OneD, NekDouble> y(nTotQuadPoints);
125  Array<OneD, NekDouble> z(nTotQuadPoints);
127 
128  m_fields[0]->GetCoords(x, y, z);
129 
130  for (int i = 0; i < m_spacedim + 2; ++i)
131  {
132  u[i] = Array<OneD, NekDouble>(nTotQuadPoints);
133  }
134 
135  EvaluateIsentropicVortex(x, y, z, u, time);
136 
137  Vmath::Vcopy(nTotQuadPoints, u[field], 1, outfield, 1);
138  }
139 
141  const Array<OneD, NekDouble> &x,
142  const Array<OneD, NekDouble> &y,
143  const Array<OneD, NekDouble> &z,
145  NekDouble time,
146  const int o)
147  {
148  boost::ignore_unused(z);
149 
150  int nq = x.size();
151 
152  // Flow parameters
153  const NekDouble x0 = 5.0;
154  const NekDouble y0 = 0.0;
155  const NekDouble beta = 5.0;
156  const NekDouble u0 = 1.0;
157  const NekDouble v0 = 0.5;
158  const NekDouble gamma = m_gamma;
159  NekDouble r, xbar, ybar, tmp;
160  NekDouble fac = 1.0/(16.0*gamma*M_PI*M_PI);
161 
162  // In 3D zero rhow field.
163  if (m_spacedim == 3)
164  {
165  Vmath::Zero(nq, &u[3][o], 1);
166  }
167 
168  // Fill storage
169  for (int i = 0; i < nq; ++i)
170  {
171  xbar = x[i] - u0*time - x0;
172  ybar = y[i] - v0*time - y0;
173  r = sqrt(xbar*xbar + ybar*ybar);
174  tmp = beta*exp(1-r*r);
175  u[0][i+o] = pow(1.0 - (gamma-1.0)*tmp*tmp*fac, 1.0/(gamma-1.0));
176  u[1][i+o] = u[0][i+o]*(u0 - tmp*ybar/(2*M_PI));
177  u[2][i+o] = u[0][i+o]*(v0 + tmp*xbar/(2*M_PI));
178  u[m_spacedim+1][i+o] = pow(u[0][i+o], gamma)/(gamma-1.0) +
179  0.5*(u[1][i+o]*u[1][i+o] + u[2][i+o]*u[2][i+o]) / u[0][i+o];
180  }
181  }
182 
183 }
virtual ~IsentropicVortex()
Destructor for EulerCFE class.
void EvaluateIsentropicVortex(const Array< OneD, NekDouble > &x, const Array< OneD, NekDouble > &y, const Array< OneD, NekDouble > &z, Array< OneD, Array< OneD, NekDouble > > &u, NekDouble time, const int o=0)
Isentropic Vortex Test Case.
virtual void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time=0.0)
Get the exact solutions for isentropic vortex and Ringleb flow problems.
virtual void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Set the initial conditions.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
int m_spacedim
Spatial dimension (>= expansion dim).
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT int GetTotPoints()
Base class for unsteady solvers.
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:47
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267