Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // 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: NonSmooth artificial diffusion for shock capture
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include "NonSmoothShockCapture.h"
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43 std::string NonSmoothShockCapture::className = GetArtificialDiffusionFactory().
44  RegisterCreatorFunction("NonSmooth",
45  NonSmoothShockCapture::create,
46  "NonSmooth artificial diffusion for shock capture.");
47 
48 NonSmoothShockCapture::NonSmoothShockCapture(
51  const int spacedim)
52  : ArtificialDiffusion(pSession, pFields, spacedim)
53 {
54 }
55 
57  const Array<OneD, Array<OneD, NekDouble> > &physfield,
59 {
60  const int nElements = m_fields[0]->GetExpSize();
61  int PointCount = 0;
62  int nTotQuadPoints = m_fields[0]->GetTotPoints();
63 
64  Array<OneD, NekDouble> Sensor (nTotQuadPoints, 0.0);
65  Array<OneD, NekDouble> SensorKappa(nTotQuadPoints, 0.0);
66 
67  m_varConv->GetSensor(m_fields[0], physfield, Sensor, SensorKappa);
68 
69  for (int e = 0; e < nElements; e++)
70  {
71  // Threshold value specified in C. Biottos thesis. Based on a 1D
72  // shock tube problem S_k = log10(1/p^4). See G.E. Barter and
73  // D.L. Darmofal. Shock Capturing with PDE-based artificial
74  // diffusion for DGFEM: Part 1 Formulation, Journal of Computational
75  // Physics 229 (2010) 1810-1827 for further reference
76 
77  // Adjustable depending on the coarsness of the mesh. Might want to
78  // move this variable into the session file
79 
80  int nQuadPointsElement = m_fields[0]->GetExp(e)->GetTotPoints();
81 
82  for (int n = 0; n < nQuadPointsElement; n++)
83  {
84  NekDouble mu_0 = m_mu0;
85 
86  if (Sensor[n+PointCount] < (m_Skappa-m_Kappa))
87  {
88  mu[n+PointCount] = 0;
89  }
90  else if (Sensor[n+PointCount] >= (m_Skappa-m_Kappa)
91  && Sensor[n+PointCount] <= (m_Skappa+m_Kappa))
92  {
93  mu[n+PointCount] = mu_0 * (0.5 * (1 + sin(
94  M_PI * (Sensor[n+PointCount] -
95  m_Skappa - m_Kappa) /
96  (2*m_Kappa))));
97  }
98  else if (Sensor[n+PointCount] > (m_Skappa+m_Kappa))
99  {
100  mu[n+PointCount] = mu_0;
101  }
102  }
103 
104  PointCount += nQuadPointsElement;
105  }
106 }
107 
108 }
STL namespace.
virtual void v_GetArtificialViscosity(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &mu)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
Encapsulates the artificial diffusion used in shock capture.
ArtificialDiffusionFactory & GetArtificialDiffusionFactory()
Declaration of the artificial diffusion factory singleton.
double NekDouble
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.