47 VariableConverter::VariableConverter(
50 : m_session(pSession), m_spacedim(spaceDim)
54 m_session->LoadSolverInfo(
"EquationOfState", eosType,
"IdealGas");
96 std::string viscosityType;
97 m_session->LoadSolverInfo(
"ViscosityType", viscosityType,
"Constant");
98 if (
"Variable" == viscosityType)
102 "The Tref should be given in Kelvin for using the Sutherland's law "
103 "of dynamic viscosity. The default is 288.15. Note the mu or "
104 "Reynolds number should coorespond to this temperature.");
125 size_t nPts = physfield[
m_spacedim + 1].size();
131 Vmath::Vvtvp(nPts, physfield[i + 1], 1, physfield[i + 1], 1, energy, 1,
135 Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
147 int nPts = physfield[0].size();
155 Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
165 int nPts = physfield[0].size();
175 Vmath::Vadd(nPts, energy, 1, enthalpy, 1, enthalpy, 1);
189 const int nPts = physfield[0].size();
193 Vmath::Vdiv(nPts, physfield[1 + i], 1, physfield[0], 1, velocity[i], 1);
208 const int nPts = physfield[0].size();
210 Vmath::Vmul(nPts, physfield[1], 1, physfield[1], 1, mach, 1);
214 Vmath::Vvtvp(nPts, physfield[1 + i], 1, physfield[1 + i], 1, mach, 1,
218 Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
219 Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
222 Vmath::Vdiv(nPts, mach, 1, soundspeed, 1, mach, 1);
243 const int nPts = temperature.size();
245 for (
int i = 0; i < nPts; ++i)
259 const int nPts = temperature.size();
263 for (
int i = 0; i < nPts; ++i)
276 const int nPts = physfield[0].size();
292 Vmath::Vvtvp(nPts, velocity[i], 1, velocity[i], 1, Vtot, 1, Vtot, 1);
308 int nPts = physfield[0].size();
313 for (
int i = 0; i < nPts; ++i)
315 pressure[i] =
m_eos->GetPressure(physfield[0][i], energy[i]);
329 int nPts = physfield[0].size();
334 for (
int i = 0; i < nPts; ++i)
336 temperature[i] =
m_eos->GetTemperature(physfield[0][i], energy[i]);
350 int nPts = physfield[0].size();
355 for (
int i = 0; i < nPts; ++i)
357 soundspeed[i] =
m_eos->GetSoundSpeed(physfield[0][i], energy[i]);
371 int nPts = physfield[0].size();
376 for (
int i = 0; i < nPts; ++i)
378 entropy[i] =
m_eos->GetEntropy(physfield[0][i], energy[i]);
393 int nPts = rho.size();
395 for (
int i = 0; i < nPts; ++i)
414 for (
int i = 0; i < nPts; ++i)
426 auto nTracePts = fields[0]->GetTrace()->GetTotPoints();
429 auto nPts = fields[0]->GetTotPoints();
460 fields[0]->GetFwdBwdTracePhys(
m_muAv, muFwd, muBwd,
false,
false,
false);
461 for (
size_t p = 0;
p < nTracePts; ++
p)
486 auto nElements = fields[0]->GetExpSize();
494 auto expdim = fields[0]->GetGraph()->GetMeshDimension();
495 for (
size_t e = 0; e < nElements; e++)
504 for (
size_t i = 0; i < exp3D->GetNtraces(); ++i)
507 h, exp3D->GetGeom3D()->GetEdge(i)->GetVertex(0)->dist(*(
508 exp3D->GetGeom3D()->GetEdge(i)->GetVertex(1))));
517 for (
size_t i = 0; i < exp2D->GetNtraces(); ++i)
520 h, exp2D->GetGeom2D()->GetEdge(i)->GetVertex(0)->dist(*(
521 exp2D->GetGeom2D()->GetEdge(i)->GetVertex(1))));
530 h = min(h, exp1D->
GetGeom1D()->GetVertex(0)->dist(
531 *(exp1D->GetGeom1D()->GetVertex(1))));
537 ASSERTL0(
false,
"Dimension out of bound.")
542 m_hOverP[e] = h / max(pOrderElmt[e] - 1, 1);
563 for (
int e = 0; e < field->GetExpSize(); e++)
565 int numModesElement = expOrderElement[e];
566 int nElmtPoints = field->GetExp(e)->GetTotPoints();
567 int physOffset = field->GetPhys_Offset(e);
568 int nElmtCoeffs = field->GetExp(e)->GetNcoeffs();
569 int numCutOff = numModesElement - offset;
571 if (numModesElement <= offset)
573 Vmath::Fill(nElmtPoints, 0.0, tmp = Sensor + physOffset, 1);
574 Vmath::Fill(nElmtPoints, 0.0, tmp = SensorKappa + physOffset, 1);
580 tmp = physarray[0] + physOffset);
583 field->GetExp(e)->FwdTrans(elmtPhys, elmtCoeffs);
590 field->GetExp(e)->ReduceOrderCoeffs(numCutOff, elmtCoeffs,
594 field->GetExp(e)->BwdTrans(reducedElmtCoeffs, reducedElmtPhys);
601 Vmath::Vsub(nElmtPoints, elmtPhys, 1, reducedElmtPhys, 1, difference,
604 numerator =
Vmath::Dot(nElmtPoints, difference, difference);
605 denominator =
Vmath::Dot(nElmtPoints, elmtPhys, elmtPhys);
610 Vmath::Fill(nElmtPoints, elmtSensor, tmp = Sensor + physOffset, 1);
613 order = max(numModesElement - 1, 1);
625 if (elmtSensor < (Skappa -
m_Kappa))
629 else if (elmtSensor > (Skappa +
m_Kappa))
631 elmtSensorKappa = 1.0;
636 0.5 * (1 + sin(M_PI * (elmtSensor - Skappa) / (2 *
m_Kappa)));
639 tmp = SensorKappa + physOffset, 1);
653 auto nPts = consVar[0].size();
660 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambdas, 1);
664 GetSensor(fields[0], consVar, Sensor, muAv, 1);
667 auto nElmt = fields[0]->GetExpSize();
668 for (
size_t e = 0; e < nElmt; ++e)
670 auto physOffset = fields[0]->GetPhys_Offset(e);
671 auto nElmtPoints = fields[0]->GetExp(e)->GetTotPoints();
675 LambdaElmt =
Vmath::Vmax(nElmtPoints, tmp = Lambdas + physOffset, 1);
679 Vmath::Vsum(nElmtPoints, tmp = consVar[0] + physOffset, 1);
680 rhoAve = rhoAve / nElmtPoints;
685 Vmath::Smul(nElmtPoints, LambdaElmt, tmp = muAv + physOffset, 1,
686 tmp = muAv + physOffset, 1);
701 auto nPts = consVar[0].size();
714 auto nElmt = fields[0]->GetExpSize();
715 for (
size_t e = 0; e < nElmt; ++e)
717 auto nElmtPoints = fields[0]->GetExp(e)->GetTotPoints();
718 auto physOffset = fields[0]->GetPhys_Offset(e);
719 auto physEnd = physOffset + nElmtPoints;
724 for (
size_t p = physOffset;
p < physEnd; ++
p)
730 divTmp = std::max(divTmp, 0.0);
734 NekDouble lambda = sSpeedTmp + absVelocity[
p];
735 muAv[
p] = sensor * rho * lambda * hOpTmp;
750 NekDouble eps = std::numeric_limits<NekDouble>::epsilon();
754 auto nPts = div.size();
755 for (
size_t p = 0;
p < nPts; ++
p)
759 NekDouble denDuc = tmpDiv2 + curlSquare[
p] + eps;
#define ASSERTL0(condition, msg)
#define WARNINGL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
SpatialDomains::Geometry1DSharedPtr GetGeom1D() const
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
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.
NekDouble m_TRatioSutherland
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)
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 ,.
std::string m_shockSensorType
void GetEnthalpy(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &enthalpy)
Compute the specific enthalpy .
std::string m_shockCaptureType
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.
NekDouble m_oneOverT_star
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)
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.
std::string m_ducrosSensor
~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 .
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< Expansion2D > Expansion2DSharedPtr
std::shared_ptr< Expansion1D > Expansion1DSharedPtr
std::shared_ptr< Expansion3D > Expansion3DSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kNekSqrtTol
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
static Array< OneD, NekDouble > NullNekDouble1DArray
T Smax(const T a, const T b, const T k)
Return the soft max of between two scalars.
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
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.
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
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
T Dot(int n, const T *w, const T *x)
vvtvp (vector times vector times vector): z = w*x*y
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 Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
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 Zero(int n, T *x, const int incx)
Zero vector.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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.
scalarT< T > sqrt(scalarT< T > in)