Nektar++
RinglebFlow.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File RinglebFlow.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 Ringleb flow
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43  string RinglebFlow::className =
45  "RinglebFlow", RinglebFlow::create,
46  "Euler equations for Ringleb flow.");
47 
48  RinglebFlow::RinglebFlow(
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", "RinglebFlow");
70  }
71 
72  /**
73  * @brief Get the exact solutions for isentropic vortex and Ringleb
74  * flow problems.
75  */
77  unsigned int field,
78  Array<OneD, NekDouble> &outfield,
79  const NekDouble time)
80  {
81  boost::ignore_unused(time);
82  GetExactRinglebFlow( field, outfield);
83  }
84 
85  /**
86  * @brief Compute the exact solution for the Ringleb flow problem.
87  */
89  int field,
90  Array<OneD, NekDouble> &outarray)
91  {
92  int nTotQuadPoints = GetTotPoints();
93 
94  Array<OneD, NekDouble> rho(nTotQuadPoints, 100.0);
95  Array<OneD, NekDouble> rhou(nTotQuadPoints);
96  Array<OneD, NekDouble> rhov(nTotQuadPoints);
97  Array<OneD, NekDouble> E(nTotQuadPoints);
98  Array<OneD, NekDouble> x(nTotQuadPoints);
99  Array<OneD, NekDouble> y(nTotQuadPoints);
100  Array<OneD, NekDouble> z(nTotQuadPoints);
101 
102  m_fields[0]->GetCoords(x, y, z);
103 
104  // Flow parameters
105  NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
106  NekDouble J11, J12, J21, J22, det;
107  NekDouble Fx, Fy;
108  NekDouble xi, yi;
109  NekDouble dV;
110  NekDouble dtheta;
111  NekDouble par1;
112  NekDouble theta = M_PI / 4.0;
113  NekDouble kExt = 0.7;
114  NekDouble V = kExt * sin(theta);
115  NekDouble toll = 1.0e-8;
116  NekDouble errV = 1.0;
117  NekDouble errTheta = 1.0;
118  NekDouble gamma = m_gamma;
119  NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
120 
121  for (int i = 0; i < nTotQuadPoints; ++i)
122  {
123  while ((abs(errV) > toll) || (abs(errTheta) > toll))
124  {
125  VV = V * V;
126  sint = sin(theta);
127  c = sqrt(1.0 - gamma_1_2 * VV);
128  k = V / sint;
129  phi = 1.0 / k;
130  pp = phi * phi;
131  J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
132  1.0 / (5.0 * c * c * c * c * c) -
133  0.5 * log((1.0 + c) / (1.0 - c));
134 
135  r = pow(c, 1.0 / gamma_1_2);
136  xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
137  yi = phi / (r * V) * sqrt(1.0 - VV * pp);
138  par1 = 25.0 - 5.0 * VV;
139  ss = sint * sint;
140 
141  Fx = xi - x[i];
142  Fy = yi - y[i];
143 
144  J11 = 39062.5 / pow(par1, 3.5) * (1.0 / VV - 2.0 / VV * ss) *
145  V + 1562.5 / pow(par1, 2.5) * (-2.0 / (VV * V) + 4.0 /
146  (VV * V) * ss) + 12.5 / pow(par1, 1.5) * V + 312.5 /
147  pow(par1, 2.5) * V + 7812.5 / pow(par1, 3.5) * V -
148  0.25 * (-1.0 / pow(par1, 0.5) * V/(1.0 - 0.2 *
149  pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
150  pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
151  pow(par1, 0.5) * V) / (1.0 + 0.2 * pow(par1, 0.5)) *
152  (1.0 - 0.2 * pow(par1, 0.5));
153 
154  J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
155  J21 = -6250.0 / (VV * V) * sint /
156  pow(par1, 2.5) * pow((1.0 - ss), 0.5) +
157  78125.0 / V * sint / pow(par1, 3.5) *
158  pow((1.0 - ss), 0.5);
159 
160  // the matrix is singular when theta = pi/2
161  if(abs(y[i])<toll && abs(cos(theta))<toll)
162  {
163  J22 = -39062.5 / pow(par1, 3.5) / V + 3125 /
164  pow(par1, 2.5) / (VV * V) + 12.5 / pow(par1, 1.5) *
165  V + 312.5 / pow(par1, 2.5) * V + 7812.5 /
166  pow(par1, 3.5) * V - 0.25 * (-1.0 / pow(par1, 0.5) *
167  V / (1.0 - 0.2 * pow(par1, 0.5)) - (1.0 + 0.2 *
168  pow(par1, 0.5)) / pow((1.0 - 0.2 *
169  pow(par1, 0.5)), 2.0) / pow(par1, 0.5) * V) /
170  (1.0 + 0.2 * pow(par1, 0.5)) * (1.0 - 0.2 *
171  pow(par1,0.5));
172 
173  // dV = -dV/dx * Fx
174  dV = -1.0 / J22 * Fx;
175  dtheta = 0.0;
176  theta = M_PI / 2.0;
177  }
178  else
179  {
180  J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
181  pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
182  pow(par1, 2.5) / pow((1.0 - ss), 0.5) * cos(theta);
183 
184  det = -1.0 / (J11 * J22 - J12 * J21);
185 
186  // [dV dtheta]' = -[invJ]*[Fx Fy]'
187  dV = det * ( J22 * Fx - J12 * Fy);
188  dtheta = det * (-J21 * Fx + J11 * Fy);
189  }
190 
191  V = V + dV;
192  theta = theta + dtheta;
193 
194  errV = abs(dV);
195  errTheta = abs(dtheta);
196 
197  }
198 
199  c = sqrt(1.0 - gamma_1_2 * VV);
200  r = pow(c, 1.0 / gamma_1_2);
201 
202  rho[i] = r;
203  rhou[i] = rho[i] * V * cos(theta);
204  rhov[i] = rho[i] * V * sin(theta);
205  P = (c * c) * rho[i] / gamma;
206  E[i] = P / (gamma - 1.0) + 0.5 *
207  (rhou[i] * rhou[i] / rho[i] + rhov[i] * rhov[i] / rho[i]);
208 
209  // Resetting the guess value
210  errV = 1.0;
211  errTheta = 1.0;
212  theta = M_PI/4.0;
213  V = kExt*sin(theta);
214  }
215 
216  switch (field)
217  {
218  case 0:
219  outarray = rho;
220  break;
221  case 1:
222  outarray = rhou;
223  break;
224  case 2:
225  outarray = rhov;
226  break;
227  case 3:
228  outarray = E;
229  break;
230  default:
231  ASSERTL0(false, "Error in variable number!");
232  break;
233  }
234  }
235 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
STL namespace.
SOLVER_UTILS_EXPORT int GetTotPoints()
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
Base class for unsteady solvers.
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:49
void GetExactRinglebFlow(int field, Array< OneD, NekDouble > &outarray)
Ringleb Flow Test Case.
Definition: RinglebFlow.cpp:88
double NekDouble
EquationSystemFactory & GetEquationSystemFactory()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
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.
Definition: RinglebFlow.cpp:76
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
Definition: RinglebFlow.cpp:66
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual ~RinglebFlow()
Destructor for EulerCFE class.
Definition: RinglebFlow.cpp:59