44 "NavierStokes equations in conservative variables.");
69 m_session->LoadParameter(
"GasConstant", gasConstant, 287.058);
84 if (
m_session->DefinesParameter(
"thermalConductivity"))
87 "Cannot define both Pr and thermalConductivity.");
89 m_session->LoadParameter(
"thermalConductivity",
105 m_session->LoadSolverInfo(
"DiffusionType", diffName,
"LDGNS");
109 if (
"InteriorPenalty" == diffName)
115 if (
"LDGNS" == diffName ||
"LDGNS3DHomogeneous1D" == diffName)
132 &NavierStokesCFE::GetViscousFluxVectorConservVar<false>,
this);
135 &NavierStokesCFE::GetViscousFluxVectorConservVar<true>,
this);
154 size_t nvariables = inarray.size();
163 for (
size_t i = 0; i < nvariables; ++i)
204 for (
size_t i = 0; i < nvariables; ++i)
206 Vmath::Vadd(npointsOut, outarrayDiff[i], 1, outarray[i], 1,
217 for (
size_t i = 0; i < nvariables - 1; ++i)
226 m_varConv->GetPressure(inarray, inarrayDiff[0]);
229 m_varConv->GetTemperature(inarray, inarrayDiff[nvariables - 2]);
232 m_varConv->GetVelocityVector(inarray, inarrayDiff);
246 m_varConv->GetTemperature(pFwd, inFwd[nvariables - 2]);
247 m_varConv->GetTemperature(pBwd, inBwd[nvariables - 2]);
249 m_varConv->GetVelocityVector(pFwd, inFwd);
250 m_varConv->GetVelocityVector(pBwd, inBwd);
257 outarrayDiff, inFwd, inBwd);
262 outarrayDiff, inFwd, inBwd);
265 for (
size_t i = 0; i < nvariables; ++i)
267 Vmath::Vadd(npointsOut, outarrayDiff[i], 1, outarray[i], 1,
289 size_t nScalar = physfield.size();
290 size_t nPts = physfield[0].size();
300 thermalConductivity);
305 Vmath::Vadd(nPts, divVel, 1, derivativesO1[j][j], 1, divVel, 1);
323 Vmath::Vadd(nPts, derivativesO1[i][j], 1, derivativesO1[j][i], 1,
324 viscousTensor[i][j + 1], 1);
326 Vmath::Vmul(nPts, mu, 1, viscousTensor[i][j + 1], 1,
327 viscousTensor[i][j + 1], 1);
332 Vmath::Vadd(nPts, viscousTensor[i][j + 1], 1, divVel, 1,
333 viscousTensor[i][j + 1], 1);
339 viscousTensor[j][i + 1], 1);
351 Vmath::Vvtvp(nPts, physfield[j], 1, viscousTensor[i][j + 1], 1,
374 size_t nScalar = physfield.size();
375 size_t nPts =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
376 size_t nPts_orig = physfield[0].size();
388 thermalConductivity);
398 m_fields[0]->PhysInterp1DScaled(OneDptscale, physfield[i],
406 m_fields[0]->PhysInterp1DScaled(OneDptscale, derivativesO1[i][j],
421 Vmath::Vadd(nPts, divVel, 1, deriv_interp[j][j], 1, divVel, 1);
439 Vmath::Vadd(nPts, deriv_interp[i][j], 1, deriv_interp[j][i], 1,
440 out_interp[i][j + 1], 1);
443 out_interp[i][j + 1], 1);
448 Vmath::Vadd(nPts, out_interp[i][j + 1], 1, divVel, 1,
449 out_interp[i][j + 1], 1);
454 out_interp[j][i + 1] = out_interp[i][j + 1];
466 Vmath::Vvtvp(nPts, vel_interp[j], 1, out_interp[i][j + 1], 1,
481 m_fields[0]->PhysGalerkinProjection1DScaled(
482 OneDptscale, out_interp[i][j], viscousTensor[i][j]);
499 size_t nConvectiveFields = consvar.size();
501 size_t nengy = nConvectiveFields - 1;
508 size_t nLengthArray = 0;
511 size_t nBndRegions =
m_fields[nengy]->GetBndCondExpansions().size();
512 for (
size_t j = 0; j < nBndRegions; ++j)
515 ->GetBndConditions()[j]
522 m_fields[nengy]->GetBndCondExpansions()[j]->GetExpSize();
523 for (
size_t e = 0; e < nBndEdges; ++e)
525 size_t nBndEdgePts =
m_fields[nengy]
526 ->GetBndCondExpansions()[j]
530 int id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
531 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
535 m_fields[nengy]->GetBndConditions()[j]->GetUserDefined(),
538 if (nBndEdgePts != nLengthArray)
540 for (
size_t i = 0; i < nConvectiveFields; ++i)
548 nLengthArray = nBndEdgePts;
559 for (
size_t k = 0; k < nConvectiveFields; ++k)
565 m_varConv->GetPressure(bndCons, bndPressure);
567 m_varConv->GetRhoFromPT(bndPressure, bndTotEngy, bndRho);
568 m_varConv->GetEFromRhoP(bndRho, bndPressure, bndIntEndy);
569 m_varConv->GetDynamicEnergy(bndCons, bndTotEngy);
571 Vmath::Vvtvp(nBndEdgePts, bndIntEndy, 1, bndCons[ndens], 1,
572 bndTotEngy, 1, bndTotEngy, 1);
575 tmp = consvar[nengy] + id2, 1);
591 size_t nConvectiveFields = inarray.size();
592 size_t nPts = inaverg[nConvectiveFields - 1].size();
594 for (
size_t i = 0; i < nConvectiveFields - 1; ++i)
596 nonZeroIndex[i] = i + 1;
602 m_varConv->GetTemperature(inaverg, temperature);
605 std::vector<NekDouble> inAvgTmp(nConvectiveFields);
606 std::vector<NekDouble> inTmp(nConvectiveFields);
607 std::vector<NekDouble> outTmp(nConvectiveFields);
608 for (
size_t d = 0;
d < nDim; ++
d)
610 for (
size_t nderiv = 0; nderiv < nDim; ++nderiv)
612 for (
size_t p = 0;
p < nPts; ++
p)
615 for (
size_t f = 0; f < nConvectiveFields; ++f)
617 inAvgTmp[f] = inaverg[f][
p];
618 inTmp[f] = inarray[f][
p];
622 inAvgTmp.data(), inTmp.data(),
623 mu[
p], outTmp.data());
625 for (
size_t f = 0; f < nConvectiveFields; ++f)
627 outarray[
d][f][
p] += normal[nderiv][
p] * outTmp[f];
642 size_t nTracePts = uFwd[0].size();
645 size_t nVariables = uFwd.size();
648 uBwd[nVariables - 1], 1, tAve, 1);
657 for (
size_t i = 0; i < nVariables; ++i)
660 Vmath::Vsub(nTracePts, uFwd[i], 1, uBwd[i], 1, penaltyCoeff[i], 1);
662 if (i < nVariables - 1)
664 Vmath::Vmul(nTracePts, muAve, 1, penaltyCoeff[i], 1,
669 Vmath::Vmul(nTracePts, tcAve, 1, penaltyCoeff[i], 1,
683 size_t nPts = temperature.size();
685 for (
size_t p = 0;
p < nPts; ++
p)
695 size_t nTracePts =
m_fields[0]->GetTrace()->GetTotPoints();
696 if (nPts != nTracePts)
731 size_t nDim = fields[0]->GetCoordim(0);
732 size_t nVar = cnsVar.size();
733 size_t nPts = cnsVar[0].size();
734 size_t nPtsTrc = cnsVarFwd[0].size();
738 primVarBwd(nVar - 1);
740 for (
unsigned short d = 0;
d < nVar - 2; ++
d)
746 size_t ergLoc = nVar - 2;
754 for (
unsigned short d = 0;
d < nVar - 2; ++
d)
757 for (
size_t p = 0;
p < nPts; ++
p)
759 primVar[
d][
p] = cnsVar[
d + 1][
p] / cnsVar[0][
p];
762 for (
size_t p = 0;
p < nPtsTrc; ++
p)
764 primVarFwd[
d][
p] = cnsVarFwd[
d + 1][
p] / cnsVarFwd[0][
p];
765 primVarBwd[
d][
p] = cnsVarBwd[
d + 1][
p] / cnsVarBwd[0][
p];
771 for (
unsigned short j = 0; j < nDim; ++j)
774 for (
unsigned short i = 0; i < nVar - 1; ++i)
781 m_diffusion->DiffuseCalcDerivative(fields, primVar, primVarDer, primVarFwd,
796 size_t nDim = pVarDer.size();
797 size_t nPts = div.size();
800 for (
size_t p = 0;
p < nPts; ++
p)
803 for (
unsigned short j = 0; j < nDim; ++j)
805 divTmp += pVarDer[j][j][
p];
813 for (
size_t p = 0;
p < nPts; ++
p)
837 curl0sqr += curl1sqr + curl2sqr;
839 curlSquare[
p] = curl0sqr;
844 for (
size_t p = 0;
p < nPts; ++
p)
853 curlSquare[
p] = curl * curl;
864 std::vector<std::string> &variables)
867 m_session->MatchSolverInfo(
"OutputExtraFields",
"True", extraFields,
true);
870 const int nPhys =
m_fields[0]->GetNpoints();
871 const int nCoeffs =
m_fields[0]->GetNcoeffs();
874 for (
size_t i = 0; i <
m_fields.size(); ++i)
892 m_varConv->GetVelocityVector(cnsVar, velocity);
894 m_varConv->GetTemperature(cnsVar, temperature);
896 m_varConv->GetSoundSpeed(cnsVar, soundspeed);
897 m_varConv->GetMach(cnsVar, soundspeed, mach);
900 m_session->LoadParameter(
"SensorOffset", sensorOffset, 1);
909 string velNames[3] = {
"u",
"v",
"w"};
912 m_fields[0]->FwdTransLocalElmt(velocity[i], velFwd[i]);
913 variables.push_back(velNames[i]);
914 fieldcoeffs.push_back(velFwd[i]);
918 m_fields[0]->FwdTransLocalElmt(temperature, TFwd);
919 m_fields[0]->FwdTransLocalElmt(entropy, sFwd);
920 m_fields[0]->FwdTransLocalElmt(soundspeed, aFwd);
921 m_fields[0]->FwdTransLocalElmt(mach, mFwd);
922 m_fields[0]->FwdTransLocalElmt(sensor, sensFwd);
924 variables.push_back(
"p");
925 variables.push_back(
"T");
926 variables.push_back(
"s");
927 variables.push_back(
"a");
928 variables.push_back(
"Mach");
929 variables.push_back(
"Sensor");
930 fieldcoeffs.push_back(pFwd);
931 fieldcoeffs.push_back(TFwd);
932 fieldcoeffs.push_back(sFwd);
933 fieldcoeffs.push_back(aFwd);
934 fieldcoeffs.push_back(mFwd);
935 fieldcoeffs.push_back(sensFwd);
944 variables.push_back(
"ArtificialVisc");
945 fieldcoeffs.push_back(sensorFwd);
954 for (
size_t i = 0; i <
m_fields.size(); ++i)
958 m_fields[i]->GetFwdBwdTracePhys(cnsVar[i], cnsVarFwd[i],
967 m_fields[0]->FwdTransLocalElmt(div, divFwd);
968 variables.push_back(
"div");
969 fieldcoeffs.push_back(divFwd);
972 m_fields[0]->FwdTransLocalElmt(curlSquare, curlFwd);
973 variables.push_back(
"curl^2");
974 fieldcoeffs.push_back(curlFwd);
980 variables.push_back(
"ArtificialVisc");
981 fieldcoeffs.push_back(muavFwd);
988 if (type ==
"NonSmooth" || type ==
"Physical" || type ==
"Off")
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
NekDouble m_bndEvaluateTime
std::string m_shockCaptureType
SolverUtils::DiffusionSharedPtr m_diffusion
void v_InitObject(bool DeclareFields=true) override
Initialization object for CompressibleFlowSystem class.
VariableConverterSharedPtr m_varConv
void SetBoundaryConditionsBwdWeight()
Set up a weight on physical boundaries for boundary condition applications.
ArtificialDiffusionSharedPtr m_artificialDiffusion
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
NavierStokesCFE(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
void SpecialBndTreat(Array< OneD, Array< OneD, NekDouble > > &consvar)
For very special treatment. For general boundaries it does nothing But for WallViscous and WallAdiaba...
void GetDivCurlFromDvelT(const TensorOfArray3D< NekDouble > &pVarDer, Array< OneD, NekDouble > &div, Array< OneD, NekDouble > &curlSquare)
Get divergence and curl from velocity derivative tensor.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
void v_InitObject(bool DeclareField=true) override
Initialization object for CompressibleFlowSystem class.
void GetDivCurlSquared(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &cnsVar, Array< OneD, NekDouble > &div, Array< OneD, NekDouble > &curlSquare, const Array< OneD, Array< OneD, NekDouble > > &cnsVarFwd, const Array< OneD, Array< OneD, NekDouble > > &cnsVarBwd)
Get divergence and curl squared.
static std::string className
void InitObject_Explicit()
void v_DoDiffusion(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const Array< OneD, Array< OneD, NekDouble > > &pFwd, const Array< OneD, Array< OneD, NekDouble > > &pBwd) override
NekDouble m_thermalConductivityRef
bool m_is_mu_variable
flag to switch between constant viscosity and Sutherland an enum could be added for more options
void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables) override
bool m_is_shockCaptPhys
flag for shock capturing switch on/off an enum could be added for more options
bool v_SupportsShockCaptType(const std::string type) const override
void GetViscousSymmtrFluxConservVar(const size_t nSpaceDim, const Array< OneD, Array< OneD, NekDouble > > &inaverg, const Array< OneD, Array< OneD, NekDouble > > &inarray, TensorOfArray3D< NekDouble > &outarray, Array< OneD, int > &nonZeroIndex, const Array< OneD, Array< OneD, NekDouble > > &normals)
Calculate and return the Symmetric flux in IP method.
void GetViscosityAndThermalCondFromTemp(const Array< OneD, NekDouble > &temperature, Array< OneD, NekDouble > &mu, Array< OneD, NekDouble > &thermalCond)
Update viscosity todo: add artificial viscosity here.
virtual void v_GetViscousFluxVector(const Array< OneD, const Array< OneD, NekDouble > > &physfield, TensorOfArray3D< NekDouble > &derivatives, TensorOfArray3D< NekDouble > &viscousTensor)
Return the flux vector for the LDG diffusion problem.
virtual void v_GetFluxPenalty(const Array< OneD, const Array< OneD, NekDouble > > &uFwd, const Array< OneD, const Array< OneD, NekDouble > > &uBwd, Array< OneD, Array< OneD, NekDouble > > &penaltyCoeff)
Return the penalty vector for the LDGNS diffusion problem.
bool m_is_diffIP
flag to switch between IP and LDG an enum could be added for more options
void GetViscousFluxBilinearFormKernel(const unsigned short nDim, const unsigned short FluxDirection, const unsigned short DerivDirection, const T *inaverg, const T *injumpp, const T &mu, T *outarray)
Calculate diffusion flux using the Jacobian form.
void GetViscosityAndThermalCondFromTempKernel(const T &temperature, T &mu, T &thermalCond)
virtual void v_GetViscousFluxVectorDeAlias(const Array< OneD, const Array< OneD, NekDouble > > &physfield, TensorOfArray3D< NekDouble > &derivatives, TensorOfArray3D< NekDouble > &viscousTensor)
Return the flux vector for the LDG diffusion problem.
std::string m_ViscosityType
Array< OneD, Array< OneD, NekDouble > > m_gridVelocityTrace
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
Base class for unsteady solvers.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
DiffusionFactory & GetDiffusionFactory()
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::vector< double > d(NPUPPER *NPUPPER)
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
void Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
Svtsvtp (scalar times vector plus scalar times vector):
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
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 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.
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.