Nektar++
UnsteadyAdvectionDiffusion.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File UnsteadyAdvectionDiffusion.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: Unsteady advection-diffusion solve routines
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <iostream>
36 
37 #include <boost/core/ignore_unused.hpp>
38 
40 
41 using namespace std;
42 
43 namespace Nektar
44 {
45  string UnsteadyAdvectionDiffusion::className
47  "UnsteadyAdvectionDiffusion",
48  UnsteadyAdvectionDiffusion::create);
49 
50  UnsteadyAdvectionDiffusion::UnsteadyAdvectionDiffusion(
53  : UnsteadySystem(pSession, pGraph),
54  AdvectionSystem(pSession, pGraph)
55  {
56  m_planeNumber = 0;
57  }
58 
59  /**
60  * @brief Initialisation object for the unsteady linear advection
61  * diffusion equation.
62  */
64  {
66 
67  m_session->LoadParameter("wavefreq", m_waveFreq, 0.0);
68  m_session->LoadParameter("epsilon", m_epsilon, 0.0);
69 
70  // turn on substepping
71  m_session->MatchSolverInfo("Extrapolation", "SubStepping",
72  m_subSteppingScheme, false);
73 
74  // Define Velocity fields
76  std::vector<std::string> vel;
77  vel.push_back("Vx");
78  vel.push_back("Vy");
79  vel.push_back("Vz");
80  vel.resize(m_spacedim);
81 
82  GetFunction( "AdvectionVelocity")->Evaluate(vel, m_velocity);
83 
84  m_session->MatchSolverInfo(
85  "SpectralVanishingViscosity", "True", m_useSpecVanVisc, false);
86 
88  {
89  m_session->LoadParameter("SVVCutoffRatio",m_sVVCutoffRatio,0.75);
90  m_session->LoadParameter("SVVDiffCoeff",m_sVVDiffCoeff,0.1);
91  }
92 
93  // Type of advection and diffusion classes to be used
94  switch(m_projectionType)
95  {
96  // Discontinuous field
98  {
99  // Do not forwards transform initial condition
100  m_homoInitialFwd = false;
101 
102  // Advection term
103  string advName;
104  string riemName;
105  m_session->LoadSolverInfo("AdvectionType", advName, "WeakDG");
107  CreateInstance(advName, advName);
108  m_advObject->SetFluxVector(&UnsteadyAdvectionDiffusion::
109  GetFluxVectorAdv, this);
110  m_session->LoadSolverInfo("UpwindType", riemName, "Upwind");
112  CreateInstance(riemName, m_session);
113  m_riemannSolver->SetScalar("Vn", &UnsteadyAdvectionDiffusion::
114  GetNormalVelocity, this);
115  m_advObject->SetRiemannSolver(m_riemannSolver);
116  m_advObject->InitObject (m_session, m_fields);
117 
118  // Diffusion term
120  {
121  std::string diffName;
122  m_session->LoadSolverInfo("DiffusionType", diffName, "LDG");
124  CreateInstance(diffName, diffName);
125  m_diffusion->SetFluxVector(&UnsteadyAdvectionDiffusion::
126  GetFluxVectorDiff, this);
127  m_diffusion->InitObject(m_session, m_fields);
128  }
129 
130  ASSERTL0(m_subSteppingScheme == false,"SubSteppingScheme is not set up for DG projection");
131  break;
132  }
133  // Continuous field
136  {
137  // Advection term
138  std::string advName;
139  m_session->LoadSolverInfo("AdvectionType", advName,
140  "NonConservative");
142  CreateInstance(advName, advName);
143  m_advObject->SetFluxVector(&UnsteadyAdvectionDiffusion::
144  GetFluxVectorAdv, this);
145 
146  if(advName.compare("WeakDG") == 0)
147  {
148  string riemName;
149  m_session->LoadSolverInfo("UpwindType", riemName, "Upwind");
151  CreateInstance(riemName, m_session);
152  m_riemannSolver->SetScalar("Vn",
154  GetNormalVelocity, this);
155  m_advObject->SetRiemannSolver(m_riemannSolver);
156  m_advObject->InitObject (m_session, m_fields);
157  }
158 
159  // In case of Galerkin explicit diffusion gives an error
161  {
162  ASSERTL0(false, "Explicit Galerkin diffusion not set up.");
163  }
164  // In case of Galerkin implicit diffusion: do nothing
165  break;
166  }
167  default:
168  {
169  ASSERTL0(false, "Unsupported projection type.");
170  break;
171  }
172  }
173 
179 
180  if(m_subSteppingScheme) // Substepping
181  {
183  "Projection must be set to Mixed_CG_Discontinuous for "
184  "substepping");
186  m_intScheme->GetIntegrationMethod(), m_intScheme);
187  }
188  }
189 
190  /**
191  * @brief Unsteady linear advection diffusion equation destructor.
192  */
194  {
195  }
196 
197  /**
198  * @brief Get the normal velocity for the unsteady linear advection
199  * diffusion equation.
200  */
202  {
203  return GetNormalVel(m_velocity);
204  }
205 
206 
208  const Array<OneD, const Array<OneD, NekDouble> > &velfield)
209  {
210  // Number of trace (interface) points
211  int i;
212  int nTracePts = GetTraceNpoints();
213 
214  // Auxiliary variable to compute the normal velocity
215  Array<OneD, NekDouble> tmp(nTracePts);
216  m_traceVn = Array<OneD, NekDouble>(nTracePts, 0.0);
217 
218  // Reset the normal velocity
219  Vmath::Zero(nTracePts, m_traceVn, 1);
220 
221  for (i = 0; i < velfield.num_elements(); ++i)
222  {
223  m_fields[0]->ExtractTracePhys(velfield[i], tmp);
224 
225  Vmath::Vvtvp(nTracePts,
226  m_traceNormals[i], 1,
227  tmp, 1,
228  m_traceVn, 1,
229  m_traceVn, 1);
230  }
231 
232  return m_traceVn;
233  }
234 
235  /**
236  * @brief Compute the right-hand side for the unsteady linear advection
237  * diffusion problem.
238  *
239  * @param inarray Given fields.
240  * @param outarray Calculated solution.
241  * @param time Time.
242  */
244  const Array<OneD, const Array<OneD, NekDouble> >&inarray,
245  Array<OneD, Array<OneD, NekDouble> >&outarray,
246  const NekDouble time)
247  {
248  // Number of fields (variables of the problem)
249  int nVariables = inarray.num_elements();
250 
251  // Number of solution points
252  int nSolutionPts = GetNpoints();
253 
254  // RHS computation using the new advection base class
255  m_advObject->Advect(nVariables, m_fields, m_velocity,
256  inarray, outarray, time);
257 
258  // Negate the RHS
259  for (int i = 0; i < nVariables; ++i)
260  {
261  Vmath::Neg(nSolutionPts, outarray[i], 1);
262  }
263 
265  {
266  Array<OneD, Array<OneD, NekDouble> > outarrayDiff(nVariables);
267  for (int i = 0; i < nVariables; ++i)
268  {
269  outarrayDiff[i] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
270  }
271 
272  m_diffusion->Diffuse(nVariables, m_fields, inarray, outarrayDiff);
273 
274  for (int i = 0; i < nVariables; ++i)
275  {
276  Vmath::Vadd(nSolutionPts, &outarrayDiff[i][0], 1,
277  &outarray[i][0], 1, &outarray[i][0], 1);
278  }
279  }
280 
281  }
282 
283  /**
284  * @brief Compute the projection for the unsteady advection
285  * diffusion problem.
286  *
287  * @param inarray Given fields.
288  * @param outarray Calculated solution.
289  * @param time Time.
290  */
292  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
293  Array<OneD, Array<OneD, NekDouble> > &outarray,
294  const NekDouble time)
295  {
296  int i;
297  int nvariables = inarray.num_elements();
298  SetBoundaryConditions(time);
299  switch(m_projectionType)
300  {
302  {
303  // Just copy over array
304  int npoints = GetNpoints();
305 
306  for(i = 0; i < nvariables; ++i)
307  {
308  Vmath::Vcopy(npoints, inarray[i], 1, outarray[i], 1);
309  }
310  break;
311  }
314  {
316 
317  for(i = 0; i < nvariables; ++i)
318  {
319  m_fields[i]->FwdTrans(inarray[i], coeffs);
320  m_fields[i]->BwdTrans_IterPerExp(coeffs, outarray[i]);
321  }
322  break;
323  }
324  default:
325  {
326  ASSERTL0(false, "Unknown projection scheme");
327  break;
328  }
329  }
330  }
331 
332 
333  /* @brief Compute the diffusion term implicitly.
334  *
335  * @param inarray Given fields.
336  * @param outarray Calculated solution.
337  * @param time Time.
338  * @param lambda Diffusion coefficient.
339  */
341  const Array<OneD, const Array<OneD, NekDouble> >&inarray,
342  Array<OneD, Array<OneD, NekDouble> >&outarray,
343  const NekDouble time,
344  const NekDouble lambda)
345  {
346  int nvariables = inarray.num_elements();
347  int nq = m_fields[0]->GetNpoints();
348 
350  factors[StdRegions::eFactorLambda] = 1.0/lambda/m_epsilon;
351 
352  if(m_useSpecVanVisc)
353  {
356  }
358  {
359  factors[StdRegions::eFactorTau] = 1.0;
360  }
361 
362  Array<OneD, Array< OneD, NekDouble> > F(nvariables);
363  for (int n = 0; n < nvariables; ++n)
364  {
365  F[n] = Array<OneD, NekDouble> (nq);
366  }
367 
368  // We solve ( \nabla^2 - HHlambda ) Y[i] = rhs [i]
369  // inarray = input: \hat{rhs} -> output: \hat{Y}
370  // outarray = output: nabla^2 \hat{Y}
371  // where \hat = modal coeffs
372  for (int i = 0; i < nvariables; ++i)
373  {
374  // Multiply 1.0/timestep/lambda
376  inarray[i], 1, F[i], 1);
377  }
378 
379  //Setting boundary conditions
380  SetBoundaryConditions(time);
381 
382  for (int i = 0; i < nvariables; ++i)
383  {
384  // Solve a system of equations with Helmholtz solver
385  m_fields[i]->HelmSolve(F[i], m_fields[i]->UpdateCoeffs(),
386  NullFlagList, factors);
387 
388  m_fields[i]->BwdTrans(m_fields[i]->GetCoeffs(), outarray[i]);
389  }
390  }
391 
392  /**
393  * @brief Return the flux vector for the advection part.
394  *
395  * @param physfield Fields.
396  * @param flux Resulting flux.
397  */
399  const Array<OneD, Array<OneD, NekDouble> > &physfield,
401  {
402  ASSERTL1(flux[0].num_elements() == m_velocity.num_elements(),
403  "Dimension of flux array and velocity array do not match");
404 
405  const int nq = m_fields[0]->GetNpoints();
406 
407  for (int i = 0; i < flux.num_elements(); ++i)
408  {
409  for (int j = 0; j < flux[0].num_elements(); ++j)
410  {
411  Vmath::Vmul(nq, physfield[i], 1, m_velocity[j], 1,
412  flux[i][j], 1);
413  }
414  }
415  }
416 
417  /**
418  * @brief Return the flux vector for the diffusion part.
419  *
420  * @param i Equation number.
421  * @param j Spatial direction.
422  * @param physfield Fields.
423  * @param derivatives First order derivatives.
424  * @param flux Resulting flux.
425  */
427  const Array<OneD, Array<OneD, NekDouble> > &inarray,
428  const Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&qfield,
429  Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&viscousTensor)
430  {
431  boost::ignore_unused(inarray);
432 
433  unsigned int nDim = qfield.num_elements();
434  unsigned int nConvectiveFields = qfield[0].num_elements();
435  unsigned int nPts = qfield[0][0].num_elements();
436  for (unsigned int j = 0; j < nDim; ++j)
437  {
438  for (unsigned int i = 0; i < nConvectiveFields; ++i)
439  {
440  Vmath::Smul(nPts, m_epsilon, qfield[j][i], 1,
441  viscousTensor[j][i], 1 );
442  }
443  }
444  }
445 
448  {
450  }
451 
452 
453  /**
454  * Perform the extrapolation.
455  */
457  {
459  {
461  }
462 
463  return false;
464  }
465 
466 
467  /**
468  *
469  */
471  const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln,
472  int nstep,
473  NekDouble time)
474  {
475  int n;
476  int nsubsteps;
477 
478  NekDouble dt;
479 
480  Array<OneD, Array<OneD, NekDouble> > fields, velfields;
481 
482  static int ncalls = 1;
483  int nint = min(ncalls++, m_intSteps);
484 
487 
488  LibUtilities::CommSharedPtr comm = m_session->GetComm();
489 
490  // Get the proper time step with CFL control
491  dt = GetSubstepTimeStep();
492 
493  nsubsteps = (m_timestep > dt)? ((int)(m_timestep/dt)+1):1;
494  nsubsteps = max(m_minsubsteps, nsubsteps);
495 
496  dt = m_timestep/nsubsteps;
497 
498  if (m_infosteps && !((nstep+1)%m_infosteps) && comm->GetRank() == 0)
499  {
500  cout << "Sub-integrating using "<< nsubsteps
501  << " steps over Dt = " << m_timestep
502  << " (SubStep CFL=" << m_cflSafetyFactor << ")"<< endl;
503  }
504 
505  for (int m = 0; m < nint; ++m)
506  {
507  // We need to update the fields held by the m_integrationSoln
508  fields = integrationSoln->UpdateSolutionVector()[m];
509 
510  // Initialise NS solver which is set up to use a GLM method
511  // with calls to EvaluateAdvection_SetPressureBCs and
512  // SolveUnsteadyStokesSystem
514  SubIntegrationSoln = m_subStepIntegrationScheme->
515  InitializeScheme(dt, fields, time, m_subStepIntegrationOps);
516 
517  for(n = 0; n < nsubsteps; ++n)
518  {
519  fields = m_subStepIntegrationScheme->TimeIntegrate(n, dt, SubIntegrationSoln,
521  }
522 
523  // Reset time integrated solution in m_integrationSoln
524  integrationSoln->SetSolVector(m,fields);
525  }
526  }
527 
528 
529  /**
530  *
531  */
533  {
534  int n_element = m_fields[0]->GetExpSize();
535 
536  const Array<OneD, int> ExpOrder=m_fields[0]->EvalBasisNumModesMaxPerExp();
537  Array<OneD, int> ExpOrderList (n_element, ExpOrder);
538 
539  const NekDouble cLambda = 0.2; // Spencer book pag. 317
540 
541  Array<OneD, NekDouble> tstep (n_element, 0.0);
542  Array<OneD, NekDouble> stdVelocity(n_element, 0.0);
543 
544  stdVelocity = GetMaxStdVelocity(m_velocity);
545 
546  for(int el = 0; el < n_element; ++el)
547  {
548  tstep[el] = m_cflSafetyFactor /
549  (stdVelocity[el] * cLambda *
550  (ExpOrder[el]-1) * (ExpOrder[el]-1));
551  }
552 
553  NekDouble TimeStep = Vmath::Vmin(n_element, tstep, 1);
554  m_session->GetComm()->AllReduce(TimeStep,LibUtilities::ReduceMin);
555 
556  return TimeStep;
557  }
558 
560  int intMethod,
561  const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme)
562  {
563  // Set to 1 for first step and it will then be increased in
564  // time advance routines
565  switch(intMethod)
566  {
569  {
571 
572  }
573  break;
575  {
577  }
578  break;
579  default:
580  ASSERTL0(0,"Integration method not suitable: Options include BackwardEuler or BDFImplicitOrder1");
581  break;
582  }
583  m_intSteps = IntegrationScheme->GetIntegrationSteps();
584 
585  // set explicit time-integration class operators
588  }
589 
590  /**
591  * Explicit Advection terms used by SubStepAdvance time integration
592  */
594  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
595  Array<OneD, Array<OneD, NekDouble> > &outarray,
596  const NekDouble time)
597  {
598  int i;
599  int nVariables = inarray.num_elements();
600 
601  /// Get the number of coefficients
602  int ncoeffs = m_fields[0]->GetNcoeffs();
603 
604  /// Define an auxiliary variable to compute the RHS
605  Array<OneD, Array<OneD, NekDouble> > WeakAdv(nVariables);
606  WeakAdv[0] = Array<OneD, NekDouble> (ncoeffs*nVariables);
607  for(i = 1; i < nVariables; ++i)
608  {
609  WeakAdv[i] = WeakAdv[i-1] + ncoeffs;
610  }
611 
612  // Currently assume velocity field is time independent and does not therefore
613  // need extrapolating.
614  // RHS computation using the advection base class
615  m_advObject->Advect(nVariables, m_fields, m_velocity,
616  inarray, outarray, time);
617 
618  for(i = 0; i < nVariables; ++i)
619  {
620  m_fields[i]->IProductWRTBase(outarray[i],WeakAdv[i]);
621  // negation requried due to sign of DoAdvection term to be consistent
622  Vmath::Neg(ncoeffs, WeakAdv[i], 1);
623  }
624 
625  AddAdvectionPenaltyFlux(m_velocity, inarray, WeakAdv);
626 
627 
628  /// Operations to compute the RHS
629  for(i = 0; i < nVariables; ++i)
630  {
631  // Negate the RHS
632  Vmath::Neg(ncoeffs, WeakAdv[i], 1);
633 
634  /// Multiply the flux by the inverse of the mass matrix
635  m_fields[i]->MultiplyByElmtInvMass(WeakAdv[i], WeakAdv[i]);
636 
637  /// Store in outarray the physical values of the RHS
638  m_fields[i]->BwdTrans(WeakAdv[i], outarray[i]);
639  }
640  }
641 
642  /**
643  * Projection used by SubStepAdvance time integration
644  */
646  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
647  Array<OneD, Array<OneD, NekDouble> > &outarray,
648  const NekDouble time)
649  {
650  boost::ignore_unused(time);
651 
652  ASSERTL1(inarray.num_elements() == outarray.num_elements(),"Inarray and outarray of different sizes ");
653 
654  for(int i = 0; i < inarray.num_elements(); ++i)
655  {
656  Vmath::Vcopy(inarray[i].num_elements(),inarray[i],1,outarray[i],1);
657  }
658  }
659 
661  const Array<OneD, const Array<OneD, NekDouble> > &velfield,
662  const Array<OneD, const Array<OneD, NekDouble> > &physfield,
663  Array<OneD, Array<OneD, NekDouble> > &Outarray)
664  {
665  ASSERTL1(physfield.num_elements() == Outarray.num_elements(),
666  "Physfield and outarray are of different dimensions");
667 
668  int i;
669 
670  /// Number of trace points
671  int nTracePts = m_fields[0]->GetTrace()->GetNpoints();
672 
673  /// Forward state array
674  Array<OneD, NekDouble> Fwd(3*nTracePts);
675 
676  /// Backward state array
677  Array<OneD, NekDouble> Bwd = Fwd + nTracePts;
678 
679  /// upwind numerical flux state array
680  Array<OneD, NekDouble> numflux = Bwd + nTracePts;
681 
682  /// Normal velocity array
683  Array<OneD, NekDouble> Vn = GetNormalVel(velfield);
684 
685  for(i = 0; i < physfield.num_elements(); ++i)
686  {
687  /// Extract forwards/backwards trace spaces
688  /// Note: Needs to have correct i value to get boundary conditions
689  m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);
690 
691  /// Upwind between elements
692  m_fields[0]->GetTrace()->Upwind(Vn, Fwd, Bwd, numflux);
693 
694  /// Construct difference between numflux and Fwd,Bwd
695  Vmath::Vsub(nTracePts, numflux, 1, Fwd, 1, Fwd, 1);
696  Vmath::Vsub(nTracePts, numflux, 1, Bwd, 1, Bwd, 1);
697 
698  /// Calculate the numerical fluxes multipling Fwd, Bwd and
699  /// numflux by the normal advection velocity
700  Vmath::Vmul(nTracePts, Fwd, 1, Vn, 1, Fwd, 1);
701  Vmath::Vmul(nTracePts, Bwd, 1, Vn, 1, Bwd, 1);
702 
703  m_fields[0]->AddFwdBwdTraceIntegral(Fwd,Bwd,Outarray[i]);
704  }
705  }
706 
707 
709  const Array<OneD, Array<OneD,NekDouble> > inarray)
710  {
711 
712  int n_points_0 = m_fields[0]->GetExp(0)->GetTotPoints();
713  int n_element = m_fields[0]->GetExpSize();
714  int nvel = inarray.num_elements();
715  int cnt;
716 
717  ASSERTL0(nvel >= 2, "Method not implemented for 1D");
718 
719  NekDouble pntVelocity;
720 
721  // Getting the standard velocity vector on the 2D normal space
722  Array<OneD, Array<OneD, NekDouble> > stdVelocity(nvel);
723  Array<OneD, NekDouble> maxV(n_element, 0.0);
725 
726  for (int i = 0; i < nvel; ++i)
727  {
728  stdVelocity[i] = Array<OneD, NekDouble>(n_points_0);
729  }
730 
731  if (nvel == 2)
732  {
733  cnt = 0.0;
734  for (int el = 0; el < n_element; ++el)
735  {
736  int n_points = m_fields[0]->GetExp(el)->GetTotPoints();
737  ptsKeys = m_fields[0]->GetExp(el)->GetPointsKeys();
738 
739  // reset local space if necessary
740  if(n_points != n_points_0)
741  {
742  for (int j = 0; j < nvel; ++j)
743  {
744  stdVelocity[j] = Array<OneD, NekDouble>(n_points);
745  }
746  n_points_0 = n_points;
747  }
748 
750  m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetDerivFactors(ptsKeys);
751 
752  if (m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetGtype()
754  {
755  for (int i = 0; i < n_points; i++)
756  {
757  stdVelocity[0][i] = gmat[0][i]*inarray[0][i+cnt]
758  + gmat[2][i]*inarray[1][i+cnt];
759 
760  stdVelocity[1][i] = gmat[1][i]*inarray[0][i+cnt]
761  + gmat[3][i]*inarray[1][i+cnt];
762  }
763  }
764  else
765  {
766  for (int i = 0; i < n_points; i++)
767  {
768  stdVelocity[0][i] = gmat[0][0]*inarray[0][i+cnt]
769  + gmat[2][0]*inarray[1][i+cnt];
770 
771  stdVelocity[1][i] = gmat[1][0]*inarray[0][i+cnt]
772  + gmat[3][0]*inarray[1][i+cnt];
773  }
774  }
775 
776  cnt += n_points;
777 
778 
779  for (int i = 0; i < n_points; i++)
780  {
781  pntVelocity = stdVelocity[0][i]*stdVelocity[0][i]
782  + stdVelocity[1][i]*stdVelocity[1][i];
783 
784  if (pntVelocity>maxV[el])
785  {
786  maxV[el] = pntVelocity;
787  }
788  }
789  maxV[el] = sqrt(maxV[el]);
790  }
791  }
792  else
793  {
794  cnt = 0;
795  for (int el = 0; el < n_element; ++el)
796  {
797 
798  int n_points = m_fields[0]->GetExp(el)->GetTotPoints();
799  ptsKeys = m_fields[0]->GetExp(el)->GetPointsKeys();
800 
801  // reset local space if necessary
802  if(n_points != n_points_0)
803  {
804  for (int j = 0; j < nvel; ++j)
805  {
806  stdVelocity[j] = Array<OneD, NekDouble>(n_points);
807  }
808  n_points_0 = n_points;
809  }
810 
812  m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetDerivFactors(ptsKeys);
813 
814  if (m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetGtype()
816  {
817  for (int i = 0; i < n_points; i++)
818  {
819  stdVelocity[0][i] = gmat[0][i]*inarray[0][i+cnt]
820  + gmat[3][i]*inarray[1][i+cnt]
821  + gmat[6][i]*inarray[2][i+cnt];
822 
823  stdVelocity[1][i] = gmat[1][i]*inarray[0][i+cnt]
824  + gmat[4][i]*inarray[1][i+cnt]
825  + gmat[7][i]*inarray[2][i+cnt];
826 
827  stdVelocity[2][i] = gmat[2][i]*inarray[0][i+cnt]
828  + gmat[5][i]*inarray[1][i+cnt]
829  + gmat[8][i]*inarray[2][i+cnt];
830  }
831  }
832  else
833  {
834  for (int i = 0; i < n_points; i++)
835  {
836  stdVelocity[0][i] = gmat[0][0]*inarray[0][i+cnt]
837  + gmat[3][0]*inarray[1][i+cnt]
838  + gmat[6][0]*inarray[2][i+cnt];
839 
840  stdVelocity[1][i] = gmat[1][0]*inarray[0][i+cnt]
841  + gmat[4][0]*inarray[1][i+cnt]
842  + gmat[7][0]*inarray[2][i+cnt];
843 
844  stdVelocity[2][i] = gmat[2][0]*inarray[0][i+cnt]
845  + gmat[5][0]*inarray[1][i+cnt]
846  + gmat[8][0]*inarray[2][i+cnt];
847  }
848  }
849 
850  cnt += n_points;
851 
852  for (int i = 0; i < n_points; i++)
853  {
854  pntVelocity = stdVelocity[0][i]*stdVelocity[0][i]
855  + stdVelocity[1][i]*stdVelocity[1][i]
856  + stdVelocity[2][i]*stdVelocity[2][i];
857 
858  if (pntVelocity > maxV[el])
859  {
860  maxV[el] = pntVelocity;
861  }
862  }
863 
864  maxV[el] = sqrt(maxV[el]);
865  //cout << maxV[el]*maxV[el] << endl;
866  }
867  }
868 
869  return maxV;
870  }
871 }
void SubStepProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
void GetFluxVectorAdv(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &flux)
Evaluate the flux at each solution point for the advection part.
Array< OneD, NekDouble > GetMaxStdVelocity(const Array< OneD, Array< OneD, NekDouble > > inarray)
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
BDF multi-step scheme of order 1 (implicit)
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
NekDouble m_time
Current time of simulation.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
LibUtilities::TimeIntegrationWrapperSharedPtr m_subStepIntegrationScheme
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
NekDouble m_timestep
Time step size.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:874
Array< OneD, Array< OneD, NekDouble > > m_velocity
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
DiffusionFactory & GetDiffusionFactory()
Definition: Diffusion.cpp:41
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
STL namespace.
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:294
void GetFluxVectorDiff(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &viscousTensor)
Evaluate the flux at each solution point for the diffusion part.
void SubStepAdvection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Array< OneD, NekDouble > & GetNormalVel(const Array< OneD, const Array< OneD, NekDouble > > &velfield)
Get the normal velocity based on input velfield.
Array< OneD, NekDouble > & GetNormalVelocity()
Get the normal velocity based on m_velocity.
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Perform the projection.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
std::shared_ptr< TimeIntegrationWrapper > TimeIntegrationWrapperSharedPtr
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
virtual void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the RHS.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
virtual bool v_PreIntegrate(int step)
PreIntegration step for substepping.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
Base class for unsteady solvers.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print Summary.
RiemannSolverFactory & GetRiemannSolverFactory()
int m_spacedim
Spatial dimension (>= expansion dim).
void SetUpSubSteppingTimeIntegration(int intMethod, const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme)
SolverUtils::DiffusionSharedPtr m_diffusion
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:47
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
double NekDouble
TimeIntegrationWrapperFactory & GetTimeIntegrationWrapperFactory()
EquationSystemFactory & GetEquationSystemFactory()
void SubStepAdvance(const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln, int nstep, NekDouble time)
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:346
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
BDF multi-step scheme of order 2 (implicit)
virtual void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, NekDouble time, NekDouble lambda)
Solve implicitly the diffusion term.
SOLVER_UTILS_EXPORT int GetNpoints()
LibUtilities::TimeIntegrationSchemeOperators m_subStepIntegrationOps
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetTraceNpoints()
void AddAdvectionPenaltyFlux(const Array< OneD, const Array< OneD, NekDouble > > &velfield, const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &Outarray)
SOLVER_UTILS_EXPORT int GetNcoeffs()
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
A base class for PDEs which include an advection component.
std::shared_ptr< TimeIntegrationSolution > TimeIntegrationSolutionSharedPtr
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
Geometry is curved or has non-constant factors.
virtual void v_InitObject()
Initialise the object.
LibUtilities::TimeIntegrationSolutionSharedPtr m_intSoln
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:302
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:186
static FlagList NullFlagList
An empty flag list.