Nektar++
Public Member Functions | Protected Attributes | List of all members
Nektar::VariableConverter Class Reference

#include <VariableConverter.h>

Public Member Functions

 VariableConverter (const LibUtilities::SessionReaderSharedPtr &pSession, const int spaceDim)
 
 ~VariableConverter ()
 Destructor for VariableConverter class. More...
 
void GetDynamicEnergy (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
 Compute the dynamic energy \( e = rho*V^2/2 \). More...
 
void GetInternalEnergy (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
 Compute the specific internal energy \( e = (E - rho*V^2/2)/rho \). More...
 
template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
GetInternalEnergy (T *physfield)
 
void GetEnthalpy (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &enthalpy)
 Compute the specific enthalpy \( h = e + p/rho \). More...
 
void GetVelocityVector (const Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &velocity)
 Compute the velocity field \( \mathbf{v} \) given the momentum \( \rho\mathbf{v} \). More...
 
void GetMach (Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &soundspeed, Array< OneD, NekDouble > &mach)
 Compute the mach number \( M = \| \mathbf{v} \|^2 / c \). More...
 
void GetDynamicViscosity (const Array< OneD, const NekDouble > &temperature, Array< OneD, NekDouble > &mu)
 Compute the dynamic viscosity using the Sutherland's law \( \mu = \mu_star * (T / T_star)^3/2 * (1 + C) / (T / T_star + C) \), where: \mu_star = 1.7894 * 10^-5 Kg / (m * s) T_star = 288.15 K C = 110. / 288.15. More...
 
template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
GetDynamicViscosity (T &temperature)
 
void GetAbsoluteVelocity (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &Vtot)
 
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)
 
void GetTemperature (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &temperature)
 Compute the temperature using the equation of state. More...
 
template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
GetTemperature (T *physfield)
 
void GetPressure (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &pressure)
 Calculate the pressure using the equation of state. More...
 
template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
GetPressure (T *physfield)
 
void GetSoundSpeed (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &soundspeed)
 Compute the sound speed using the equation of state. More...
 
void GetEntropy (const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &entropy)
 Compute the entropy using the equation of state. More...
 
void GetEFromRhoP (const Array< OneD, NekDouble > &rho, const Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &energy)
 Compute \( e(rho,p) \) using the equation of state. More...
 
void GetRhoFromPT (const Array< OneD, NekDouble > &pressure, const Array< OneD, NekDouble > &temperature, Array< OneD, NekDouble > &rho)
 Compute \( rho(p,T) \) using the equation of state. More...
 
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 \( \mu = \mu_star * (T / T_star)^3/2 * (T_star + 110) / (T + 110) \), where: \mu_star = 1.7894 * 10^-5 Kg / (m * s) T_star = 288.15 K. More...
 
const EquationOfStateSharedPtr Geteos ()
 

Protected Attributes

LibUtilities::SessionReaderSharedPtr m_session
 
EquationOfStateSharedPtr m_eos
 
int m_spacedim
 
NekDouble m_pInf
 
NekDouble m_rhoInf
 
NekDouble m_gasConstant
 
NekDouble m_mu
 
NekDouble m_Skappa
 
NekDouble m_Kappa
 
NekDouble m_oneOverT_star
 

Detailed Description

Definition at line 50 of file VariableConverter.h.

Constructor & Destructor Documentation

◆ VariableConverter()

Nektar::VariableConverter::VariableConverter ( const LibUtilities::SessionReaderSharedPtr pSession,
const int  spaceDim 
)

Definition at line 44 of file VariableConverter.cpp.

46  : m_session(pSession), m_spacedim(spaceDim)
47 {
48  // Create equation of state object
49  std::string eosType;
50  m_session->LoadSolverInfo("EquationOfState", eosType, "IdealGas");
52 
53  // Parameters for dynamic viscosity
54  m_session->LoadParameter("pInf", m_pInf, 101325);
55  m_session->LoadParameter("rhoInf", m_rhoInf, 1.225);
56  m_session->LoadParameter("GasConstant", m_gasConstant, 287.058);
57  m_session->LoadParameter("mu", m_mu, 1.78e-05);
59 
60  // Parameters for sensor
61  m_session->LoadParameter("Skappa", m_Skappa, -1.0);
62  m_session->LoadParameter("Kappa", m_Kappa, 0.25);
63 
64 
65 }
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:145
EquationOfStateSharedPtr m_eos
LibUtilities::SessionReaderSharedPtr m_session
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.

References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::GetEquationOfStateFactory(), m_eos, m_gasConstant, m_Kappa, m_mu, m_oneOverT_star, m_pInf, m_rhoInf, m_session, and m_Skappa.

◆ ~VariableConverter()

Nektar::VariableConverter::~VariableConverter ( )

Destructor for VariableConverter class.

Definition at line 70 of file VariableConverter.cpp.

71 {
72 }

Member Function Documentation

◆ GetAbsoluteVelocity()

void Nektar::VariableConverter::GetAbsoluteVelocity ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  Vtot 
)

