Nektar++
NonSmoothShockCapture.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: NonSmoothShockCapture.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: NonSmooth artificial diffusion for shock capture
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include "NonSmoothShockCapture.h"
36 
37 using namespace std;
38 
39 namespace Nektar
40 {
41 
42 std::string NonSmoothShockCapture::className = GetArtificialDiffusionFactory().
43  RegisterCreatorFunction("NonSmooth",
44  NonSmoothShockCapture::create,
45  "NonSmooth artificial diffusion for shock capture.");
46 
47 NonSmoothShockCapture::NonSmoothShockCapture(
50  const int spacedim)
51  : ArtificialDiffusion(pSession, pFields, spacedim)
52 {
53  m_session->LoadParameter ("SensorOffset", m_offset, 1);
54 }
55 
57  const Array<OneD, Array<OneD, NekDouble> > &physfield,
59 {
60  int nPts = m_fields[0]->GetTotPoints();
61  int nElements = m_fields[0]->GetExpSize();
62 
63  // Determine the maximum wavespeed
64  Array <OneD, NekDouble > Lambda(nPts, 0.0);
65  Array <OneD, NekDouble > soundspeed(nPts, 0.0);
66  Array <OneD, NekDouble > absVelocity(nPts, 0.0);
67  m_varConv->GetSoundSpeed(physfield, soundspeed);
68  m_varConv->GetAbsoluteVelocity(physfield, absVelocity);
69  Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambda, 1);
70 
71  // Compute sensor based on rho
72  Array<OneD, NekDouble> Sensor(nPts, 0.0);
73  m_varConv->GetSensor(m_fields[0], physfield, Sensor, mu, m_offset);
74 
75  // Scale AV
77  for (int e = 0; e < nElements; e++)
78  {
79  int physOffset = m_fields[0]->GetPhys_Offset(e);
80  int nElmtPoints = m_fields[0]->GetExp(e)->GetTotPoints();
81 
82  // Get max wavespeed per element
83  NekDouble LambdaElmt = 0.0;
84  LambdaElmt = Vmath::Vmax(nElmtPoints, tmp = Lambda + physOffset, 1);
85 
86  // Scale viscosity by the maximum wave speed and h/p
87  LambdaElmt *= m_mu0 * m_hOverP[e];
88  Vmath::Smul(nElmtPoints, LambdaElmt, tmp = mu + physOffset, 1,
89  tmp = mu + physOffset, 1);
90  }
91 }
92 }
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:782
STL namespace.
virtual void v_GetArtificialViscosity(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &mu)
Encapsulates the artificial diffusion used in shock capture.
Array< OneD, NekDouble > m_hOverP
h/p scaling
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
ArtificialDiffusionFactory & GetArtificialDiffusionFactory()
Declaration of the artificial diffusion factory singleton.
double NekDouble
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
NekDouble m_mu0
Constant scaling.
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
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