49 "CompressibleFlowSystem",
51 "Auxiliary functions for the compressible flow system.");
55 : UnsteadySystem(pSession)
67 "No UPWINDTYPE defined in session.");
73 m_vecLocs = Array<OneD, Array<OneD, NekDouble> >(1);
77 m_vecLocs[0][i] = 1 + i;
82 "Compressible flow sessions must define a Gamma parameter.");
87 "Compressible flow sessions must define a pInf parameter.");
92 "Compressible flow sessions must define a rhoInf parameter.");
97 "Compressible flow sessions must define a uInf parameter.");
101 if (m_spacedim == 2 || m_spacedim == 3)
104 "Compressible flow sessions must define a vInf parameter"
105 "for 2D/3D problems.");
113 "Compressible flow sessions must define a wInf parameter"
131 m_session->LoadSolverInfo(
"ShockCaptureType",
133 m_session->LoadParameter (
"thermalConductivity",
147 ASSERTL0(
false,
"Continuous field not supported.");
153 string advName, diffName, riemName;
156 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
157 m_session->LoadSolverInfo(
"DiffusionType", diffName,
"LDGNS");
198 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Average");
232 ASSERTL0(
false,
"Unsupported projection type.");
260 Array<
OneD, Array<OneD, NekDouble> > &physarray)
264 int nVariables = physarray.num_elements();
266 const Array<OneD, const int> &traceBndMap
270 Array<OneD, Array<OneD, NekDouble> > Fwd(nVariables);
271 for (i = 0; i < nVariables; ++i)
273 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
274 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
279 int e, id1, id2, nBCEdgePts, eMax;
281 eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
283 for (e = 0; e < eMax; ++e)
285 nBCEdgePts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
286 GetExp(e)->GetTotPoints();
287 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
289 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt+e]);
297 Array<OneD, NekDouble > tmp2(nBCEdgePts, 0.0);
300 &Fwd[nVariables-1][id2], 1,
304 &Fwd[nVariables-1][id2], 1,
306 &Fwd[nVariables-1][id2], 1);
310 &Fwd[nVariables-1][id2], 1,
311 &Fwd[nVariables-1][id2], 1);
316 Array<OneD, NekDouble> tmp(nBCEdgePts, 0.0);
329 Vmath::Smul(nBCEdgePts, -2.0, &tmp[0], 1, &tmp[0], 1);
342 for (i = 0; i < nVariables; ++i)
345 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
346 UpdatePhys())[id1], 1);
357 Array<
OneD, Array<OneD, NekDouble> > &physarray)
361 int nVariables = physarray.num_elements();
363 const Array<OneD, const int> &traceBndMap
367 Array<OneD, Array<OneD, NekDouble> > Fwd(nVariables);
368 for (i = 0; i < nVariables; ++i)
370 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
371 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
377 int e, id1, id2, nBCEdgePts, eMax;
379 eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
381 for (e = 0; e < eMax; ++e)
383 nBCEdgePts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
384 GetExp(e)->GetTotPoints();
385 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
387 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt+e]);
394 Array<OneD, NekDouble > tmp2(nBCEdgePts, 0.0);
397 &Fwd[nVariables-1][id2], 1,
401 &Fwd[nVariables-1][id2], 1,
403 &Fwd[nVariables-1][id2], 1);
407 &Fwd[nVariables-1][id2], 1,
408 &Fwd[nVariables-1][id2], 1);
417 for (i = 0; i < nVariables; ++i)
420 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
421 UpdatePhys())[id1], 1);
432 Array<
OneD, Array<OneD, NekDouble> > &physarray)
436 int nVariables = physarray.num_elements();
438 const Array<OneD, const int> &traceBndMap
442 Array<OneD, Array<OneD, NekDouble> > Fwd(nVariables);
443 for (i = 0; i < nVariables; ++i)
445 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
446 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
451 int e, id1, id2, nBCEdgePts, eMax;
453 eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
455 for (e = 0; e < eMax; ++e)
457 nBCEdgePts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
458 GetExp(e)->GetTotPoints();
459 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
461 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt+e]);
468 Array<OneD, NekDouble > tmp2(nBCEdgePts, 0.0);
471 &Fwd[nVariables-1][id2], 1,
475 &Fwd[nVariables-1][id2], 1,
477 &Fwd[nVariables-1][id2], 1);
481 &Fwd[nVariables-1][id2], 1,
482 &Fwd[nVariables-1][id2], 1);
486 Array<OneD, NekDouble> tmp(nBCEdgePts, 0.0);
499 Vmath::Smul(nBCEdgePts, -2.0, &tmp[0], 1, &tmp[0], 1);
512 for (i = 0; i < nVariables; ++i)
515 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
516 UpdatePhys())[id1], 1);
528 Array<
OneD, Array<OneD, NekDouble> > &physarray)
532 int nVariables = physarray.num_elements();
535 const Array<OneD, const int> &traceBndMap
541 NekDouble gammaMinusOneInv = 1.0 / gammaMinusOne;
543 Array<OneD, NekDouble> tmp1 (nTracePts, 0.0);
544 Array<OneD, NekDouble> tmp2 (nTracePts, 0.0);
545 Array<OneD, NekDouble> VnInf(nTracePts, 0.0);
546 Array<OneD, NekDouble> velInf(nDimensions, 0.0);
552 if (nDimensions == 2 || nDimensions == 3)
556 Vmath::Vadd(nTracePts, VnInf, 1, tmp1, 1, VnInf, 1);
558 if (nDimensions == 3)
562 Vmath::Vadd(nTracePts, VnInf, 1, tmp2, 1, VnInf, 1);
566 Array<OneD, Array<OneD, NekDouble> > Fwd(nVariables);
567 for (i = 0; i < nVariables; ++i)
569 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
570 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
575 Array<OneD, NekDouble > Vn (nTracePts, 0.0);
576 Array<OneD, NekDouble > Vel(nTracePts, 0.0);
577 for (i = 0; i < nDimensions; ++i)
579 Vmath::Vdiv(nTracePts, Fwd[i+1], 1, Fwd[0], 1, Vel, 1);
585 Array<OneD, NekDouble > absVel(nTracePts, 0.0);
586 for (i = 0; i < nDimensions; ++i)
588 Vmath::Vdiv(nTracePts, Fwd[i+1], 1, Fwd[0], 1, tmp1, 1);
590 Vmath::Vadd(nTracePts, tmp1, 1, absVel, 1, absVel, 1);
595 Array<OneD, NekDouble > soundSpeed(nTracePts);
596 Array<OneD, NekDouble > pressure (nTracePts);
598 for (i = 0; i < nTracePts; i++)
602 pressure[i] = (gammaMinusOne) * (Fwd[2][i] -
603 0.5 * (Fwd[1][i] * Fwd[1][i] / Fwd[0][i]));
607 pressure[i] = (gammaMinusOne) * (Fwd[3][i] -
608 0.5 * (Fwd[1][i] * Fwd[1][i] / Fwd[0][i] +
609 Fwd[2][i] * Fwd[2][i] / Fwd[0][i]));
613 pressure[i] = (gammaMinusOne) * (Fwd[4][i] -
614 0.5 * (Fwd[1][i] * Fwd[1][i] / Fwd[0][i] +
615 Fwd[2][i] * Fwd[2][i] / Fwd[0][i] +
616 Fwd[3][i] * Fwd[3][i] / Fwd[0][i]));
619 soundSpeed[i] = sqrt(gamma * pressure[i] / Fwd[0][i]);
623 Array<OneD, NekDouble > Mach(nTracePts, 0.0);
624 Vmath::Vdiv(nTracePts, Vn, 1, soundSpeed, 1, Mach, 1);
629 int e, id1, id2, nBCEdgePts, pnt;
630 NekDouble cPlus, rPlus, cMinus, rMinus, VDBC, VNBC;
631 Array<OneD, NekDouble> velBC(nDimensions, 0.0);
632 Array<OneD, NekDouble> rhoVelBC(nDimensions, 0.0);
635 eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
638 for (e = 0; e < eMax; ++e)
640 nBCEdgePts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
641 GetExp(e)->GetNumPoints(0);
643 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
645 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt+e]);
648 for (i = 0; i < nBCEdgePts; i++)
656 if (Mach[pnt] < 1.00)
659 cPlus = sqrt(gamma * pressure[pnt] / Fwd[0][pnt]);
660 rPlus = Vn[pnt] + 2.0 * cPlus * gammaMinusOneInv;
664 rMinus = VnInf[pnt] - 2.0 * cMinus * gammaMinusOneInv;
670 rPlus = VnInf[pnt] + 2.0 * cPlus * gammaMinusOneInv;
674 rMinus = VnInf[pnt] - 2.0 * cPlus * gammaMinusOneInv;
678 VNBC = 0.5 * (rPlus + rMinus);
679 cBC = 0.25 * gammaMinusOne * (rPlus - rMinus);
680 VDBC = VNBC - VnInf[pnt];
684 rhoBC = pow((cBC * cBC) / (gamma * sBC), gammaMinusOneInv);
685 pBC = rhoBC * cBC * cBC * gammaInv;
691 for ( j = 0; j < nDimensions; ++j)
694 rhoVelBC[j] = rhoBC * velBC[j];
695 EkBC += 0.5 * rhoBC * velBC[j]*velBC[j];
699 EBC = pBC * gammaMinusOneInv + EkBC;
702 (
m_fields[0]->GetBndCondExpansions()[bcRegion]->
703 UpdatePhys())[id1+i] = rhoBC;
704 for (j = 0; j < nDimensions; ++j)
706 (
m_fields[j+1]->GetBndCondExpansions()[bcRegion]->
707 UpdatePhys())[id1+i] = rhoVelBC[j];
709 (
m_fields[nDimensions+1]->GetBndCondExpansions()[bcRegion]->
710 UpdatePhys())[id1+i] = EBC;
716 if (Mach[pnt] < 1.00)
719 cPlus = sqrt(gamma * pressure[pnt] / Fwd[0][pnt]);
720 rPlus = Vn[pnt] + 2.0 * cPlus * gammaMinusOneInv;
724 rMinus = VnInf[pnt] - 2.0 * cMinus * gammaMinusOneInv;
729 cPlus = sqrt(gamma * pressure[pnt] / Fwd[0][pnt]);
730 rPlus = Vn[pnt] + 2.0 * cPlus * gammaMinusOneInv;
733 cMinus = sqrt(gamma * pressure[pnt] / Fwd[0][pnt]);
734 rMinus = Vn[pnt] - 2.0 * cPlus * gammaMinusOneInv;
738 VNBC = 0.5 * (rPlus + rMinus);
739 cBC = 0.25 * gammaMinusOne * (rPlus - rMinus);
740 VDBC = VNBC - Vn[pnt];
743 sBC = pressure[pnt] / (pow(Fwd[0][pnt], gamma));
744 rhoBC = pow((cBC * cBC) / (gamma * sBC), gammaMinusOneInv);
745 pBC = rhoBC * cBC * cBC * gammaInv;
751 for ( j = 0; j < nDimensions; ++j)
753 velBC[j] = Fwd[j+1][pnt] / Fwd[0][pnt] +
755 rhoVelBC[j] = rhoBC * velBC[j];
756 EkBC += 0.5 * rhoBC * velBC[j]*velBC[j];
760 EBC = pBC * gammaMinusOneInv + EkBC;
763 (
m_fields[0]->GetBndCondExpansions()[bcRegion]->
764 UpdatePhys())[id1+i] = rhoBC;
765 for (j = 0; j < nDimensions; ++j)
767 (
m_fields[j+1]->GetBndCondExpansions()[bcRegion]->
768 UpdatePhys())[id1+i] = rhoVelBC[j];
770 (
m_fields[nDimensions+1]->GetBndCondExpansions()[bcRegion]->
771 UpdatePhys())[id1+i] = EBC;
784 Array<
OneD, Array<OneD, NekDouble> > &physarray)
788 int id1, id2, nBCEdgePts;
790 int nVariables = physarray.num_elements();
793 const Array<OneD, const int> &traceBndMap
797 Array<OneD, Array<OneD, NekDouble> > Fwd(nVariables);
798 for (i = 0; i < nVariables; ++i)
800 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
801 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
806 eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
809 for (e = 0; e < eMax; ++e)
811 nBCEdgePts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
812 GetExp(e)->GetNumPoints(0);
813 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
815 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt+e]);
818 for (i = 0; i < nBCEdgePts; i++)
823 (
m_fields[0]->GetBndCondExpansions()[bcRegion]->
824 UpdatePhys())[id1+i] = Fwd[0][pnt];
827 for (j = 1; j <=nDimensions; ++j)
829 (
m_fields[j]->GetBndCondExpansions()[bcRegion]->
830 UpdatePhys())[id1+i] = Fwd[j][pnt];
834 (
m_fields[nVariables-1]->GetBndCondExpansions()[bcRegion]->
835 UpdatePhys())[id1+i] = Fwd[nVariables-1][pnt];
848 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
849 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &flux)
852 int nq = physfield[0].num_elements();
853 int nVariables =
m_fields.num_elements();
855 Array<OneD, NekDouble> pressure(nq);
856 Array<OneD, Array<OneD, NekDouble> > velocity(
m_spacedim);
861 velocity[i] = Array<OneD, NekDouble>(nq);
878 Vmath::Vadd(nq, flux[i+1][i], 1, pressure, 1, flux[i+1][i], 1);
882 Vmath::Vadd(nq, physfield[m_spacedim+1], 1, pressure, 1,
888 flux[m_spacedim+1][j], 1);
892 if (nVariables == m_spacedim+3)
911 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
912 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &flux)
915 int nq = physfield[0].num_elements();
916 int nVariables =
m_fields.num_elements();
920 nq =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
922 Array<OneD, NekDouble> pressure(nq);
923 Array<OneD, Array<OneD, NekDouble> > velocity(
m_spacedim);
925 Array<OneD, Array<OneD, NekDouble> > physfield_interp(nVariables);
926 Array<OneD, Array<OneD, Array<OneD, NekDouble> > > flux_interp(
929 for (i = 0; i < nVariables; ++ i)
931 physfield_interp[i] = Array<OneD, NekDouble>(nq);
932 flux_interp[i] = Array<OneD, Array<OneD, NekDouble> >(
m_spacedim);
934 OneDptscale, physfield[i], physfield_interp[i]);
938 flux_interp[i][j] = Array<OneD, NekDouble>(nq);
945 velocity[i] = Array<OneD, NekDouble>(nq);
948 m_fields[0]->PhysGalerkinProjection1DScaled(
949 OneDptscale, physfield_interp[i+1], flux[0][i]);
953 GetPressure (physfield_interp, velocity, pressure);
960 Vmath::Vmul(nq, velocity[j], 1, physfield_interp[i+1], 1,
961 flux_interp[i+1][j], 1);
965 Vmath::Vadd(nq, flux_interp[i+1][i], 1, pressure,1,
966 flux_interp[i+1][i], 1);
974 m_fields[0]->PhysGalerkinProjection1DScaled(
975 OneDptscale, flux_interp[i+1][j], flux[i+1][j]);
980 Vmath::Vadd(nq, physfield_interp[m_spacedim+1], 1, pressure, 1,
986 flux_interp[m_spacedim+1][j], 1);
989 m_fields[0]->PhysGalerkinProjection1DScaled(
991 flux_interp[m_spacedim+1][j],
992 flux[m_spacedim+1][j]);
1002 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
1003 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &derivativesO1,
1004 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &viscousTensor)
1007 int nVariables =
m_fields.num_elements();
1008 int nPts = physfield[0].num_elements();
1014 Array<OneD, NekDouble > mu (nPts, 0.0);
1015 Array<OneD, NekDouble > thermalConductivity(nPts, 0.0);
1016 Array<OneD, NekDouble > mu2 (nPts, 0.0);
1017 Array<OneD, NekDouble > divVel (nPts, 0.0);
1024 Vmath::Smul(nPts, tRa, &mu[0], 1, &thermalConductivity[0], 1);
1030 &thermalConductivity[0], 1);
1034 Array<OneD, Array<OneD, NekDouble> > tmp(
m_spacedim);
1035 Array<OneD, Array<OneD, NekDouble> > Sgg(
m_spacedim);
1043 Vmath::Vadd(nPts, &divVel[0], 1, &derivativesO1[j][j][0], 1,
1048 Vmath::Smul(nPts, lambda, &divVel[0], 1, &divVel[0], 1);
1049 Vmath::Vmul(nPts, &mu[0], 1, &divVel[0], 1, &divVel[0], 1);
1055 tmp[j] = Array<OneD, NekDouble>(nPts, 0.0);
1056 Sgg[j] = Array<OneD, NekDouble>(nPts, 0.0);
1058 Vmath::Vmul(nPts, &mu2[0], 1, &derivativesO1[j][j][0], 1,
1061 Vmath::Vadd(nPts, &tmp[j][0], 1, &divVel[0], 1, &Sgg[j][0], 1);
1066 Array<OneD, NekDouble > Sxy(nPts, 0.0);
1067 Array<OneD, NekDouble > Sxz(nPts, 0.0);
1068 Array<OneD, NekDouble > Syz(nPts, 0.0);
1070 if (m_spacedim == 2)
1074 &derivativesO1[1][0][0], 1, &Sxy[0], 1);
1077 Vmath::Vmul(nPts, &mu[0], 1, &Sxy[0], 1, &Sxy[0], 1);
1079 else if (m_spacedim == 3)
1083 &derivativesO1[1][0][0], 1, &Sxy[0], 1);
1087 &derivativesO1[2][0][0], 1, &Sxz[0], 1);
1091 &derivativesO1[2][1][0], 1, &Syz[0], 1);
1094 Vmath::Vmul(nPts, &mu[0], 1, &Sxy[0], 1, &Sxy[0], 1);
1097 Vmath::Vmul(nPts, &mu[0], 1, &Sxz[0], 1, &Sxz[0], 1);
1100 Vmath::Vmul(nPts, &mu[0], 1, &Syz[0], 1, &Syz[0], 1);
1104 Array<OneD, NekDouble > STx(nPts, 0.0);
1105 Array<OneD, NekDouble > STy(nPts, 0.0);
1106 Array<OneD, NekDouble > STz(nPts, 0.0);
1116 if (m_spacedim == 1)
1118 Array<OneD, NekDouble > tmp1(nPts, 0.0);
1121 Vmath::Vmul(nPts, &physfield[0][0], 1, &Sgg[0][0], 1, &STx[0], 1);
1125 &derivativesO1[0][1][0], 1, &tmp1[0], 1);
1128 Vmath::Vadd(nPts, &STx[0], 1, &tmp1[0], 1, &STx[0], 1);
1130 else if (m_spacedim == 2)
1132 Array<OneD, NekDouble > tmp1(nPts, 0.0);
1133 Array<OneD, NekDouble > tmp2(nPts, 0.0);
1138 Vmath::Vmul(nPts, &physfield[0][0], 1, &Sgg[0][0], 1, &STx[0], 1);
1141 Vmath::Vmul(nPts, &physfield[1][0], 1, &Sxy[0], 1, &tmp1[0], 1);
1145 &derivativesO1[0][2][0], 1, &tmp2[0], 1);
1148 Vmath::Vadd(nPts, &STx[0], 1, &tmp1[0], 1, &STx[0], 1);
1149 Vmath::Vadd(nPts, &STx[0], 1, &tmp2[0], 1, &STx[0], 1);
1158 Vmath::Vmul(nPts, &physfield[1][0], 1, &Sgg[1][0], 1, &STy[0], 1);
1161 Vmath::Vmul(nPts, &physfield[0][0], 1, &Sxy[0], 1, &tmp1[0], 1);
1165 &derivativesO1[1][2][0], 1, &tmp2[0], 1);
1168 Vmath::Vadd(nPts, &STy[0], 1, &tmp1[0], 1, &STy[0], 1);
1169 Vmath::Vadd(nPts, &STy[0], 1, &tmp2[0], 1, &STy[0], 1);
1171 else if (m_spacedim == 3)
1173 Array<OneD, NekDouble > tmp1(nPts, 0.0);
1174 Array<OneD, NekDouble > tmp2(nPts, 0.0);
1175 Array<OneD, NekDouble > tmp3(nPts, 0.0);
1180 Vmath::Vmul(nPts, &physfield[0][0], 1, &Sgg[0][0], 1, &STx[0], 1);
1183 Vmath::Vmul(nPts, &physfield[1][0], 1, &Sxy[0], 1, &tmp1[0], 1);
1186 Vmath::Vmul(nPts, &physfield[2][0], 1, &Sxz[0], 1, &tmp2[0], 1);
1190 &derivativesO1[0][3][0], 1, &tmp3[0], 1);
1193 Vmath::Vadd(nPts, &STx[0], 1, &tmp1[0], 1, &STx[0], 1);
1194 Vmath::Vadd(nPts, &STx[0], 1, &tmp2[0], 1, &STx[0], 1);
1195 Vmath::Vadd(nPts, &STx[0], 1, &tmp3[0], 1, &STx[0], 1);
1205 Vmath::Vmul(nPts, &physfield[1][0], 1, &Sgg[1][0], 1, &STy[0], 1);
1208 Vmath::Vmul(nPts, &physfield[0][0], 1, &Sxy[0], 1, &tmp1[0], 1);
1211 Vmath::Vmul(nPts, &physfield[2][0], 1, &Syz[0], 1, &tmp2[0], 1);
1215 &derivativesO1[1][3][0], 1, &tmp3[0], 1);
1218 Vmath::Vadd(nPts, &STy[0], 1, &tmp1[0], 1, &STy[0], 1);
1219 Vmath::Vadd(nPts, &STy[0], 1, &tmp2[0], 1, &STy[0], 1);
1220 Vmath::Vadd(nPts, &STy[0], 1, &tmp3[0], 1, &STy[0], 1);
1230 Vmath::Vmul(nPts, &physfield[2][0], 1, &Sgg[2][0], 1, &STz[0], 1);
1233 Vmath::Vmul(nPts, &physfield[0][0], 1, &Sxz[0], 1, &tmp1[0], 1);
1236 Vmath::Vmul(nPts, &physfield[1][0], 1, &Syz[0], 1, &tmp2[0], 1);
1240 &derivativesO1[2][3][0], 1, &tmp3[0], 1);
1243 Vmath::Vadd(nPts, &STz[0], 1, &tmp1[0], 1, &STz[0], 1);
1244 Vmath::Vadd(nPts, &STz[0], 1, &tmp2[0], 1, &STz[0], 1);
1245 Vmath::Vadd(nPts, &STz[0], 1, &tmp3[0], 1, &STz[0], 1);
1256 Vmath::Vcopy(nPts, &Sgg[0][0], 1, &viscousTensor[0][1][0], 1);
1259 Vmath::Vcopy(nPts, &STx[0], 1, &viscousTensor[0][2][0], 1);
1270 Vmath::Vcopy(nPts, &Sgg[0][0], 1, &viscousTensor[0][1][0], 1);
1272 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor[1][1][0], 1);
1275 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor[0][2][0], 1);
1277 Vmath::Vcopy(nPts, &Sgg[1][0], 1, &viscousTensor[1][2][0], 1);
1280 Vmath::Vcopy(nPts, &STx[0], 1, &viscousTensor[0][3][0], 1);
1282 Vmath::Vcopy(nPts, &STy[0], 1, &viscousTensor[1][3][0], 1);
1295 Vmath::Vcopy(nPts, &Sgg[0][0], 1, &viscousTensor[0][1][0], 1);
1297 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor[1][1][0], 1);
1299 Vmath::Vcopy(nPts, &Sxz[0], 1, &viscousTensor[2][1][0], 1);
1302 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor[0][2][0], 1);
1304 Vmath::Vcopy(nPts, &Sgg[1][0], 1, &viscousTensor[1][2][0], 1);
1306 Vmath::Vcopy(nPts, &Syz[0], 1, &viscousTensor[2][2][0], 1);
1309 Vmath::Vcopy(nPts, &Sxz[0], 1, &viscousTensor[0][3][0], 1);
1311 Vmath::Vcopy(nPts, &Syz[0], 1, &viscousTensor[1][3][0], 1);
1313 Vmath::Vcopy(nPts, &Sgg[2][0], 1, &viscousTensor[2][3][0], 1);
1316 Vmath::Vcopy(nPts, &STx[0], 1, &viscousTensor[0][4][0], 1);
1318 Vmath::Vcopy(nPts, &STy[0], 1, &viscousTensor[1][4][0], 1);
1320 Vmath::Vcopy(nPts, &STz[0], 1, &viscousTensor[2][4][0], 1);
1325 ASSERTL0(
false,
"Illegal expansion dimension");
1335 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
1336 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &derivativesO1,
1337 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &viscousTensor)
1341 int nVariables =
m_fields.num_elements();
1342 int nPts = physfield[0].num_elements();
1344 int variables_phys = physfield.num_elements();
1350 nPts =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
1352 int nVariables_aux = derivativesO1[0].num_elements();
1354 Array<OneD, Array<OneD, NekDouble> > physfield_interp(variables_phys);
1355 Array<OneD, Array<OneD, Array<OneD, NekDouble> > > derivativesO1_interp(
1357 Array<OneD, Array<OneD, Array<OneD, NekDouble> > >viscousTensor_interp(
1362 viscousTensor_interp[i] = Array<OneD, Array<OneD, NekDouble> >(
1364 for (j = 0; j < nVariables; ++j)
1366 viscousTensor_interp[i][j] = Array<OneD, NekDouble>(nPts);
1374 Array<OneD, NekDouble > mu (nPts, 0.0);
1375 Array<OneD, NekDouble > mu2 (nPts, 0.0);
1376 Array<OneD, NekDouble > divVel (nPts, 0.0);
1377 Array<OneD, NekDouble > pressure (nPts, 0.0);
1378 Array<OneD, NekDouble > temperature(nPts, 0.0);
1380 for (i = 0; i < nVariables; ++i)
1383 OneDptscale, physfield[i], fields_interp[i]);
1386 for (i = 0; i < variables_phys; ++i)
1388 physfield_interp[i] = Array<OneD, NekDouble> (nPts);
1391 m_fields[0]->PhysInterp1DScaled(OneDptscale, physfield[i],
1392 physfield_interp[i]);
1397 derivativesO1_interp[i] = Array<OneD, Array<OneD, NekDouble> >(
1399 for (j = 0; j < nVariables_aux; ++j)
1401 derivativesO1_interp[i][j] = Array<OneD, NekDouble>(nPts);
1403 OneDptscale, derivativesO1[i][j],
1404 derivativesO1_interp[i][j]);
1423 Array<OneD, Array<OneD, NekDouble> > tmp(m_spacedim);
1424 Array<OneD, Array<OneD, NekDouble> > Sgg(m_spacedim);
1432 Vmath::Vadd(nPts, &divVel[0], 1, &derivativesO1_interp[j][j][0], 1,
1437 Vmath::Smul(nPts, lambda, &divVel[0], 1, &divVel[0], 1);
1438 Vmath::Vmul(nPts, &mu[0], 1, &divVel[0], 1, &divVel[0], 1);
1444 tmp[j] = Array<OneD, NekDouble>(nPts, 0.0);
1445 Sgg[j] = Array<OneD, NekDouble>(nPts, 0.0);
1447 Vmath::Vmul(nPts, &mu2[0], 1, &derivativesO1_interp[j][j][0], 1,
1450 Vmath::Vadd(nPts, &tmp[j][0], 1, &divVel[0], 1, &Sgg[j][0], 1);
1455 Array<OneD, NekDouble > Sxy(nPts, 0.0);
1456 Array<OneD, NekDouble > Sxz(nPts, 0.0);
1457 Array<OneD, NekDouble > Syz(nPts, 0.0);
1459 if (m_spacedim == 2)
1462 Vmath::Vadd(nPts, &derivativesO1_interp[0][1][0], 1,
1463 &derivativesO1_interp[1][0][0], 1, &Sxy[0], 1);
1466 Vmath::Vmul(nPts, &mu[0], 1, &Sxy[0], 1, &Sxy[0], 1);
1468 else if (m_spacedim == 3)
1471 Vmath::Vadd(nPts, &derivativesO1_interp[0][1][0], 1,
1472 &derivativesO1_interp[1][0][0], 1, &Sxy[0], 1);
1475 Vmath::Vadd(nPts, &derivativesO1_interp[0][2][0], 1,
1476 &derivativesO1_interp[2][0][0], 1, &Sxz[0], 1);
1479 Vmath::Vadd(nPts, &derivativesO1_interp[1][2][0], 1,
1480 &derivativesO1_interp[2][1][0], 1, &Syz[0], 1);
1483 Vmath::Vmul(nPts, &mu[0], 1, &Sxy[0], 1, &Sxy[0], 1);
1486 Vmath::Vmul(nPts, &mu[0], 1, &Sxz[0], 1, &Sxz[0], 1);
1489 Vmath::Vmul(nPts, &mu[0], 1, &Syz[0], 1, &Syz[0], 1);
1493 Array<OneD, NekDouble > STx(nPts, 0.0);
1494 Array<OneD, NekDouble > STy(nPts, 0.0);
1495 Array<OneD, NekDouble > STz(nPts, 0.0);
1506 if (m_spacedim == 1)
1508 Array<OneD, NekDouble > tmp1(nPts, 0.0);
1512 &Sgg[0][0], 1, &STx[0], 1);
1516 &derivativesO1_interp[0][1][0], 1, &tmp1[0], 1);
1519 Vmath::Vadd(nPts, &STx[0], 1, &tmp1[0], 1, &STx[0], 1);
1521 else if (m_spacedim == 2)
1523 Array<OneD, NekDouble > tmp1(nPts, 0.0);
1524 Array<OneD, NekDouble > tmp2(nPts, 0.0);
1530 &Sgg[0][0], 1, &STx[0], 1);
1534 &Sxy[0], 1, &tmp1[0], 1);
1538 &derivativesO1_interp[0][2][0], 1, &tmp2[0], 1);
1541 Vmath::Vadd(nPts, &STx[0], 1, &tmp1[0], 1, &STx[0], 1);
1542 Vmath::Vadd(nPts, &STx[0], 1, &tmp2[0], 1, &STx[0], 1);
1552 &Sgg[1][0], 1, &STy[0], 1);
1556 &Sxy[0], 1, &tmp1[0], 1);
1560 &derivativesO1_interp[1][2][0], 1, &tmp2[0], 1);
1563 Vmath::Vadd(nPts, &STy[0], 1, &tmp1[0], 1, &STy[0], 1);
1564 Vmath::Vadd(nPts, &STy[0], 1, &tmp2[0], 1, &STy[0], 1);
1566 else if (m_spacedim == 3)
1568 Array<OneD, NekDouble > tmp1(nPts, 0.0);
1569 Array<OneD, NekDouble > tmp2(nPts, 0.0);
1570 Array<OneD, NekDouble > tmp3(nPts, 0.0);
1576 &Sgg[0][0], 1, &STx[0], 1);
1580 &Sxy[0], 1, &tmp1[0], 1);
1584 &Sxz[0], 1, &tmp2[0], 1);
1588 &derivativesO1_interp[0][3][0], 1, &tmp3[0], 1);
1591 Vmath::Vadd(nPts, &STx[0], 1, &tmp1[0], 1, &STx[0], 1);
1592 Vmath::Vadd(nPts, &STx[0], 1, &tmp2[0], 1, &STx[0], 1);
1593 Vmath::Vadd(nPts, &STx[0], 1, &tmp3[0], 1, &STx[0], 1);
1604 &Sgg[1][0], 1, &STy[0], 1);
1608 &Sxy[0], 1, &tmp1[0], 1);
1612 &Syz[0], 1, &tmp2[0], 1);
1616 &derivativesO1_interp[1][3][0], 1, &tmp3[0], 1);
1619 Vmath::Vadd(nPts, &STy[0], 1, &tmp1[0], 1, &STy[0], 1);
1620 Vmath::Vadd(nPts, &STy[0], 1, &tmp2[0], 1, &STy[0], 1);
1621 Vmath::Vadd(nPts, &STy[0], 1, &tmp3[0], 1, &STy[0], 1);
1632 &Sgg[2][0], 1, &STz[0], 1);
1636 &Sxz[0], 1, &tmp1[0], 1);
1640 &Syz[0], 1, &tmp2[0], 1);
1644 &derivativesO1_interp[2][3][0], 1, &tmp3[0], 1);
1647 Vmath::Vadd(nPts, &STz[0], 1, &tmp1[0], 1, &STz[0], 1);
1648 Vmath::Vadd(nPts, &STz[0], 1, &tmp2[0], 1, &STz[0], 1);
1649 Vmath::Vadd(nPts, &STz[0], 1, &tmp3[0], 1, &STz[0], 1);
1657 int nq = physfield[0].num_elements();
1659 Vmath::Zero(nq, &viscousTensor_interp[0][0][0], 1);
1662 Vmath::Vcopy(nPts, &Sgg[0][0], 1, &viscousTensor_interp[0][1][0], 1);
1665 Vmath::Vcopy(nPts, &STx[0], 1, &viscousTensor_interp[0][2][0], 1);
1670 int nq = physfield[0].num_elements();
1672 Vmath::Zero(nq, &viscousTensor_interp[0][0][0], 1);
1674 Vmath::Zero(nq, &viscousTensor_interp[1][0][0], 1);
1677 Vmath::Vcopy(nPts, &Sgg[0][0], 1, &viscousTensor_interp[0][1][0], 1);
1679 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor_interp[1][1][0], 1);
1682 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor_interp[0][2][0], 1);
1684 Vmath::Vcopy(nPts, &Sgg[1][0], 1, &viscousTensor_interp[1][2][0], 1);
1687 Vmath::Vcopy(nPts, &STx[0], 1, &viscousTensor_interp[0][3][0], 1);
1689 Vmath::Vcopy(nPts, &STy[0], 1, &viscousTensor_interp[1][3][0], 1);
1694 int nq = physfield[0].num_elements();
1696 Vmath::Zero(nq, &viscousTensor_interp[0][0][0], 1);
1698 Vmath::Zero(nq, &viscousTensor_interp[1][0][0], 1);
1700 Vmath::Zero(nq, &viscousTensor_interp[2][0][0], 1);
1703 Vmath::Vcopy(nPts, &Sgg[0][0], 1, &viscousTensor_interp[0][1][0], 1);
1705 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor_interp[1][1][0], 1);
1707 Vmath::Vcopy(nPts, &Sxz[0], 1, &viscousTensor_interp[2][1][0], 1);
1710 Vmath::Vcopy(nPts, &Sxy[0], 1, &viscousTensor_interp[0][2][0], 1);
1712 Vmath::Vcopy(nPts, &Sgg[1][0], 1, &viscousTensor_interp[1][2][0], 1);
1714 Vmath::Vcopy(nPts, &Syz[0], 1, &viscousTensor_interp[2][2][0], 1);
1717 Vmath::Vcopy(nPts, &Sxz[0], 1, &viscousTensor_interp[0][3][0], 1);
1719 Vmath::Vcopy(nPts, &Syz[0], 1, &viscousTensor_interp[1][3][0], 1);
1721 Vmath::Vcopy(nPts, &Sgg[2][0], 1, &viscousTensor_interp[2][3][0], 1);
1724 Vmath::Vcopy(nPts, &STx[0], 1, &viscousTensor_interp[0][4][0], 1);
1726 Vmath::Vcopy(nPts, &STy[0], 1, &viscousTensor_interp[1][4][0], 1);
1728 Vmath::Vcopy(nPts, &STz[0], 1, &viscousTensor_interp[2][4][0], 1);
1733 ASSERTL0(
false,
"Illegal expansion dimension");
1739 for (j = 1; j < nVariables; ++j)
1742 m_fields[0]->PhysGalerkinProjection1DScaled(
1744 viscousTensor_interp[i][j],
1745 viscousTensor[i][j]);
1760 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
1761 Array<OneD, NekDouble> &pressure)
1763 int nBCEdgePts = physfield[0].num_elements();
1767 Vmath::Vmul(nBCEdgePts, physfield[1], 1, physfield[1], 1, pressure, 1);
1770 Vmath::Vvtvp(nBCEdgePts, physfield[1+i], 1, physfield[1+i], 1,
1771 pressure, 1, pressure, 1);
1774 Vmath::Vdiv (nBCEdgePts, pressure, 1, physfield[0], 1, pressure, 1);
1777 pressure, 1, physfield[m_spacedim+1], 1, pressure, 1);
1786 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
1787 Array<OneD, NekDouble> &pressure,
1788 Array<OneD, NekDouble> &enthalpy)
1791 Array<OneD, NekDouble> tmp(npts, 0.0);
1796 Vmath::Vdiv(npts, pressure, 1, physfield[0], 1, enthalpy, 1);
1798 Vmath::Vadd(npts, tmp, 1, enthalpy, 1, enthalpy, 1);
1815 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
1816 const Array<
OneD,
const Array<OneD, NekDouble> > &velocity,
1817 Array<OneD, NekDouble> &pressure)
1819 int nBCEdgePts = physfield[0].num_elements();
1823 Vmath::Vmul (nBCEdgePts, velocity[0], 1, physfield[1], 1, pressure, 1);
1826 Vmath::Vvtvp(nBCEdgePts, velocity[i], 1, physfield[1+i], 1,
1827 pressure, 1, pressure, 1);
1831 pressure, 1, physfield[m_spacedim+1], 1, pressure, 1);
1844 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
1845 Array<
OneD, Array<OneD, NekDouble> > &velocity)
1847 const int nBCEdgePts = physfield[0].num_elements();
1851 Vmath::Vdiv(nBCEdgePts, physfield[1+i], 1, physfield[0], 1,
1864 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
1865 Array<OneD, NekDouble > &pressure,
1866 Array<OneD, NekDouble > &temperature)
1868 const int nq = physfield[0].num_elements();
1870 Vmath::Vdiv(nq, pressure, 1, physfield[0], 1, temperature, 1);
1882 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
1883 Array<OneD, NekDouble > &pressure,
1884 Array<OneD, NekDouble > &soundspeed)
1886 const int nq =
m_fields[0]->GetTotPoints();
1887 Vmath::Vdiv (nq, pressure, 1, physfield[0], 1, soundspeed, 1);
1900 Array<
OneD, Array<OneD, NekDouble> > &physfield,
1901 Array<OneD, NekDouble > &soundspeed,
1902 Array<OneD, NekDouble > &mach)
1904 const int nq =
m_fields[0]->GetTotPoints();
1906 Vmath::Vmul(nq, physfield[1], 1, physfield[1], 1, mach, 1);
1914 Vmath::Vdiv(nq, mach, 1, physfield[0], 1, mach, 1);
1915 Vmath::Vdiv(nq, mach, 1, physfield[0], 1, mach, 1);
1931 const Array<OneD, const NekDouble> &temperature,
1932 Array<OneD, NekDouble> &mu)
1934 const int nPts = temperature.num_elements();
1939 for (
int i = 0; i < nPts; ++i)
1941 ratio = temperature[i] / T_star;
1942 mu[i] = mu_star * ratio * sqrt(ratio) *
1943 (T_star + 110.0) / (temperature[i] + 110.0);
1951 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
1952 const Array<OneD, const NekDouble> &pressure,
1953 const Array<OneD, const NekDouble> &temperature,
1954 Array<OneD, NekDouble> &entropy)
1957 const int npts =
m_fields[0]->GetTotPoints();
1959 Array<OneD, NekDouble> L2entropy(npts, 0.0);
1961 for (
int i = 0; i <
npts; ++i)
1967 Vmath::Vmul(npts,entropy,1,entropy,1,L2entropy,1);
1971 entropy_sum = sqrt(entropy_sum);
1973 std::ofstream m_file(
"L2entropy.txt", std::ios_base::app);
1975 m_file << setprecision(16) << scientific << entropy_sum << endl;
1985 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray)
1988 int nElements =
m_fields[0]->GetExpSize();
1991 Array<OneD, NekDouble> tstep (nElements, 0.0);
1992 Array<OneD, NekDouble> stdVelocity(nElements);
2003 for(n = 0; n < nElements; ++n)
2005 int npoints =
m_fields[0]->GetExp(n)->GetTotPoints();
2006 Array<OneD, NekDouble> one2D(npoints, 1.0);
2009 minLength = sqrt(Area);
2010 if (
m_fields[0]->GetExp(n)->as<LocalRegions::TriExp>())
2016 / (stdVelocity[n] * cLambda
2017 * (ExpOrder[n] - 1) * (ExpOrder[n] - 1));
2034 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
2035 Array<OneD, NekDouble> &stdV)
2038 int n_element =
m_fields[0]->GetExpSize();
2042 Array<OneD, Array<OneD, NekDouble> > velocity (
m_spacedim);
2043 Array<OneD, Array<OneD, NekDouble> > stdVelocity(
m_spacedim);
2044 Array<OneD, NekDouble> pressure (nTotQuadPoints);
2045 Array<OneD, NekDouble> soundspeed (nTotQuadPoints);
2053 velocity [i] = Array<OneD, NekDouble>(nTotQuadPoints);
2054 stdVelocity[i] = Array<OneD, NekDouble>(nTotQuadPoints, 0.0);
2061 for(
int el = 0; el < n_element; ++el)
2063 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
2067 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
2068 const Array<TwoD, const NekDouble> &gmat =
2069 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()
2070 ->GetDerivFactors(ptsKeys);
2072 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
2084 1, stdVelocity[i], 1, stdVelocity[i], 1);
2097 1, stdVelocity[i], 1, stdVelocity[i], 1);
2102 for (
int i = 0; i < nq; ++i)
2107 pntVelocity += stdVelocity[j][i]*stdVelocity[j][i];
2109 pntVelocity = sqrt(pntVelocity) + soundspeed[nBCEdgePts];
2110 if (pntVelocity > stdV[el])
2112 stdV[el] = pntVelocity;
2128 ASSERTL0(n <= 20,
"Illegal modes dimension for CFL calculation "
2129 "(P has to be less then 20)");
2131 NekDouble CFLDG[21] = { 2.0000, 6.0000, 11.8424, 19.1569,
2132 27.8419, 37.8247, 49.0518, 61.4815,
2133 75.0797, 89.8181, 105.6700, 122.6200,
2134 140.6400, 159.7300, 179.8500, 201.0100,
2135 223.1800, 246.3600, 270.5300, 295.6900,
2145 ASSERTL0(
false,
"Continuous Galerkin stability coefficients "
2146 "not introduced yet.");
2160 const Array<OneD,int> &ExpOrder)
2164 for (i =0; i<
m_fields[0]->GetExpSize(); i++)
2172 const Array<
OneD,
const Array<OneD, NekDouble> > &physarray,
2173 Array<OneD, NekDouble> &Sensor,
2174 Array<OneD, NekDouble> &SensorKappa)
2176 int e, NumModesElement, nQuadPointsElement;
2178 int nElements =
m_fields[0]->GetExpSize();
2185 Array<OneD, NekDouble> SolP(nTotQuadPoints,0.0);
2186 Array<OneD, NekDouble> SolPmOne(nTotQuadPoints,0.0);
2187 Array<OneD, NekDouble> SolNorm(nTotQuadPoints,0.0);
2191 int CoeffsCount = 0;
2193 for (e = 0; e < nElements; e++)
2195 NumModesElement = ExpOrderElement[e];
2197 int nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2198 int nCoeffsElement =
m_fields[0]->GetExp(e)->GetNcoeffs();
2199 int numCutOff = NumModesElement - 1;
2204 Array<OneD, NekDouble> SolPElementPhys(nQuadPointsElement,0.0);
2205 Array<OneD, NekDouble> SolPElementCoeffs(nCoeffsElement,0.0);
2207 Array<OneD, NekDouble> SolPmOneElementPhys(nQuadPointsElement,0.0);
2208 Array<OneD, NekDouble> SolPmOneElementCoeffs(nCoeffsElement,0.0);
2212 for (
int i = 0; i < nQuadPointsElement; i++)
2214 SolPElementPhys[i] = SolP[CoeffsCount+i];
2217 m_fields[0]->GetExp(e)->FwdTrans(SolPElementPhys,
2225 m_fields[0]->GetExp(e)->ReduceOrderCoeffs(numCutOff,
2227 SolPmOneElementCoeffs);
2229 m_fields[0]->GetExp(e)->BwdTrans(SolPmOneElementCoeffs,
2230 SolPmOneElementPhys);
2232 for (
int i = 0; i < nQuadPointsElement; i++)
2234 SolPmOne[CoeffsCount+i] = SolPmOneElementPhys[i];
2244 SolPmOneElementPhys, 1,
2252 for (
int i = 0; i < nQuadPointsElement; i++)
2254 SolPmeanNumerator += SolNorm[i];
2255 SolPmeanDenumerator += SolPElementPhys[i];
2258 for (
int i = 0; i < nQuadPointsElement; ++i)
2260 Sensor[CoeffsCount+i] = sqrt(SolPmeanNumerator/nQuadPointsElement)
2261 /sqrt(SolPmeanDenumerator/nQuadPointsElement);
2263 Sensor[CoeffsCount+i] = log10(Sensor[CoeffsCount+i]);
2265 CoeffsCount += nQuadPointsElement;
2270 for (e = 0; e < nElements; e++)
2272 NumModesElement = ExpOrderElement[e];
2276 nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2278 for (
int i = 0; i < nQuadPointsElement; i++)
2280 if (Sensor[CoeffsCount+i] <= (Phi0 - DeltaPhi))
2282 SensorKappa[CoeffsCount+i] = 0;
2284 else if(Sensor[CoeffsCount+i] >= (Phi0 + DeltaPhi))
2286 SensorKappa[CoeffsCount+i] = ThetaS;
2288 else if(abs(Sensor[CoeffsCount+i]-Phi0) < DeltaPhi)
2290 SensorKappa[CoeffsCount+i] = ThetaS/2*(1+sin(M_PI*
2291 (Sensor[CoeffsCount+i]-Phi0)
2296 CoeffsCount += nQuadPointsElement;
2302 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
2303 Array<
OneD, Array<OneD, NekDouble> > outarrayForcing)
2305 const int nPts =
m_fields[0]->GetTotPoints();
2306 const int nvariables =
m_fields.num_elements();
2307 const int nElements =
m_fields[0]->GetExpSize();
2309 Array<OneD, NekDouble> Sensor(nPts, 0.0);
2310 Array<OneD, NekDouble> SensorKappa(nPts, 0.0);
2311 Array <OneD, NekDouble > Lambda(nPts, 0.0);
2312 Array <OneD, NekDouble > Tau(nPts, 1.0);
2313 Array <OneD, NekDouble > soundspeed(nPts, 0.0);
2314 Array <OneD, NekDouble > pressure(nPts, 0.0);
2315 Array <OneD, NekDouble > temperature(nPts, 0.0);
2316 Array <OneD, NekDouble > absVelocity(nPts, 0.0);
2317 Array <OneD, NekDouble > hel(nPts, 0.0);
2318 Array <OneD, NekDouble > h_minmin(m_spacedim, 0.0);
2321 Array<OneD, NekDouble> pOrder (nPts, 0.0);
2327 GetSensor(inarray, Sensor, SensorKappa);
2330 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambda, 1);
2336 for (
int e = 0; e < nElements; e++)
2338 int nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2340 for (
int n = 0; n < nQuadPointsElement; n++)
2342 pOrder[n + PointCount] = pOrderElmt[e];
2344 Tau[n + PointCount] = 1.0/(
m_C1*pOrder[n + PointCount]*LambdaMax);
2346 outarrayForcing[nvariables-1][n + PointCount] = 1/Tau[n + PointCount]*(
m_hFactor*LambdaMax/pOrder[n + PointCount]*SensorKappa[n + PointCount]-inarray[nvariables-1][n + PointCount]);
2348 PointCount += nQuadPointsElement;
2353 Array<
OneD, Array<OneD, NekDouble> > &outarray,
2354 Array<OneD, NekDouble > &hmin)
2357 const int nElements =
m_fields[0]->GetExpSize();
2364 for (
int e = 0; e < nElements; e++)
2367 Array <OneD, NekDouble> L1(nedges, 0.0);
2369 for (
int j = 0; j < nedges; ++j)
2380 if (boost::dynamic_pointer_cast<SpatialDomains::QuadGeom>(
m_fields[0]->GetExp(e)->GetGeom()))
2384 ElQuadGeom->
GetEdge(j)->GetVertex(0)->GetCoords(x0,y0,z0);
2385 ElQuadGeom->GetEdge(j)->GetVertex(1)->GetCoords(x1,y1,z1);
2387 L1[j] = sqrt(pow((x0-x1),2)+pow((y0-y1),2)+pow((z0-z1),2));
2391 ASSERTL0(
false,
"GetElementDimensions() is only implemented for quadrilateral elements");
2396 if(boost::dynamic_pointer_cast<SpatialDomains::QuadGeom>(
m_fields[0]->GetExp(e)->GetGeom()))
2398 hx = min(L1[0], L1[2]);
2399 hy = min(L1[1], L1[3]);
2401 outarray[0][e] = hx;
2402 outarray[1][e] = hy;
2406 hmin[0] =
Vmath::Vmin(outarray[0].num_elements(), outarray[0], 1);
2407 hmin[1] =
Vmath::Vmin(outarray[1].num_elements(), outarray[1], 1);
2411 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
2412 Array<OneD, NekDouble> &Vtot)
2417 Array<OneD, Array<OneD, NekDouble> > velocity (m_spacedim);
2423 velocity[i] = Array<OneD, NekDouble>(nTotQuadPoints);
2441 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
2442 Array<OneD, NekDouble > &eps_bar)
2444 int nvariables = physfield.num_elements();
2445 int nPts =
m_fields[0]->GetTotPoints();
2447 Array<OneD, NekDouble > pressure (nPts, 0.0);
2448 Array<OneD, NekDouble > temperature (nPts, 0.0);
2449 Array <OneD, NekDouble > sensor (nPts, 0.0);
2450 Array <OneD, NekDouble > SensorKappa (nPts, 0.0);
2451 Array <OneD, NekDouble > absVelocity (nPts, 0.0);
2452 Array <OneD, NekDouble > soundspeed (nPts, 0.0);
2453 Array <OneD, NekDouble > Lambda (nPts, 0.0);
2454 Array <OneD, NekDouble > mu_var (nPts, 0.0);
2455 Array <OneD, NekDouble > h_minmin (m_spacedim, 0.0);
2463 GetSensor(physfield, sensor, SensorKappa);
2466 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambda, 1);
2484 for (
int e = 0; e < eps_bar.num_elements(); e++)
2486 if (physfield[nvariables-1][e] <= (Phi0 - DeltaPhi))
2490 else if(physfield[nvariables-1][e] >= (Phi0 + DeltaPhi))
2494 else if(abs(physfield[nvariables-1][e]-Phi0) < DeltaPhi)
2496 eps_bar[e] =
m_mu0/2*(1+sin(M_PI*
2497 (physfield[nvariables-1][e]-Phi0)/(2*DeltaPhi)));
2504 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
2505 Array<OneD, NekDouble > &mu_var)
2507 const int nElements =
m_fields[0]->GetExpSize();
2512 Array<OneD, NekDouble> S_e (nTotQuadPoints, 0.0);
2513 Array<OneD, NekDouble> se (nTotQuadPoints, 0.0);
2514 Array<OneD, NekDouble> Sensor (nTotQuadPoints, 0.0);
2515 Array<OneD, NekDouble> SensorKappa(nTotQuadPoints, 0.0);
2516 Array<OneD, NekDouble> absVelocity(nTotQuadPoints, 0.0);
2517 Array<OneD, NekDouble> soundspeed (nTotQuadPoints, 0.0);
2518 Array<OneD, NekDouble> pressure (nTotQuadPoints, 0.0);
2523 GetSensor (physfield, Sensor, SensorKappa);
2526 Array<OneD, NekDouble> Lambda(nTotQuadPoints, 1.0);
2527 Vmath::Vadd(nTotQuadPoints, absVelocity, 1, soundspeed, 1, Lambda, 1);
2529 for (
int e = 0; e < nElements; e++)
2540 int nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2541 Array <OneD, NekDouble> one2D(nQuadPointsElement, 1.0);
2543 for (
int n = 0; n < nQuadPointsElement; n++)
2549 mu_var[n+PointCount] = 0;
2554 mu_var[n+PointCount] = mu_0*(0.5*(1+sin(
2559 mu_var[n+PointCount] = mu_0;
2563 PointCount += nQuadPointsElement;
2568 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
2569 Array<OneD, NekDouble > &PolyOrder)
2574 int nElements =
m_fields[0]->GetExpSize();
2575 int npts =
m_fields[0]->GetTotPoints();
2577 Array<OneD, NekDouble > Sensor (npts, 0.0);
2578 Array<OneD, NekDouble > SensorKappa (npts, 0.0);
2579 Array<OneD, NekDouble > se (npts,0.0);
2581 GetSensor(physfield, Sensor, SensorKappa);
2583 int nQuadPointsElement = 0;
2587 int MinOrderShock = 4;
2589 std::ofstream m_file(
"VariablePComposites.txt", std::ios_base::app);
2590 for (
int e = 0; e < nElements; e++)
2592 m_file <<
"<C ID=\"" << e+1 <<
"\"> Q[" << e <<
"] </C>"<< endl;
2596 std::ofstream m_file2(
"VariablePExpansions.txt", std::ios_base::app);
2598 for (e = 0; e < nElements; e++)
2600 nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2611 for (
int i = 0; i < nQuadPointsElement; i++)
2613 se[npCount + i] = (Sensor[npCount + i]);
2615 if (se[npCount + i] > s_ds)
2617 if (PolyOrder[npCount + i] > MinOrderShock)
2619 PolyOrder[npCount + i] = PolyOrder[npCount + i] - 1;
2621 else if(PolyOrder[e] < MinOrderShock)
2623 PolyOrder[npCount + i] = PolyOrder[npCount + i] + 1;
2627 else if(se[npCount + i] > s_sm && se[npCount + i] < s_ds)
2629 if (PolyOrder[npCount + i] < MaxOrder)
2631 PolyOrder[npCount + i] = PolyOrder[npCount + i] + 2;
2634 else if(se[npCount + i] > s_fl && se[npCount + i] < s_sm)
2636 PolyOrder[npCount + i] = PolyOrder[npCount + i] + 1;
2638 else if(se[npCount + i] < s_fl)
2640 if (PolyOrder[npCount + i] > MinOrder)
2642 PolyOrder[npCount + i] = PolyOrder[npCount + i];
2646 m_file2 <<
"<E COMPOSITE= \"C[" << e+1
2647 <<
"]\" NUMMODES=\"" << PolyOrder[npCount + 1]
2648 <<
"\" TYPE=\"MODIFIED\" FIELDS=\"rho,rhou,rhov,rhow,E\" />"
2650 npCount += nQuadPointsElement;
2657 std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
2658 std::vector<std::string> &variables)
2660 const int nPhys =
m_fields[0]->GetNpoints();
2661 const int nCoeffs =
m_fields[0]->GetNcoeffs();
2662 Array<OneD, Array<OneD, NekDouble> > tmp(
m_fields.num_elements());
2664 for (
int i = 0; i <
m_fields.num_elements(); ++i)
2669 Array<OneD, NekDouble> pressure(nPhys), soundspeed(nPhys), mach(nPhys), sensor(nPhys), SensorKappa(nPhys), smooth(nPhys);
2673 GetMach (tmp, soundspeed, mach);
2677 Array<OneD, NekDouble> pFwd(nCoeffs), sFwd(nCoeffs), mFwd(nCoeffs), sensFwd(nCoeffs), smoothFwd(nCoeffs);
2679 m_fields[0]->FwdTrans(pressure, pFwd);
2680 m_fields[0]->FwdTrans(soundspeed, sFwd);
2682 m_fields[0]->FwdTrans(sensor, sensFwd);
2683 m_fields[0]->FwdTrans(smooth, smoothFwd);
2685 variables.push_back (
"p");
2686 variables.push_back (
"a");
2687 variables.push_back (
"Mach");
2688 variables.push_back (
"Sensor");
2689 variables.push_back (
"SmoothVisc");
2690 fieldcoeffs.push_back(pFwd);
2691 fieldcoeffs.push_back(sFwd);
2692 fieldcoeffs.push_back(mFwd);
2693 fieldcoeffs.push_back(sensFwd);
2694 fieldcoeffs.push_back(smoothFwd);