Definition at line 231 of file VariableConverter.cpp.

234 {
235  const int nPts = physfield[0].size();
236 
237  // Getting the velocity vector on the 2D normal space
238  Array<OneD, Array<OneD, NekDouble>> velocity(m_spacedim);
239 
240  Vmath::Zero(Vtot.size(), Vtot, 1);
241 
242  for (int i = 0; i < m_spacedim; ++i)
243  {
244  velocity[i] = Array<OneD, NekDouble>(nPts);
245  }
246 
247  GetVelocityVector(physfield, velocity);
248 
249  for (int i = 0; i < m_spacedim; ++i)
250  {
251  Vmath::Vvtvp(nPts, velocity[i], 1, velocity[i], 1, Vtot, 1, Vtot, 1);
252  }
253 
254  Vmath::Vsqrt(nPts, Vtot, 1, Vtot, 1);
255 }
void GetVelocityVector(const Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &velocity)
Compute the velocity field given the momentum .
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:475
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:513
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436

References GetVelocityVector(), m_spacedim, Vmath::Vsqrt(), Vmath::Vvtvp(), and Vmath::Zero().

◆ GetDmuDT()

void Nektar::VariableConverter::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 \( \mu = \mu_star * (T / T_star)^3/2 * (T_star + 110) / (T + 110) \), where: \mu_star = 1.7894 * 10^-5 Kg / (m * s) T_star = 288.15 K.

Parameters
physfieldInput physical field.
muThe resulting dynamic viscosity.

Definition at line 215 of file VariableConverter.cpp.

219 {
220  const int nPts = temperature.size();
221  NekDouble tmp = 0.0;
222 
223  for (int i = 0; i < nPts; ++i)
224  {
225  tmp = 0.5* (temperature[i]+3.0*110.0)/
226  (temperature[i]*(temperature[i]+110.0));
227  DmuDT[i] = mu[i]*tmp;
228  }
229 }
double NekDouble

◆ GetDynamicEnergy()

void Nektar::VariableConverter::GetDynamicEnergy ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  energy 
)

Compute the dynamic energy \( e = rho*V^2/2 \).

Definition at line 78 of file VariableConverter.cpp.

