44 VariableConverter::VariableConverter(
46 : m_session(pSession), m_spacedim(spaceDim)
50 m_session->LoadSolverInfo(
"EquationOfState", eosType,
"IdealGas");
80 int nPts = physfield[0].num_elements();
86 Vmath::Vvtvp(nPts, physfield[i + 1], 1, physfield[i + 1], 1, tmp, 1,
94 Vmath::Vsub(nPts, physfield[m_spacedim + 1], 1, tmp, 1, energy, 1);
96 Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
106 int nPts = physfield[0].num_elements();
114 Vmath::Vdiv(nPts, pressure, 1, physfield[0], 1, enthalpy, 1);
116 Vmath::Vadd(nPts, energy, 1, enthalpy, 1, enthalpy, 1);
130 const int nPts = physfield[0].num_elements();
134 Vmath::Vdiv(nPts, physfield[1 + i], 1, physfield[0], 1, velocity[i], 1);
149 const int nPts = physfield[0].num_elements();
151 Vmath::Vmul(nPts, physfield[1], 1, physfield[1], 1, mach, 1);
155 Vmath::Vvtvp(nPts, physfield[1 + i], 1, physfield[1 + i], 1, mach, 1,
159 Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
160 Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
163 Vmath::Vdiv(nPts, mach, 1, soundspeed, 1, mach, 1);
182 const int nPts = temperature.num_elements();
188 for (
int i = 0; i < nPts; ++i)
190 ratio = temperature[i] / T_star;
191 mu[i] = mu_star * ratio * sqrt(ratio) * (1 + C) / (ratio + C);
199 const int nPts = physfield[0].num_elements();
215 Vmath::Vvtvp(nPts, velocity[i], 1, velocity[i], 1, Vtot, 1, Vtot, 1);
232 for (
int e = 0; e < field->GetExpSize(); e++)
234 int numModesElement = expOrderElement[e];
235 int nElmtPoints = field->GetExp(e)->GetTotPoints();
236 int physOffset = field->GetPhys_Offset(e);
237 int nElmtCoeffs = field->GetExp(e)->GetNcoeffs();
238 int numCutOff = numModesElement - offset;
240 if (numModesElement <= offset)
243 tmp = Sensor + physOffset, 1);
245 tmp = SensorKappa + physOffset, 1);
251 tmp = physarray[0] + physOffset);
254 field->GetExp(e)->FwdTrans(elmtPhys, elmtCoeffs);
261 field->GetExp(e)->ReduceOrderCoeffs(numCutOff, elmtCoeffs,
265 field->GetExp(e)->BwdTrans(reducedElmtCoeffs, reducedElmtPhys);
272 Vmath::Vsub(nElmtPoints, elmtPhys, 1, reducedElmtPhys, 1, difference,
275 numerator =
Vmath::Dot(nElmtPoints, difference, difference);
276 denominator =
Vmath::Dot(nElmtPoints, elmtPhys, elmtPhys);
278 NekDouble elmtSensor = sqrt(numerator / denominator);
281 Vmath::Fill(nElmtPoints, elmtSensor, tmp = Sensor + physOffset, 1);
284 order = max(numModesElement-1, 1);
287 Skappa =
m_Skappa - 4.25 * log10(static_cast<NekDouble>(order));
296 if (elmtSensor < (Skappa-
m_Kappa))
300 else if (elmtSensor > (Skappa +
m_Kappa))
302 elmtSensorKappa = 1.0;
306 elmtSensorKappa = 0.5 *
307 (1 + sin(M_PI * (elmtSensor - Skappa) / (2 *
m_Kappa)));
310 tmp = SensorKappa + physOffset, 1);
324 int nPts = physfield[0].num_elements();
329 for (
int i = 0; i < nPts; ++i)
331 pressure[i] =
m_eos->GetPressure(physfield[0][i], energy[i]);
345 int nPts = physfield[0].num_elements();
350 for (
int i = 0; i < nPts; ++i)
352 temperature[i] =
m_eos->GetTemperature(physfield[0][i], energy[i]);
366 int nPts = physfield[0].num_elements();
371 for (
int i = 0; i < nPts; ++i)
373 soundspeed[i] =
m_eos->GetSoundSpeed(physfield[0][i], energy[i]);
387 int nPts = physfield[0].num_elements();
392 for (
int i = 0; i < nPts; ++i)
394 entropy[i] =
m_eos->GetEntropy(physfield[0][i], energy[i]);
409 int nPts = rho.num_elements();
411 for (
int i = 0; i < nPts; ++i)
413 energy[i] =
m_eos->GetEFromRhoP(rho[i], pressure[i]);
428 int nPts = pressure.num_elements();
430 for (
int i = 0; i < nPts; ++i)
432 rho[i] =
m_eos->GetRhoFromPT(pressure[i], temperature[i]);
EquationOfStateSharedPtr m_eos
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void GetEFromRhoP(const Array< OneD, NekDouble > &rho, const Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &energy)
Compute using the equation of state.
void GetPressure(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &pressure)
Calculate the pressure using the equation of state.
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
static const NekDouble kNekSqrtTol
void GetEntropy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &entropy)
Compute the entropy using the equation of state.
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.
void GetAbsoluteVelocity(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &Vtot)
LibUtilities::SessionReaderSharedPtr m_session
void GetEnthalpy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &enthalpy)
Compute the specific enthalpy .
void GetDynamicViscosity(const Array< OneD, const NekDouble > &temperature, Array< OneD, NekDouble > &mu)
Compute the dynamic viscosity using the Sutherland's law , where: = 1.7894 * 10^-5 Kg / (m * s) T_st...
void GetMach(Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &soundspeed, Array< OneD, NekDouble > &mach)
Compute the mach number .
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
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)
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
~VariableConverter()
Destructor for VariableConverter class.
void GetTemperature(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &temperature)
Compute the temperature using the equation of state.
T Dot(int n, const T *w, const T *x)
vvtvp (vector times vector times vector): z = w*x*y
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.
void GetSoundSpeed(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &soundspeed)
Compute the sound speed 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 GetInternalEnergy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &energy)
Compute the specific internal energy .
void GetRhoFromPT(const Array< OneD, NekDouble > &pressure, const Array< OneD, NekDouble > &temperature, Array< OneD, NekDouble > &rho)
Compute using the equation of state.
void Zero(int n, T *x, const int incx)
Zero vector.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
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.
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.