Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 GetVelocityVector (const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity)
 
void GetSoundSpeed (const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &soundspeed)
 
void GetMach (Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &soundspeed, Array< OneD, NekDouble > &mach)
 
void GetTemperature (const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &temperature)
 
void GetPressure (const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &pressure)
 Calculate the pressure field $ p = (\gamma-1)(E-\frac{1}{2}\rho\| \mathbf{v} \|^2) $ assuming an ideal gas law. More...
 
void GetPressure (const Array< OneD, const Array< OneD, NekDouble > > &physfield, const Array< OneD, const Array< OneD, NekDouble > > &velocity, Array< OneD, NekDouble > &pressure)
 Calculate the pressure field $ p = (\gamma-1)(E-\frac{1}{2}\rho\| \mathbf{v} \|^2) $ assuming an ideal gas law. More...
 
void GetEnthalpy (const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &enthalpy)
 
void GetEntropy (const Array< OneD, const Array< OneD, NekDouble > > &physfield, const Array< OneD, const NekDouble > &pressure, const Array< OneD, const NekDouble > &temperature, Array< OneD, NekDouble > &entropy)
 
void GetDynamicViscosity (const Array< OneD, const NekDouble > &temperature, Array< OneD, NekDouble > &mu)
 
void GetAbsoluteVelocity (const Array< OneD, const Array< OneD, NekDouble > > &inarray, 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)
 

Protected Attributes

LibUtilities::SessionReaderSharedPtr m_session
 
int m_spacedim
 
NekDouble m_gamma
 
NekDouble m_pInf
 
NekDouble m_rhoInf
 
NekDouble m_gasConstant
 
NekDouble m_mu
 
NekDouble m_thermalConductivity
 
NekDouble m_Skappa
 
NekDouble m_Kappa
 
NekDouble m_mu0
 

Detailed Description

Definition at line 50 of file VariableConverter.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file VariableConverter.cpp.

References ASSERTL0, m_gamma, m_gasConstant, m_Kappa, m_mu, m_mu0, m_pInf, m_rhoInf, m_session, m_Skappa, and m_thermalConductivity.