81 {
82  size_t nPts = physfield[m_spacedim + 1].size();
83  Vmath::Zero(nPts, energy, 1);
84 
85  // tmp = (rho * u_i)^2
86  for (int i = 0; i < m_spacedim; ++i)
87  {
88  Vmath::Vvtvp(nPts, physfield[i + 1], 1, physfield[i + 1], 1, energy, 1,
89  energy, 1);
90  }
91  // Divide by rho and multiply by 0.5 --> tmp = 0.5 * rho * u^2
92  Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
93  Vmath::Smul(nPts, 0.5, energy, 1, energy, 1);
94 }
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:225
void Vdiv(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:257

References m_spacedim, Vmath::Smul(), Vmath::Vdiv(), Vmath::Vvtvp(), and Vmath::Zero().

Referenced by GetInternalEnergy().

◆ GetDynamicViscosity() [1/2]

void Nektar::VariableConverter::GetDynamicViscosity ( const Array< OneD, const NekDouble > &  temperature,
Array< OneD, NekDouble > &  mu 
)

Compute the dynamic viscosity using the Sutherland's law \( \mu = \mu_star * (T / T_star)^3/2 * (1 + C) / (T / T_star + C) \), where: \mu_star = 1.7894 * 10^-5 Kg / (m * s) T_star = 288.15 K C = 110. / 288.15.

WARNING, if this routine is modified the same must be done in the FieldConvert utility ProcessWSS.cpp (this class should be restructured).

Parameters
temperatureInput temperature field.
muThe resulting dynamic viscosity.

Definition at line 195 of file VariableConverter.cpp.

197 {
198  const int nPts = temperature.size();
199 
200  for (int i = 0; i < nPts; ++i)
201  {
202  mu[i] = GetDynamicViscosity(temperature[i]);
203  }
204 }
void GetDynamicViscosity(const Array< OneD, const NekDouble > &temperature, Array< OneD, NekDouble > &mu)
Compute the dynamic viscosity using the Sutherland's law , where: \mu_star = 1.7894 * 10^-5 Kg / (m *...

◆ GetDynamicViscosity() [2/2]

template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
T Nektar::VariableConverter::GetDynamicViscosity ( T &  temperature)
inline

Definition at line 103 of file VariableConverter.h.

104  {
105  constexpr NekDouble C = .38175;
106  constexpr NekDouble onePlusC = 1.0 + C;
107 
108  NekDouble mu_star = m_mu;
109 
110  T ratio = temperature * m_oneOverT_star;
111  return mu_star * ratio * sqrt(ratio) * onePlusC / (ratio + C);
112  }
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267

References m_mu, m_oneOverT_star, and tinysimd::sqrt().

◆ GetEFromRhoP()

void Nektar::VariableConverter::GetEFromRhoP ( const Array< OneD, NekDouble > &  rho,
const Array< OneD, NekDouble > &  pressure,
Array< OneD, NekDouble > &  energy 
)

Compute \( e(rho,p) \) using the equation of state.

Parameters
rhoInput density
pressureInput pressure
energyThe resulting internal energy.

Definition at line 441 of file VariableConverter.cpp.

444 {
445  int nPts = rho.size();
446 
447  for (int i = 0; i < nPts; ++i)
448  {
449  energy[i] = m_eos->GetEFromRhoP(rho[i], pressure[i]);
450  }
451 }

References m_eos, and CG_Iterations::pressure.

◆ GetEnthalpy()

void Nektar::VariableConverter::GetEnthalpy ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  enthalpy 
)

Compute the specific enthalpy \( h = e + p/rho \).

Definition at line 118 of file VariableConverter.cpp.

121 {
122  int nPts = physfield[0].size();
123  Array<OneD, NekDouble> energy(nPts, 0.0);
124  Array<OneD, NekDouble> pressure(nPts, 0.0);
125 
126  GetInternalEnergy(physfield, energy);
127  GetPressure(physfield, pressure);
128 
129  // Calculate p/rho
130  Vmath::Vdiv(nPts, pressure, 1, physfield[0], 1, enthalpy, 1);
131  // Calculate h = e + p/rho
132  Vmath::Vadd(nPts, energy, 1, enthalpy, 1, enthalpy, 1);
133 }
void GetPressure(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &pressure)
Calculate the pressure using the equation of state.
void GetInternalEnergy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
Compute the specific internal energy .
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:322

References GetInternalEnergy(), GetPressure(), CG_Iterations::pressure, Vmath::Vadd(), and Vmath::Vdiv().

◆ GetEntropy()

void Nektar::VariableConverter::GetEntropy ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  entropy 
)

Compute the entropy using the equation of state.

Parameters
physfieldInput physical field
soundspeedThe resulting sound speed \( c \).

Definition at line 419 of file VariableConverter.cpp.

422 {
423  int nPts = physfield[0].size();
424 
425  Array<OneD, NekDouble> energy(nPts);
426  GetInternalEnergy(physfield, energy);
427 
428  for (int i = 0; i < nPts; ++i)
429  {
430  entropy[i] = m_eos->GetEntropy(physfield[0][i], energy[i]);
431  }
432 }

References GetInternalEnergy(), and m_eos.

◆ Geteos()

const EquationOfStateSharedPtr Nektar::VariableConverter::Geteos ( )
inline

Definition at line 168 of file VariableConverter.h.

169  {
170  return m_eos;
171  }

References m_eos.

◆ GetInternalEnergy() [1/2]

void Nektar::VariableConverter::GetInternalEnergy ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  energy 
)

Compute the specific internal energy \( e = (E - rho*V^2/2)/rho \).

Definition at line 100 of file VariableConverter.cpp.

103 {
104  int nPts = physfield[0].size();
105  Array<OneD, NekDouble> tmp(nPts);
106 
107  GetDynamicEnergy(physfield, tmp);
108 
109  // Calculate rhoe = E - rho*V^2/2
110  Vmath::Vsub(nPts, physfield[m_spacedim + 1], 1, tmp, 1, energy, 1);
111  // Divide by rho
112  Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
113 }
void GetDynamicEnergy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
Compute the dynamic energy .
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:372

