41 string NavierStokesCFE::className =
43 "NavierStokesCFE", NavierStokesCFE::create,
44 "NavierStokes equations in conservative variables.");
46 NavierStokesCFE::NavierStokesCFE(
75 m_session->LoadParameter (
"GasConstant", gasConstant, 287.058);
82 int nPts =
m_fields[0]->GetNpoints();
92 if (
m_session->DefinesParameter(
"thermalConductivity"))
95 "Cannot define both Pr and thermalConductivity.");
97 m_session->LoadParameter (
"thermalConductivity",
124 m_session->LoadSolverInfo(
"DiffusionType", diffName,
"LDGNS");
128 if (
"InteriorPenalty" == diffName)
134 if (
"LDGNS" == diffName||
135 "LDGNS3DHomogeneous1D" == diffName)
154 &NavierStokesCFE::GetViscousFluxVectorConservVar<false>,
this);
157 &NavierStokesCFE::GetViscousFluxVectorConservVar<true>,
this);
181 std::vector<std::string> &variables)
184 m_session->MatchSolverInfo(
"OutputExtraFields",
"True",
188 const int nPhys =
m_fields[0]->GetNpoints();
189 const int nCoeffs =
m_fields[0]->GetNcoeffs();
192 for (
int i = 0; i <
m_fields.size(); ++i)
210 m_varConv->GetVelocityVector(tmp, velocity);
212 m_varConv->GetTemperature(tmp, temperature);
214 m_varConv->GetSoundSpeed(tmp, soundspeed);
215 m_varConv->GetMach (tmp, soundspeed, mach);
218 m_session->LoadParameter (
"SensorOffset", sensorOffset, 1);
227 string velNames[3] = {
"u",
"v",
"w"};
230 m_fields[0]->FwdTrans_IterPerExp(velocity[i], velFwd[i]);
231 variables.push_back(velNames[i]);
232 fieldcoeffs.push_back(velFwd[i]);
236 m_fields[0]->FwdTrans_IterPerExp(temperature,TFwd);
237 m_fields[0]->FwdTrans_IterPerExp(entropy, sFwd);
238 m_fields[0]->FwdTrans_IterPerExp(soundspeed, aFwd);
239 m_fields[0]->FwdTrans_IterPerExp(mach, mFwd);
240 m_fields[0]->FwdTrans_IterPerExp(sensor, sensFwd);
242 variables.push_back (
"p");
243 variables.push_back (
"T");
244 variables.push_back (
"s");
245 variables.push_back (
"a");
246 variables.push_back (
"Mach");
247 variables.push_back (
"Sensor");
248 fieldcoeffs.push_back(pFwd);
249 fieldcoeffs.push_back(TFwd);
250 fieldcoeffs.push_back(sFwd);
251 fieldcoeffs.push_back(aFwd);
252 fieldcoeffs.push_back(mFwd);
253 fieldcoeffs.push_back(sensFwd);
264 variables.push_back (
"ArtificialVisc");
265 fieldcoeffs.push_back(sensorFwd);
273 variables.push_back (
"ArtificialVisc");
274 fieldcoeffs.push_back(muavFwd);
281 variables.push_back (
"divVelSquare");
282 fieldcoeffs.push_back(dv2Fwd);
287 variables.push_back (
"curlVelSquare");
288 fieldcoeffs.push_back(cv2Fwd);
293 m_fields[0]->FwdTrans_IterPerExp(duc, ducFwd);
294 variables.push_back (
"Ducros");
295 fieldcoeffs.push_back(ducFwd);
307 size_t nvariables = inarray.size();
313 for (
int i = 0; i < nvariables; ++i)
333 for (
int i = 0; i < nvariables; ++i)
348 for (
int i = 0; i < nvariables - 1; ++i)
357 m_varConv->GetPressure(inarray, inarrayDiff[0]);
360 m_varConv->GetTemperature(inarray, inarrayDiff[nvariables - 2]);
363 m_varConv->GetVelocityVector(inarray, inarrayDiff);
377 m_varConv->GetTemperature(pFwd, inFwd[nvariables - 2]);
378 m_varConv->GetTemperature(pBwd, inBwd[nvariables - 2]);
380 m_varConv->GetVelocityVector(pFwd, inFwd);
381 m_varConv->GetVelocityVector(pBwd, inBwd);
386 outarrayDiff, inFwd, inBwd);
388 for (
int i = 0; i < nvariables; ++i)
410 size_t nScalar = physfield.size();
411 size_t nPts = physfield[0].size();
445 Vmath::Vadd(nPts, divVel, 1, derivativesO1[j][j], 1,
465 derivativesO1[j][i], 1,
466 viscousTensor[i][j+1], 1);
469 viscousTensor[i][j+1], 1,
470 viscousTensor[i][j+1], 1);
477 viscousTensor[i][j+1], 1);
483 viscousTensor[j][i+1], 1);
496 viscousTensor[i][j+1], 1,
520 size_t nScalar = physfield.size();
521 int nPts =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
522 size_t nPts_orig = physfield[0].size();
564 OneDptscale, physfield[i], vel_interp[i]);
573 OneDptscale, derivativesO1[i][j], deriv_interp[i][j]);
587 Vmath::Vadd(nPts, divVel, 1, deriv_interp[j][j], 1,
607 deriv_interp[j][i], 1,
608 out_interp[i][j+1], 1);
611 out_interp[i][j+1], 1,
612 out_interp[i][j+1], 1);
619 out_interp[i][j+1], 1);
624 out_interp[j][i+1] = out_interp[i][j+1];
637 out_interp[i][j+1], 1,
653 m_fields[0]->PhysGalerkinProjection1DScaled(
656 viscousTensor[i][j]);
674 size_t nConvectiveFields = consvar.size();
676 int nengy = nConvectiveFields - 1;
683 int nLengthArray = 0;
687 GetBndCondExpansions().size();
688 for (
int j = 0; j < nBndRegions; ++j)
690 if (
m_fields[nengy]->GetBndConditions()[j]->
691 GetBoundaryConditionType() ==
697 size_t nBndEdges =
m_fields[nengy]->
698 GetBndCondExpansions()[j]->GetExpSize();
699 for (
int e = 0; e < nBndEdges; ++e)
701 size_t nBndEdgePts =
m_fields[nengy]->
702 GetBndCondExpansions()[j]->GetExp(e)->GetTotPoints();
706 GetBndCondIDToGlobalTraceID(cnt++));
709 if (boost::iequals(
m_fields[nengy]->GetBndConditions()[j]->
710 GetUserDefined(),
"WallViscous"))
712 if (nBndEdgePts != nLengthArray)
714 for (
int i = 0; i < nConvectiveFields; ++i)
723 nLengthArray = nBndEdgePts;
734 for (
int k = 0; k < nConvectiveFields; ++k)
740 m_varConv->GetPressure(bndCons, bndPressure);
742 m_varConv->GetRhoFromPT(bndPressure, bndTotEngy, bndRho);
743 m_varConv->GetEFromRhoP(bndRho, bndPressure, bndIntEndy);
744 m_varConv->GetDynamicEnergy(bndCons, bndTotEngy);
746 Vmath::Vvtvp(nBndEdgePts, bndIntEndy, 1, bndCons[ndens], 1,
747 bndTotEngy, 1, bndTotEngy, 1);
751 tmp = consvar[nengy] + id2, 1);
778 size_t nConvectiveFields = inarray.size();
779 size_t nPts = inaverg[nConvectiveFields - 1].size();
781 for (
int i = 0; i < nConvectiveFields - 1; ++i)
783 nonZeroIndex[i] = i + 1;
786 std::vector<NekDouble> inAvgTmp(nConvectiveFields);
787 std::vector<NekDouble> inTmp(nConvectiveFields);
788 std::vector<NekDouble> outTmp(nConvectiveFields);
789 for (
int d = 0; d < nDim; ++d)
791 for (
int nderiv = 0; nderiv < nDim; ++nderiv)
793 for (
size_t p = 0;
p < nPts; ++
p)
796 for (
int f = 0; f < nConvectiveFields; ++f)
798 inAvgTmp[f] = inaverg[f][
p];
799 inTmp[f] = inarray[f][
p];
809 inAvgTmp.data(), inTmp.data(), mu, outTmp.data());
811 for (
int f = 0; f < nConvectiveFields; ++f)
813 outarray[d][f][
p] += normal[d][
p] * outTmp[f];
828 int nPts = physfield[0].size();
829 int nElements =
m_fields[0]->GetExpSize();
837 m_varConv->GetSoundSpeed(physfield, soundspeed);
838 m_varConv->GetAbsoluteVelocity(physfield, absVelocity);
840 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambdas, 1);
847 for (
int e = 0; e < nElements; e++)
849 int physOffset =
m_fields[0]->GetPhys_Offset(e);
850 int nElmtPoints =
m_fields[0]->GetExp(e)->GetTotPoints();
859 rhoAve = rhoAve / nElmtPoints;
863 LambdaElmt *=
m_mu0 * hOverP[e] * rhoAve;
865 tmp =
m_muav + physOffset, 1);
873 int nConvectiveFields = inaverg.size();
874 int nPts = inaverg[nConvectiveFields-1].size();
927 int nPts =
m_fields[0]->GetTotPoints();
938 for (
int e = 0; e <
m_fields[0]->GetExpSize(); e++)
940 int nElmtPoints =
m_fields[0]->GetExp(e)->GetTotPoints();
941 int physOffset =
m_fields[0]->GetPhys_Offset(e);
944 tmp = ducros + physOffset, 1);
945 eAve = eAve / nElmtPoints;
946 Vmath::Fill(nElmtPoints, eAve, tmp = ducros + physOffset, 1);
960 unsigned int nTracePts = uFwd[0].size();
963 unsigned int nVariables = uFwd.size();
966 0.5, uBwd[nVariables-1], 1, tAve, 1);
975 for (
int i = 0; i < nVariables; ++i)
978 Vmath::Vsub(nTracePts, uFwd[i], 1, uBwd[i], 1, penaltyCoeff[i], 1);
980 if ( i < nVariables-1 )
982 Vmath::Vmul(nTracePts, muAve, 1, penaltyCoeff[i], 1,
987 Vmath::Vmul(nTracePts, tcAve, 1, penaltyCoeff[i], 1,
1003 int nPts = temperature.size();
1005 for (
size_t p = 0;
p < nPts; ++
p)
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Array< OneD, NekDouble > m_muav
NekDouble m_bndEvaluateTime
std::string m_shockCaptureType
SolverUtils::DiffusionSharedPtr m_diffusion
Array< OneD, NekDouble > GetElmtMinHP(void)
Function to get estimate of min h/p factor per element.
VariableConverterSharedPtr m_varConv
void SetBoundaryConditionsBwdWeight()
Set up a weight on physical boundaries for boundary condition applications.
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
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.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void CalcViscosity(const Array< OneD, const Array< OneD, NekDouble >> &inaverg, Array< OneD, NekDouble > &mu)
virtual ~NavierStokesCFE()
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.
void SpecialBndTreat(Array< OneD, Array< OneD, NekDouble > > &consvar)
For very special treatment. For general boundaries it does nothing But for WallViscous and WallAdiaba...
void GetViscousSymmtrFluxConservVar(const int 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.
Array< OneD, NekDouble > m_thermalConductivity
void GetPhysicalAV(const Array< OneD, const Array< OneD, NekDouble >> &physfield)
Calculate the physical artificial viscosity.
void InitObject_Explicit()
std::string m_physicalSensorType
NekDouble m_thermalConductivityRef
bool m_is_mu_variable
flag to switch between constant viscosity and Sutherland an enum could be added for more options
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble >> &fieldcoeffs, std::vector< std::string > &variables)
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.
MultiRegions::ContFieldSharedPtr m_C0ProjectExp
void GetViscosityAndThermalCondFromTemp(const Array< OneD, NekDouble > &temperature, Array< OneD, NekDouble > &mu, Array< OneD, NekDouble > &thermalCond)
Update viscosity todo: add artificial viscosity here.
void C0Smooth(Array< OneD, NekDouble > &field)
Make field C0.
virtual void v_DoDiffusion(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const Array< OneD, const Array< OneD, NekDouble >> &pFwd, const Array< OneD, const Array< OneD, NekDouble >> &pBwd)
bool m_is_diffIP
flag to switch between IP and LDG an enum could be added for more options
void Ducros(Array< OneD, NekDouble > &field)
Applied Ducros (anti-vorticity) sensor.
Array< OneD, NekDouble > m_mu
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 GetViscosityFromTempKernel(const T &temperature, T &mu)
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.
void GetArtificialViscosity(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &muav)
Calculate and return the ArtificialViscosity for shock-capturing.
void GetViscosityAndThermalCondFromTempKernel(const T &temperature, T &mu, T &thermalCond)
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
std::string m_ViscosityType
int m_spacedim
Spatial dimension (>= expansion dim).
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
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 GetPhys_Offset(int n)
Base class for unsteady solvers.
bool m_CalcPhysicalAV
flag to update artificial viscosity
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static const NekDouble kNekZeroTol
DiffusionFactory & GetDiffusionFactory()
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
T Smax(const T a, const T b, const T k)
Return the soft max of between two scalars.
void Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
vvtvvtp (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
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
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.