Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EulerADCFE.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File EulerArtificialDiffusionCFE.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 // License for the specific language governing rights and limitations under
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: Euler equations in conservative variables with artificial
33 // diffusion
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
38 #include <boost/algorithm/string.hpp>
39 
40 namespace Nektar
41 {
42  string EulerADCFE::className =
44  "EulerADCFE", EulerADCFE::create,
45  "Euler equations in conservative variables with "
46  "artificial diffusion.");
47 
50  : CompressibleFlowSystem(pSession)
51  {
52  }
53 
55  {
57 
58  if (m_shockCaptureType == "Smooth")
59  {
60  ASSERTL0(m_fields.num_elements() == m_spacedim + 3,
61  "Not enough variables for smooth shock capturing; "
62  "make sure you have added eps to variable list.");
63  m_smoothDiffusion = true;
64  }
65 
66  m_diffusion->SetArtificialDiffusionVector(
68 
69  if(m_session->DefinesSolverInfo("PROBLEMTYPE"))
70  {
71  std::string ProblemTypeStr = m_session->GetSolverInfo("PROBLEMTYPE");
72  int i;
73  for(i = 0; i < (int) SIZE_ProblemType; ++i)
74  {
75  if(boost::iequals(ProblemTypeMap[i], ProblemTypeStr))
76  {
78  break;
79  }
80  }
81  }
82  else
83  {
85  }
86 
88  {
90  DoOdeRhs, this);
92  DoOdeProjection, this);
93  }
94  else
95  {
96  ASSERTL0(false, "Implicit CFE not set up.");
97  }
98  }
99 
101  {
102 
103  }
104 
106  {
109  s, "Problem Type", ProblemTypeMap[m_problemType]);
110  }
111 
113  NekDouble initialtime,
114  bool dumpInitialConditions,
115  const int domain)
116  {
117  EquationSystem::v_SetInitialConditions(initialtime, false);
118 
119  if(dumpInitialConditions)
120  {
121  // Dump initial conditions to file
123  }
124  }
125 
127  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
128  Array<OneD, Array<OneD, NekDouble> > &outarray,
129  const NekDouble time)
130  {
131  int i;
132  int nvariables = inarray.num_elements();
133  int npoints = GetNpoints();
134 
135  Array<OneD, Array<OneD, NekDouble> > advVel;
136  Array<OneD, Array<OneD, NekDouble> > outarrayAdv(nvariables);
137  Array<OneD, Array<OneD, NekDouble> > outarrayDiff(nvariables);
138 
139  for (i = 0; i < nvariables; ++i)
140  {
141  outarrayAdv[i] = Array<OneD, NekDouble>(npoints, 0.0);
142  outarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
143  }
144 
145  m_advection->Advect(nvariables, m_fields, advVel, inarray,
146  outarrayAdv, m_time);
147 
148  for (i = 0; i < nvariables; ++i)
149  {
150  Vmath::Neg(npoints, outarrayAdv[i], 1);
151  }
152 
153  m_diffusion->Diffuse(nvariables, m_fields, inarray, outarrayDiff);
154 
155  if (m_shockCaptureType == "NonSmooth")
156  {
157  for (i = 0; i < nvariables; ++i)
158  {
159  Vmath::Vadd(npoints,
160  outarrayAdv[i], 1,
161  outarrayDiff[i], 1,
162  outarray[i], 1);
163  }
164  }
165  if(m_shockCaptureType == "Smooth")
166  {
167  const Array<OneD, int> ExpOrder = GetNumExpModesPerExp();
168 
169  NekDouble pOrder = Vmath::Vmax(ExpOrder.num_elements(), ExpOrder, 1);
170 
171  Array <OneD, NekDouble > a_vel (npoints, 0.0);
172  Array <OneD, NekDouble > u_abs (npoints, 0.0);
173  Array <OneD, NekDouble > pres (npoints, 0.0);
174  Array <OneD, NekDouble > wave_sp(npoints, 0.0);
175 
176  GetPressure(inarray, pres);
177  GetSoundSpeed(inarray, pres, a_vel);
178  GetAbsoluteVelocity(inarray, u_abs);
179 
180  Vmath::Vadd(npoints, a_vel, 1, u_abs, 1, wave_sp, 1);
181 
182  NekDouble max_wave_sp = Vmath::Vmax(npoints, wave_sp, 1);
183 
184  Vmath::Smul(npoints,
185  m_C2,
186  outarrayDiff[nvariables-1], 1,
187  outarrayDiff[nvariables-1], 1);
188 
189  Vmath::Smul(npoints,
190  max_wave_sp,
191  outarrayDiff[nvariables-1], 1,
192  outarrayDiff[nvariables-1], 1);
193 
194  Vmath::Smul(npoints,
195  pOrder,
196  outarrayDiff[nvariables-1], 1,
197  outarrayDiff[nvariables-1], 1);
198 
199  for (i = 0; i < nvariables; ++i)
200  {
201  Vmath::Vadd(npoints,
202  outarrayAdv[i], 1,
203  outarrayDiff[i], 1,
204  outarray[i], 1);
205  }
206 
207  Array<OneD, Array<OneD, NekDouble> > outarrayForcing(nvariables);
208 
209  for (i = 0; i < nvariables; ++i)
210  {
211  outarrayForcing[i] = Array<OneD, NekDouble>(npoints, 0.0);
212  }
213 
214  GetForcingTerm(inarray, outarrayForcing);
215 
216  for (i = 0; i < nvariables; ++i)
217  {
218  // Add Forcing Term
219  Vmath::Vadd(npoints,
220  outarray[i], 1,
221  outarrayForcing[i], 1,
222  outarray[i], 1);
223  }
224  }
225  }
226 
228  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
229  Array<OneD, Array<OneD, NekDouble> > &outarray,
230  const NekDouble time)
231  {
232  int i;
233  int nvariables = inarray.num_elements();
234 
235  switch(m_projectionType)
236  {
238  {
239  // Just copy over array
240  int npoints = GetNpoints();
241 
242  for(i = 0; i < nvariables; ++i)
243  {
244  Vmath::Vcopy(npoints, inarray[i], 1, outarray[i], 1);
245  }
246  SetBoundaryConditions(outarray, time);
247  break;
248  }
251  {
252  ASSERTL0(false, "No Continuous Galerkin for Euler equations");
253  break;
254  }
255  default:
256  ASSERTL0(false, "Unknown projection scheme");
257  break;
258  }
259  }
260 
262  Array<OneD, Array<OneD, NekDouble> > &inarray,
263  NekDouble time)
264  {
265  std::string varName;
266  int nvariables = m_fields.num_elements();
267  int cnt = 0;
268 
269  // loop over Boundary Regions
270  for (int n = 0; n < m_fields[0]->GetBndConditions().num_elements(); ++n)
271  {
272  // Wall Boundary Condition
273  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
275  {
276  WallBC(n, cnt, inarray);
277  }
278 
279  // Wall Boundary Condition
280  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
282  {
283  ASSERTL0(false, "WallViscous is a wrong bc for the "
284  "Euler equations");
285  }
286 
287  // Symmetric Boundary Condition
288  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
290  {
291  SymmetryBC(n, cnt, inarray);
292  }
293 
294  // Riemann invariant characteristic Boundary Condition (CBC)
295  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
297  {
298  RiemannInvariantBC(n, cnt, inarray);
299  }
300 
301  // Extrapolation of the data at the boundaries
302  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
304  {
305  ExtrapOrder0BC(n, cnt, inarray);
306  }
307 
308  // Time Dependent Boundary Condition (specified in meshfile)
309  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined()
311  {
312  for (int i = 0; i < nvariables; ++i)
313  {
314  varName = m_session->GetVariable(i);
315  m_fields[i]->EvaluateBoundaryConditions(time, varName);
316  }
317  }
318 
319  cnt += m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
320  }
321  }
322 }