References GetDynamicEnergy(), m_spacedim, Vmath::Vdiv(), and Vmath::Vsub().

Referenced by GetEnthalpy(), GetEntropy(), GetPressure(), GetSoundSpeed(), and GetTemperature().

◆ GetInternalEnergy() [2/2]

template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
T Nektar::VariableConverter::GetInternalEnergy ( T *  physfield)
inline

Definition at line 71 of file VariableConverter.h.

72  {
73  // get dynamic energy
74  T oneOrho = 1.0 / physfield[0];
75  T dynEne{};
76  for (size_t d = 1; d < m_spacedim + 1; ++d)
77  {
78  T tmp = physfield[d]; //load 1x
79  dynEne += tmp * tmp;
80  }
81  dynEne = 0.5 * dynEne * oneOrho;
82 
83  // Calculate rhoe = E - rho*V^2/2
84  T energy = physfield[m_spacedim + 1] - dynEne;
85  return energy * oneOrho;
86  }

References m_spacedim.

◆ GetMach()

void Nektar::VariableConverter::GetMach ( Array< OneD, Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  soundspeed,
Array< OneD, NekDouble > &  mach 
)

Compute the mach number \( M = \| \mathbf{v} \|^2 / c \).

Parameters
physfieldInput physical field.
soundfieldThe speed of sound corresponding to physfield.
machThe resulting mach number \( M \).

Definition at line 161 of file VariableConverter.cpp.

164 {
165  const int nPts = physfield[0].size();
166 
167  Vmath::Vmul(nPts, physfield[1], 1, physfield[1], 1, mach, 1);
168 
169  for (int i = 1; i < m_spacedim; ++i)
170  {
171  Vmath::Vvtvp(nPts, physfield[1 + i], 1, physfield[1 + i], 1, mach, 1,
172  mach, 1);
173  }
174 
175  Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
176  Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
177  Vmath::Vsqrt(nPts, mach, 1, mach, 1);
178 
179  Vmath::Vdiv(nPts, mach, 1, soundspeed, 1, mach, 1);
180 }
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:192

References m_spacedim, Vmath::Vdiv(), Vmath::Vmul(), Vmath::Vsqrt(), and Vmath::Vvtvp().

◆ GetPressure() [1/2]

void Nektar::VariableConverter::GetPressure ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  pressure 
)

Calculate the pressure using the equation of state.

Parameters
physfieldInput momentum.
pressureComputed pressure field.

Definition at line 356 of file VariableConverter.cpp.

359 {
360  int nPts = physfield[0].size();
361 
362  Array<OneD, NekDouble> energy(nPts);
363  GetInternalEnergy(physfield, energy);
364 
365  for (int i = 0; i < nPts; ++i)
366  {
367  pressure[i] = m_eos->GetPressure(physfield[0][i], energy[i]);
368  }
369 }

References GetInternalEnergy(), m_eos, and CG_Iterations::pressure.

Referenced by GetEnthalpy().

◆ GetPressure() [2/2]

template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
T Nektar::VariableConverter::GetPressure ( T *  physfield)
inline

Definition at line 146 of file VariableConverter.h.

147  {
148  T energy = GetInternalEnergy(physfield);
149  return m_eos->GetPressure(physfield[0], energy);
150  }

References GetInternalEnergy(), and m_eos.

◆ GetRhoFromPT()

void Nektar::VariableConverter::GetRhoFromPT ( const Array< OneD, NekDouble > &  pressure,
const Array< OneD, NekDouble > &  temperature,
Array< OneD, NekDouble > &  rho 
)

Compute \( rho(p,T) \) using the equation of state.

Parameters
pressureInput pressure
temperatureInput temperature
rhoThe resulting density

Definition at line 460 of file VariableConverter.cpp.

463 {
464  int nPts = pressure.size();
465 
466  for (int i = 0; i < nPts; ++i)
467  {
468  rho[i] = m_eos->GetRhoFromPT(pressure[i], temperature[i]);
469  }
470 }

References m_eos, and CG_Iterations::pressure.

◆ GetSensor()

void Nektar::VariableConverter::GetSensor ( const MultiRegions::ExpListSharedPtr field,
const Array< OneD, const Array< OneD, NekDouble >> &  physarray,
Array< OneD, NekDouble > &  Sensor,
Array< OneD, NekDouble > &  SensorKappa,
int  offset = 1 
)

Definition at line 257 of file VariableConverter.cpp.

