Nektar++
VariableConverter.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File VariableConverter.h
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: Auxiliary functions to convert variables in
32 // the compressible flow system
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_SOLVERS_COMPRESSIBLEFLOWSOLVER_MISC_VARCONVERT_H
37 #define NEKTAR_SOLVERS_COMPRESSIBLEFLOWSOLVER_MISC_VARCONVERT_H
38 
39 #include "EquationOfState.h"
40 #include <MultiRegions/ContField.h>
42 
43 namespace Nektar
44 {
45 // Forward declarations
46 class VariableConverter;
47 typedef std::shared_ptr<VariableConverter> VariableConverterSharedPtr;
48 /**
49  *
50  */
52 {
53 public:
55  const int spaceDim,
56  const SpatialDomains::MeshGraphSharedPtr &pGraph = 0);
57 
59 
60  // Variable manipulations valid for all fluids
61  void GetDynamicEnergy(
62  const Array<OneD, const Array<OneD, NekDouble>> &physfield,
63  Array<OneD, NekDouble> &energy);
64  void GetInternalEnergy(
65  const Array<OneD, const Array<OneD, NekDouble>> &physfield,
66  Array<OneD, NekDouble> &energy);
67  template <class T, typename = typename std::enable_if<
68  std::is_floating_point<T>::value ||
70  inline T GetInternalEnergy(T *physfield)
71  {
72  // get dynamic energy
73  T oneOrho = 1.0 / physfield[0];
74  T dynEne{};
75  for (size_t d = 1; d < m_spacedim + 1; ++d)
76  {
77  T tmp = physfield[d]; // load 1x
78  dynEne += tmp * tmp;
79  }
80  dynEne = 0.5 * dynEne * oneOrho;
81 
82  // Calculate rhoe = E - rho*V^2/2
83  T energy = physfield[m_spacedim + 1] - dynEne;
84  return energy * oneOrho;
85  }
86  void GetEnthalpy(const Array<OneD, const Array<OneD, NekDouble>> &physfield,
87  Array<OneD, NekDouble> &enthalpy);
88  void GetVelocityVector(const Array<OneD, Array<OneD, NekDouble>> &physfield,
89  Array<OneD, Array<OneD, NekDouble>> &velocity);
90  void GetMach(Array<OneD, Array<OneD, NekDouble>> &physfield,
91  Array<OneD, NekDouble> &soundspeed,
93  void GetDynamicViscosity(const Array<OneD, const NekDouble> &temperature,
95 
96  template <class T, typename = typename std::enable_if<
97  std::is_floating_point<T>::value ||
99  inline T GetDynamicViscosity(T &temperature)
100  {
101  const NekDouble onePlusC = 1.0 + m_TRatioSutherland;
102 
103  NekDouble mu_star = m_mu;
104 
105  T ratio = temperature * m_oneOverT_star;
106  return mu_star * ratio * sqrt(ratio) * onePlusC /
107  (ratio + m_TRatioSutherland);
108  }
109 
110  void GetAbsoluteVelocity(
111  const Array<OneD, const Array<OneD, NekDouble>> &physfield,
112  Array<OneD, NekDouble> &Vtot);
113 
114  // Transformations depending on the equation of state
115  void GetTemperature(
116  const Array<OneD, const Array<OneD, NekDouble>> &physfield,
117  Array<OneD, NekDouble> &temperature);
118  template <class T, typename = typename std::enable_if<
119  std::is_floating_point<T>::value ||
121  inline T GetTemperature(T *physfield)
122  {
123  T energy = GetInternalEnergy(physfield);
124  return m_eos->GetTemperature(physfield[0], energy);
125  }
126  //
127  void GetPressure(const Array<OneD, const Array<OneD, NekDouble>> &physfield,
129  template <class T, typename = typename std::enable_if<
130  std::is_floating_point<T>::value ||
132  inline T GetPressure(T *physfield)
133  {
134  T energy = GetInternalEnergy(physfield);
135  return m_eos->GetPressure(physfield[0], energy);
136  }
137 
138  void GetSoundSpeed(
139  const Array<OneD, const Array<OneD, NekDouble>> &physfield,
140  Array<OneD, NekDouble> &soundspeed);
141  void GetEntropy(const Array<OneD, const Array<OneD, NekDouble>> &physfield,
142  Array<OneD, NekDouble> &entropy);
143  void GetEFromRhoP(const Array<OneD, NekDouble> &rho,
145  Array<OneD, NekDouble> &energy);
147  const Array<OneD, NekDouble> &temperature,
149  void GetDmuDT(const Array<OneD, const NekDouble> &temperature,
151  Array<OneD, NekDouble> &DmuDT);
152 
154  {
155  return m_eos;
156  }
157 
158  // Shock sensor methods
160  const Array<OneD, const Array<OneD, NekDouble>> &consVar,
161  const Array<OneD, NekDouble> &div,
162  const Array<OneD, NekDouble> &curlSquared);
163 
165 
167 
168  void SetElmtMinHP(
170 
172 
173  void GetSensor(const MultiRegions::ExpListSharedPtr &field,
174  const Array<OneD, const Array<OneD, NekDouble>> &physarray,
175  Array<OneD, NekDouble> &Sensor,
176  Array<OneD, NekDouble> &SensorKappa, int offset = 1);
177 
179  const Array<OneD, const Array<OneD, NekDouble>> &physfield,
180  Array<OneD, NekDouble> &muAv);
181 
183  const Array<OneD, const Array<OneD, NekDouble>> &consVar,
184  const Array<OneD, NekDouble> &div,
185  Array<OneD, NekDouble> &muAv);
186 
187  void ApplyDucros(const Array<OneD, NekDouble> &div,
188  const Array<OneD, NekDouble> &curlSquare,
189  Array<OneD, NekDouble> &muAv);
190 
192 
193 protected:
206 
207  /// Shock sensor
209  std::string m_shockCaptureType;
210  std::string m_shockSensorType;
211  std::string m_ducrosSensor;
212  std::string m_smoothing;
214 
215  /// h/p scaling
217  /// storage
220 };
221 
222 } // namespace Nektar
223 #endif
void ApplyC0Smooth(Array< OneD, NekDouble > &field)
Make field C0.
Array< OneD, NekDouble > & GetAvTrace()
EquationOfStateSharedPtr m_eos
void GetDynamicEnergy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
Compute the dynamic energy .
Array< OneD, NekDouble > m_hOverP
h/p scaling
void GetRhoFromPT(const Array< OneD, NekDouble > &pressure, const Array< OneD, NekDouble > &temperature, Array< OneD, NekDouble > &rho)
Compute using the equation of state.
void GetTemperature(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &temperature)
Compute the temperature using the equation of state.
Array< OneD, NekDouble > m_muAvTrace
void SetAv(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const Array< OneD, NekDouble >> &consVar, const Array< OneD, NekDouble > &div, const Array< OneD, NekDouble > &curlSquared)
T GetInternalEnergy(T *physfield)
void GetDmuDT(const Array< OneD, const NekDouble > &temperature, const Array< OneD, const NekDouble > &mu, Array< OneD, NekDouble > &DmuDT)
Compute the dynamic viscosity using the Sutherland's law ,.
void GetEnthalpy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &enthalpy)
Compute the specific enthalpy .
void GetEFromRhoP(const Array< OneD, NekDouble > &rho, const Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &energy)
Compute using the equation of state.
void SetElmtMinHP(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
Compute an estimate of minimum h/p for each element of the expansion.
MultiRegions::ContFieldSharedPtr m_C0ProjectExp
LibUtilities::SessionReaderSharedPtr m_session
NekDouble m_mu0
Shock sensor.
void GetPressure(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &pressure)
Calculate the pressure using the equation of state.
void ApplyDucros(const Array< OneD, NekDouble > &div, const Array< OneD, NekDouble > &curlSquare, Array< OneD, NekDouble > &muAv)
Apply Ducros (anti-vorticity) sensor averaged over the element.
void GetSoundSpeed(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &soundspeed)
Compute the sound speed using the equation of state.
void GetAbsoluteVelocity(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &Vtot)
void GetEntropy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &entropy)
Compute the entropy using the equation of state.
void GetVelocityVector(const Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &velocity)
Compute the velocity field given the momentum .
void GetMach(Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &soundspeed, Array< OneD, NekDouble > &mach)
Compute the mach number .
void GetSensor(const MultiRegions::ExpListSharedPtr &field, const Array< OneD, const Array< OneD, NekDouble >> &physarray, Array< OneD, NekDouble > &Sensor, Array< OneD, NekDouble > &SensorKappa, int offset=1)
const EquationOfStateSharedPtr Geteos()
void GetMuAv(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &muAv)
Calculate the physical artificial viscosity based on modal sensor.
~VariableConverter()
Destructor for VariableConverter class.
Array< OneD, NekDouble > & GetElmtMinHP()
Array< OneD, NekDouble > m_muAv
storage
Array< OneD, NekDouble > & GetAv()
void GetInternalEnergy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
Compute the specific internal energy .
T GetDynamicViscosity(T &temperature)
VariableConverter(const LibUtilities::SessionReaderSharedPtr &pSession, const int spaceDim, const SpatialDomains::MeshGraphSharedPtr &pGraph=0)
void GetDynamicViscosity(const Array< OneD, const NekDouble > &temperature, Array< OneD, NekDouble > &mu)
Compute the dynamic viscosity using the Sutherland's law , C : 110. /Tref Tref : the reference temper...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ContField > ContFieldSharedPtr
Definition: ContField.h:277
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:172
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
std::shared_ptr< VariableConverter > VariableConverterSharedPtr
std::shared_ptr< EquationOfState > EquationOfStateSharedPtr
A shared pointer to an equation of state object.
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:291