50 : m_session(pSession), m_spacedim(spaceDim)
54 m_session->LoadSolverInfo(
"EquationOfState", eosType,
"IdealGas");
100 if (
m_smoothing ==
"C0" && pGraph.get() !=
nullptr)
107 std::string viscosityType;
108 m_session->LoadSolverInfo(
"ViscosityType", viscosityType,
"Constant");
109 if (
"Variable" == viscosityType)
113 "The Tref should be given in Kelvin for using the Sutherland's law "
114 "of dynamic viscosity. The default is 288.15. Note the mu or "
115 "Reynolds number should coorespond to this temperature.");
136 size_t nPts = physfield[
m_spacedim + 1].size();
142 Vmath::Vvtvp(nPts, physfield[i + 1], 1, physfield[i + 1], 1, energy, 1,
146 Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
158 size_t nPts = physfield[0].size();
166 Vmath::Vdiv(nPts, energy, 1, physfield[0], 1, energy, 1);
176 size_t nPts = physfield[0].size();
186 Vmath::Vadd(nPts, energy, 1, enthalpy, 1, enthalpy, 1);
200 const size_t nPts = physfield[0].size();
204 Vmath::Vdiv(nPts, physfield[1 + i], 1, physfield[0], 1, velocity[i], 1);
219 const size_t nPts = physfield[0].size();
221 Vmath::Vmul(nPts, physfield[1], 1, physfield[1], 1, mach, 1);
225 Vmath::Vvtvp(nPts, physfield[1 + i], 1, physfield[1 + i], 1, mach, 1,
229 Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
230 Vmath::Vdiv(nPts, mach, 1, physfield[0], 1, mach, 1);
233 Vmath::Vdiv(nPts, mach, 1, soundspeed, 1, mach, 1);
254 const size_t nPts = temperature.size();
256 for (
size_t i = 0; i < nPts; ++i)
270 const size_t nPts = temperature.size();
274 for (
size_t i = 0; i < nPts; ++i)
287 const size_t nPts = physfield[0].size();
303 Vmath::Vvtvp(nPts, velocity[i], 1, velocity[i], 1, Vtot, 1, Vtot, 1);
319 size_t nPts = physfield[0].size();
324 for (
size_t i = 0; i < nPts; ++i)
326 pressure[i] =
m_eos->GetPressure(physfield[0][i], energy[i]);
340 size_t nPts = physfield[0].size();
345 for (
size_t i = 0; i < nPts; ++i)
347 temperature[i] =
m_eos->GetTemperature(physfield[0][i], energy[i]);
361 size_t nPts = physfield[0].size();
366 for (
size_t i = 0; i < nPts; ++i)
368 soundspeed[i] =
m_eos->GetSoundSpeed(physfield[0][i], energy[i]);
382 size_t nPts = physfield[0].size();
387 for (
size_t i = 0; i < nPts; ++i)
389 entropy[i] =
m_eos->GetEntropy(physfield[0][i], energy[i]);
404 size_t nPts = rho.size();
406 for (
size_t i = 0; i < nPts; ++i)
425 for (
size_t i = 0; i < nPts; ++i)
437 size_t nTracePts = fields[0]->GetTrace()->GetTotPoints();
440 size_t nPts = fields[0]->GetTotPoints();
471 fields[0]->GetFwdBwdTracePhys(
m_muAv, muFwd, muBwd,
false,
false,
false);
472 for (
size_t p = 0;
p < nTracePts; ++
p)
497 size_t nElements = fields[0]->GetExpSize();
505 int expdim = fields[0]->GetGraph()->GetMeshDimension();
506 for (
size_t e = 0; e < nElements; e++)
515 for (
int i = 0; i < exp3D->GetNtraces(); ++i)
518 h, exp3D->GetGeom3D()->GetEdge(i)->GetVertex(0)->dist(*(
519 exp3D->GetGeom3D()->GetEdge(i)->GetVertex(1))));
528 for (
int i = 0; i < exp2D->GetNtraces(); ++i)
531 h, exp2D->GetGeom2D()->GetEdge(i)->GetVertex(0)->dist(*(
532 exp2D->GetGeom2D()->GetEdge(i)->GetVertex(1))));
541 h = min(h, exp1D->
GetGeom1D()->GetVertex(0)->dist(
542 *(exp1D->GetGeom1D()->GetVertex(1))));
548 ASSERTL0(
false,
"Dimension out of bound.")
553 m_hOverP[e] = h / max(pOrderElmt[e] - 1, 1);
574 for (
int e = 0; e <
field->GetExpSize(); e++)
576 int numModesElement = expOrderElement[e];
577 int nElmtPoints =
field->GetExp(e)->GetTotPoints();
578 int physOffset =
field->GetPhys_Offset(e);
579 int nElmtCoeffs =
field->GetExp(e)->GetNcoeffs();
580 int numCutOff = numModesElement - offset;
582 if (numModesElement <= offset)
584 Vmath::Fill(nElmtPoints, 0.0, tmp = Sensor + physOffset, 1);
585 Vmath::Fill(nElmtPoints, 0.0, tmp = SensorKappa + physOffset, 1);
591 tmp = physarray[0] + physOffset);
594 field->GetExp(e)->FwdTrans(elmtPhys, elmtCoeffs);
601 field->GetExp(e)->ReduceOrderCoeffs(numCutOff, elmtCoeffs,
605 field->GetExp(e)->BwdTrans(reducedElmtCoeffs, reducedElmtPhys);
612 Vmath::Vsub(nElmtPoints, elmtPhys, 1, reducedElmtPhys, 1, difference,
615 numerator =
Vmath::Dot(nElmtPoints, difference, difference);
616 denominator =
Vmath::Dot(nElmtPoints, elmtPhys, elmtPhys);
621 Vmath::Fill(nElmtPoints, elmtSensor, tmp = Sensor + physOffset, 1);
624 order = max(numModesElement - 1, 1);
636 if (elmtSensor < (Skappa -
m_Kappa))
640 else if (elmtSensor > (Skappa +
m_Kappa))
642 elmtSensorKappa = 1.0;
647 0.5 * (1 + sin(M_PI * (elmtSensor - Skappa) / (2 *
m_Kappa)));
650 tmp = SensorKappa + physOffset, 1);
664 size_t nPts = consVar[0].size();
671 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambdas, 1);
675 GetSensor(fields[0], consVar, Sensor, muAv, 1);
678 size_t nElmt = fields[0]->GetExpSize();
679 for (
size_t e = 0; e < nElmt; ++e)
681 int physOffset = fields[0]->GetPhys_Offset(e);
682 int nElmtPoints = fields[0]->GetExp(e)->GetTotPoints();
686 LambdaElmt =
Vmath::Vmax(nElmtPoints, tmp = Lambdas + physOffset, 1);
690 Vmath::Vsum(nElmtPoints, tmp = consVar[0] + physOffset, 1);
691 rhoAve = rhoAve / nElmtPoints;
696 Vmath::Smul(nElmtPoints, LambdaElmt, tmp = muAv + physOffset, 1,
697 tmp = muAv + physOffset, 1);
712 size_t nPts = consVar[0].size();
725 size_t nElmt = fields[0]->GetExpSize();
726 for (
size_t e = 0; e < nElmt; ++e)
728 int nElmtPoints = fields[0]->GetExp(e)->GetTotPoints();
729 int physOffset = fields[0]->GetPhys_Offset(e);
730 int physEnd = physOffset + nElmtPoints;
735 for (
int p = physOffset;
p < physEnd; ++
p)
741 divTmp = std::max(divTmp, 0.0);
745 NekDouble lambda = sSpeedTmp + absVelocity[
p];
746 muAv[
p] = sensor * rho * lambda * hOpTmp;
761 NekDouble eps = std::numeric_limits<NekDouble>::epsilon();
765 size_t nPts = div.size();
766 for (
size_t p = 0;
p < nPts; ++
p)
770 NekDouble denDuc = tmpDiv2 + curlSquare[
p] + eps;
789 "C0 projection operator not initialized in "
790 "VariableConverter::ApplyC0Smooth()");
#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()
void GetInternalEnergy(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &energy)
Compute the specific internal energy .
EquationOfStateSharedPtr m_eos
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)
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 GetAbsoluteVelocity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &Vtot)
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.
void SetAv(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const Array< OneD, NekDouble > > &consVar, const Array< OneD, NekDouble > &div=NullNekDouble1DArray, const Array< OneD, NekDouble > &curlSquared=NullNekDouble1DArray)
NekDouble m_TRatioSutherland
Array< OneD, NekDouble > m_muAvTrace
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
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
void GetPressure(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &pressure)
Calculate the pressure using the equation of state.
LibUtilities::SessionReaderSharedPtr m_session
NekDouble m_mu0
Shock sensor.
void GetTemperature(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &temperature)
Compute the temperature using the equation of state.
NekDouble m_oneOverT_star
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 GetDynamicEnergy(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &energy)
Compute the dynamic energy .
void GetSoundSpeed(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &soundspeed)
Compute the sound speed using the equation of state.
VariableConverter(const LibUtilities::SessionReaderSharedPtr &pSession, const int spaceDim, const SpatialDomains::MeshGraphSharedPtr &pGraph=nullptr)
void GetEntropy(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &entropy)
Compute the entropy using the equation of state.
void GetMach(Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &soundspeed, Array< OneD, NekDouble > &mach)
Compute the mach number .
void GetVelocityVector(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity)
Compute the velocity field given the momentum .
std::string m_ducrosSensor
~VariableConverter()
Destructor for VariableConverter class.
void GetEnthalpy(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &enthalpy)
Compute the specific enthalpy .
Array< OneD, NekDouble > & GetElmtMinHP()
Array< OneD, NekDouble > m_muAv
storage
Array< OneD, NekDouble > & GetAv()
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 kNekMachineEpsilon
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
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)
dot product
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)