262 {
263  NekDouble Skappa;
264  NekDouble order;
265  Array<OneD, NekDouble> tmp;
266  Array<OneD, int> expOrderElement = field->EvalBasisNumModesMaxPerExp();
267 
268  for (int e = 0; e < field->GetExpSize(); e++)
269  {
270  int numModesElement = expOrderElement[e];
271  int nElmtPoints = field->GetExp(e)->GetTotPoints();
272  int physOffset = field->GetPhys_Offset(e);
273  int nElmtCoeffs = field->GetExp(e)->GetNcoeffs();
274  int numCutOff = numModesElement - offset;
275 
276  if (numModesElement <= offset)
277  {
278  Vmath::Fill(nElmtPoints, 0.0,
279  tmp = Sensor + physOffset, 1);
280  Vmath::Fill(nElmtPoints, 0.0,
281  tmp = SensorKappa + physOffset, 1);
282  continue;
283  }
284 
285  // create vector to save the solution points per element at P = p;
286  Array<OneD, NekDouble> elmtPhys(nElmtPoints,
287  tmp = physarray[0] + physOffset);
288  // Compute coefficients
289  Array<OneD, NekDouble> elmtCoeffs(nElmtCoeffs, 0.0);
290  field->GetExp(e)->FwdTrans(elmtPhys, elmtCoeffs);
291 
292  // ReduceOrderCoeffs reduces the polynomial order of the solution
293  // that is represented by the coeffs given as an inarray. This is
294  // done by projecting the higher order solution onto the orthogonal
295  // basis and padding the higher order coefficients with zeros.
296  Array<OneD, NekDouble> reducedElmtCoeffs(nElmtCoeffs, 0.0);
297  field->GetExp(e)->ReduceOrderCoeffs(numCutOff, elmtCoeffs,
298  reducedElmtCoeffs);
299 
300  Array<OneD, NekDouble> reducedElmtPhys(nElmtPoints, 0.0);
301  field->GetExp(e)->BwdTrans(reducedElmtCoeffs, reducedElmtPhys);
302 
303  NekDouble numerator = 0.0;
304  NekDouble denominator = 0.0;
305 
306  // Determining the norm of the numerator of the Sensor
307  Array<OneD, NekDouble> difference(nElmtPoints, 0.0);
308  Vmath::Vsub(nElmtPoints, elmtPhys, 1, reducedElmtPhys, 1, difference,
309  1);
310 
311  numerator = Vmath::Dot(nElmtPoints, difference, difference);
312  denominator = Vmath::Dot(nElmtPoints, elmtPhys, elmtPhys);
313 
314  NekDouble elmtSensor = sqrt(numerator / denominator);
315  elmtSensor = log10(max(elmtSensor, NekConstants::kNekSqrtTol));
316 
317  Vmath::Fill(nElmtPoints, elmtSensor, tmp = Sensor + physOffset, 1);
318 
319  // Compute reference value for sensor
320  order = max(numModesElement-1, 1);
321  if (order > 0 )
322  {
323  Skappa = m_Skappa - 4.25 * log10(static_cast<NekDouble>(order));
324  }
325  else
326  {
327  Skappa = 0.0;
328  }
329 
330  // Compute artificial viscosity
331  NekDouble elmtSensorKappa;
332  if (elmtSensor < (Skappa-m_Kappa))
333  {
334  elmtSensorKappa = 0;
335  }
336  else if (elmtSensor > (Skappa + m_Kappa))
337  {
338  elmtSensorKappa = 1.0;
339  }
340  else
341  {
342  elmtSensorKappa = 0.5 *
343  (1 + sin(M_PI * (elmtSensor - Skappa) / (2 * m_Kappa)));
344  }
345  Vmath::Fill(nElmtPoints, elmtSensorKappa,
346  tmp = SensorKappa + physOffset, 1);
347  }
348 }
static const NekDouble kNekSqrtTol
T Dot(int n, const T *w, const T *x)
vvtvp (vector times vector times vector): z = w*x*y
Definition: Vmath.cpp:1038
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45

References Vmath::Dot(), Vmath::Fill(), Nektar::NekConstants::kNekSqrtTol, m_Kappa, m_Skappa, tinysimd::sqrt(), and Vmath::Vsub().

◆ GetSoundSpeed()

void Nektar::VariableConverter::GetSoundSpeed ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  soundspeed 
)

Compute the sound speed using the equation of state.