48  : m_session(pSession),
49  m_spacedim(spaceDim)
50  {
51  m_session->LoadParameter ("Gamma", m_gamma, 1.4);
52  m_session->LoadParameter ("pInf", m_pInf, 101325);
53  m_session->LoadParameter ("rhoInf", m_rhoInf, 1.225);
54  m_session->LoadParameter ("GasConstant", m_gasConstant, 287.058);
55  m_session->LoadParameter ("mu", m_mu, 1.78e-05);
56 
57  if( m_session->DefinesParameter("thermalConductivity"))
58  {
59  ASSERTL0( !m_session->DefinesParameter("Pr"),
60  "Cannot define both Pr and thermalConductivity.");
61 
62  m_session->LoadParameter ("thermalConductivity",
64  }
65  else
66  {
67  NekDouble Pr, Cp;
68  m_session->LoadParameter ("Pr",
69  Pr, 0.72);
70  Cp = m_gamma / (m_gamma - 1.0) * m_gasConstant;
71  m_thermalConductivity = Cp * m_mu / Pr;
72  }
73 
74  // Parameters for sensor
75  m_session->LoadParameter ("Skappa", m_Skappa, -2.048);
76  m_session->LoadParameter ("Kappa", m_Kappa, 0.0);
77  m_session->LoadParameter ("mu0", m_mu0, 1.0);
78  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
LibUtilities::SessionReaderSharedPtr m_session
double NekDouble
Nektar::VariableConverter::~VariableConverter ( )

Destructor for VariableConverter class.

Definition at line 83 of file VariableConverter.cpp.

84  {
85 
86  }

Member Function Documentation

void Nektar::VariableConverter::GetAbsoluteVelocity ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, NekDouble > &  Vtot 
)
void Nektar::VariableConverter::GetDynamicViscosity ( const Array< OneD, const NekDouble > &  temperature,
Array< OneD, NekDouble > &  mu 
)
void Nektar::VariableConverter::GetEnthalpy ( const Array< OneD, const Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  pressure,
Array< OneD, NekDouble > &  enthalpy 
)
void Nektar::VariableConverter::GetEntropy ( const Array< OneD, const Array< OneD, NekDouble > > &  physfield,
const Array< OneD, const NekDouble > &  pressure,
const Array< OneD, const NekDouble > &  temperature,
Array< OneD, NekDouble > &  entropy 
)
void Nektar::VariableConverter::GetMach ( Array< OneD, Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  soundspeed,
Array< OneD, NekDouble > &  mach 
)
void Nektar::VariableConverter::GetPressure ( const Array< OneD, const Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  pressure 
)

Calculate the pressure field $ p = (\gamma-1)(E-\frac{1}{2}\rho\| \mathbf{v} \|^2) $ assuming an ideal gas law.

Parameters
physfieldInput momentum.
pressureComputed pressure field.

Definition at line 96 of file VariableConverter.cpp.

References m_gamma, m_spacedim, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vdiv(), Vmath::Vmul(), and Vmath::Vvtvp().

99  {
100  int nPts = physfield[0].num_elements();
101  NekDouble alpha = -0.5;
102 
103  // Calculate ||rho v||^2
104  Vmath::Vmul(nPts, physfield[1], 1, physfield[1], 1, pressure, 1);
105  for (int i = 1; i < m_spacedim; ++i)
106  {
107  Vmath::Vvtvp(nPts, physfield[1+i], 1, physfield[1+i], 1,
108  pressure, 1, pressure, 1);
109  }
110  // Divide by rho to get rho*||v||^2
111  Vmath::Vdiv (nPts, pressure, 1, physfield[0], 1, pressure, 1);
112  // pressure <- E - 0.5*pressure
113  Vmath::Svtvp(nPts, alpha,
114  pressure, 1, physfield[m_spacedim+1], 1, pressure, 1);
115  // Multiply by (gamma-1)
116  Vmath::Smul (nPts, m_gamma-1, pressure, 1, pressure, 1);
117  }
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:485
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:442
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:241
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:213
double NekDouble
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:183
void Nektar::VariableConverter::GetPressure ( const Array< OneD, const Array< OneD, NekDouble > > &  physfield,
const Array< OneD, const Array< OneD, NekDouble > > &  velocity,
Array< OneD, NekDouble > &  pressure 
)

Calculate the pressure field $ p = (\gamma-1)(E-\frac{1}{2}\rho\| \mathbf{v} \|^2) $ assuming an ideal gas law.

This is a slightly optimised way to calculate the pressure field which avoids division by the density field if the velocity field has already been calculated.

Parameters
physfieldInput momentum.
velocityVelocity vector.
pressureComputed pressure field.

Definition at line 132 of file VariableConverter.cpp.

References m_gamma, m_spacedim, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vmul(), and Vmath::Vvtvp().

136  {
137  int nPts = physfield[0].num_elements();
138  NekDouble alpha = -0.5;
139 
140  // Calculate ||\rho v||^2.
141  Vmath::Vmul (nPts, velocity[0], 1, physfield[1], 1, pressure, 1);
142  for (int i = 1; i < m_spacedim; ++i)
143  {
144  Vmath::Vvtvp(nPts, velocity[i], 1, physfield[1+i], 1,
145  pressure, 1, pressure, 1);
146  }
147  // pressure <- E - 0.5*pressure
148  Vmath::Svtvp(nPts, alpha,
149  pressure, 1, physfield[m_spacedim+1], 1, pressure, 1);
150  // Multiply by (gamma-1).
151  Vmath::Smul (nPts, m_gamma-1, pressure, 1, pressure, 1);
152  }
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:485
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:442
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:213
double NekDouble
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:183
void Nektar::VariableConverter::GetSensor ( const MultiRegions::ExpListSharedPtr field,
const Array< OneD, const Array< OneD, NekDouble > > &  physarray,
Array< OneD, NekDouble > &  Sensor,
Array< OneD, NekDouble > &  SensorKappa 
)
void Nektar::VariableConverter::GetSoundSpeed ( const Array< OneD, Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  pressure,
Array< OneD, NekDouble > &  soundspeed 
)
void Nektar::VariableConverter::GetTemperature ( const Array< OneD, const Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  pressure,
Array< OneD, NekDouble > &  temperature 
)
void Nektar::VariableConverter::GetVelocityVector ( const Array< OneD, Array< OneD, NekDouble > > &  physfield,
Array< OneD, Array< OneD, NekDouble > > &  velocity 
)

Member Data Documentation

NekDouble Nektar::VariableConverter::m_gamma
protected

Definition at line 106 of file VariableConverter.h.

Referenced by GetPressure(), and VariableConverter().

NekDouble Nektar::VariableConverter::m_gasConstant
protected

Definition at line 109 of file VariableConverter.h.

Referenced by VariableConverter().

NekDouble Nektar::VariableConverter::m_Kappa
protected

Definition at line 113 of file VariableConverter.h.

Referenced by VariableConverter().

NekDouble Nektar::VariableConverter::m_mu
protected

Definition at line 110 of file VariableConverter.h.

Referenced by VariableConverter().

NekDouble Nektar::VariableConverter::m_mu0
protected

Definition at line 114 of file VariableConverter.h.

Referenced by VariableConverter().

NekDouble Nektar::VariableConverter::m_pInf
protected

Definition at line 107 of file VariableConverter.h.

Referenced by VariableConverter().

NekDouble Nektar::VariableConverter::m_rhoInf
protected

Definition at line 108 of file VariableConverter.h.

Referenced by VariableConverter().

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

Definition at line 104 of file VariableConverter.h.

Referenced by VariableConverter().

NekDouble Nektar::VariableConverter::m_Skappa
protected

Definition at line 112 of file VariableConverter.h.

Referenced by VariableConverter().

int Nektar::VariableConverter::m_spacedim
protected

Definition at line 105 of file VariableConverter.h.

Referenced by GetPressure().

NekDouble Nektar::VariableConverter::m_thermalConductivity
protected

Definition at line 111 of file VariableConverter.h.

Referenced by VariableConverter().