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