Parameters
physfieldInput physical field
soundspeedThe resulting sound speed \( c \).

Definition at line 398 of file VariableConverter.cpp.

401 {
402  int nPts = physfield[0].size();
403 
404  Array<OneD, NekDouble> energy(nPts);
405  GetInternalEnergy(physfield, energy);
406 
407  for (int i = 0; i < nPts; ++i)
408  {
409  soundspeed[i] = m_eos->GetSoundSpeed(physfield[0][i], energy[i]);
410  }
411 }

References GetInternalEnergy(), and m_eos.

◆ GetTemperature() [1/2]

void Nektar::VariableConverter::GetTemperature ( const Array< OneD, const Array< OneD, NekDouble >> &  physfield,
Array< OneD, NekDouble > &  temperature 
)

Compute the temperature using the equation of state.

Parameters
physfieldInput physical field.
temperatureThe resulting temperature \( T \).

Definition at line 377 of file VariableConverter.cpp.

380 {
381  int nPts = physfield[0].size();
382 
383  Array<OneD, NekDouble> energy(nPts);
384  GetInternalEnergy(physfield, energy);
385 
386  for (int i = 0; i < nPts; ++i)
387  {
388  temperature[i] = m_eos->GetTemperature(physfield[0][i], energy[i]);
389  }
390 }

References GetInternalEnergy(), and m_eos.

◆ GetTemperature() [2/2]

template<class T , typename = typename std::enable_if < std::is_floating_point<T>::value || tinysimd::is_vector_floating_point<T>::value >::type>
T Nektar::VariableConverter::GetTemperature ( T *  physfield)
inline

Definition at line 132 of file VariableConverter.h.

133  {
134  T energy = GetInternalEnergy(physfield);
135  return m_eos->GetTemperature(physfield[0], energy);
136  }

References GetInternalEnergy(), and m_eos.

◆ GetVelocityVector()

void Nektar::VariableConverter::GetVelocityVector ( const Array< OneD, Array< OneD, NekDouble >> &  physfield,
Array< OneD, Array< OneD, NekDouble >> &  velocity 
)

Compute the velocity field \( \mathbf{v} \) given the momentum \( \rho\mathbf{v} \).

Parameters
physfieldMomentum field.
velocityVelocity field.

Definition at line 142 of file VariableConverter.cpp.

145 {
146  const int nPts = physfield[0].size();
147 
148  for (int i = 0; i < m_spacedim; ++i)
149  {
150  Vmath::Vdiv(nPts, physfield[1 + i], 1, physfield[0], 1, velocity[i], 1);
151  }
152 }

References m_spacedim, and Vmath::Vdiv().

Referenced by GetAbsoluteVelocity().

Member Data Documentation

◆ m_eos

EquationOfStateSharedPtr Nektar::VariableConverter::m_eos
protected

◆ m_gasConstant

NekDouble Nektar::VariableConverter::m_gasConstant
protected

Definition at line 179 of file VariableConverter.h.

Referenced by VariableConverter().

◆ m_Kappa

NekDouble Nektar::VariableConverter::m_Kappa
protected

Definition at line 182 of file VariableConverter.h.

Referenced by GetSensor(), and VariableConverter().

◆ m_mu

NekDouble Nektar::VariableConverter::m_mu
protected

Definition at line 180 of file VariableConverter.h.

Referenced by GetDynamicViscosity(), and VariableConverter().

◆ m_oneOverT_star

NekDouble Nektar::VariableConverter::m_oneOverT_star
protected

Definition at line 183 of file VariableConverter.h.

Referenced by GetDynamicViscosity(), and VariableConverter().

◆ m_pInf

NekDouble Nektar::VariableConverter::m_pInf
protected

Definition at line 177 of file VariableConverter.h.

Referenced by VariableConverter().

◆ m_rhoInf

NekDouble Nektar::VariableConverter::m_rhoInf
protected

Definition at line 178 of file VariableConverter.h.

Referenced by VariableConverter().

◆ m_session

LibUtilities::SessionReaderSharedPtr Nektar::VariableConverter::m_session
protected

Definition at line 174 of file VariableConverter.h.

Referenced by VariableConverter().

◆ m_Skappa

NekDouble Nektar::VariableConverter::m_Skappa
protected

Definition at line 181 of file VariableConverter.h.

Referenced by GetSensor(), and VariableConverter().

◆ m_spacedim

int Nektar::VariableConverter::m_spacedim
protected