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 if (
m_fields[0]->GetExp(n)->as<LocalRegions::TriExp>())
2011 minLength = 2.0 * sqrt(Area);
2013 else if (
m_fields[0]->GetExp(n)->as<LocalRegions::QuadExp>())
2015 minLength = sqrt(Area);
2017 else if (
m_fields[0]->GetExp(n)->as<LocalRegions::HexExp>())
2019 minLength = sqrt(Area);
2023 / (stdVelocity[n] * cLambda
2024 * (ExpOrder[n] - 1) * (ExpOrder[n] - 1));
2041 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
2042 Array<OneD, NekDouble> &stdV)
2045 int n_element =
m_fields[0]->GetExpSize();
2049 Array<OneD, Array<OneD, NekDouble> > velocity (
m_spacedim);
2050 Array<OneD, Array<OneD, NekDouble> > stdVelocity(
m_spacedim);
2051 Array<OneD, NekDouble> pressure (nTotQuadPoints);
2052 Array<OneD, NekDouble> soundspeed (nTotQuadPoints);
2060 velocity [i] = Array<OneD, NekDouble>(nTotQuadPoints);
2061 stdVelocity[i] = Array<OneD, NekDouble>(nTotQuadPoints, 0.0);
2068 for(
int el = 0; el < n_element; ++el)
2070 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
2074 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
2075 const Array<TwoD, const NekDouble> &gmat =
2076 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()
2077 ->GetDerivFactors(ptsKeys);
2079 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
2091 1, stdVelocity[i], 1, stdVelocity[i], 1);
2104 1, stdVelocity[i], 1, stdVelocity[i], 1);
2109 for (
int i = 0; i < nq; ++i)
2114 pntVelocity += stdVelocity[j][i]*stdVelocity[j][i];
2116 pntVelocity = sqrt(pntVelocity) + soundspeed[nBCEdgePts];
2117 if (pntVelocity > stdV[el])
2119 stdV[el] = pntVelocity;
2135 ASSERTL0(n <= 20,
"Illegal modes dimension for CFL calculation "
2136 "(P has to be less then 20)");
2138 NekDouble CFLDG[21] = { 2.0000, 6.0000, 11.8424, 19.1569,
2139 27.8419, 37.8247, 49.0518, 61.4815,
2140 75.0797, 89.8181, 105.6700, 122.6200,
2141 140.6400, 159.7300, 179.8500, 201.0100,
2142 223.1800, 246.3600, 270.5300, 295.6900,
2152 ASSERTL0(
false,
"Continuous Galerkin stability coefficients "
2153 "not introduced yet.");
2167 const Array<OneD,int> &ExpOrder)
2171 for (i =0; i<
m_fields[0]->GetExpSize(); i++)
2179 const Array<
OneD,
const Array<OneD, NekDouble> > &physarray,
2180 Array<OneD, NekDouble> &Sensor,
2181 Array<OneD, NekDouble> &SensorKappa)
2183 int e, NumModesElement, nQuadPointsElement;
2185 int nElements =
m_fields[0]->GetExpSize();
2192 Array<OneD, NekDouble> SolP(nTotQuadPoints,0.0);
2193 Array<OneD, NekDouble> SolPmOne(nTotQuadPoints,0.0);
2194 Array<OneD, NekDouble> SolNorm(nTotQuadPoints,0.0);
2198 int CoeffsCount = 0;
2200 for (e = 0; e < nElements; e++)
2202 NumModesElement = ExpOrderElement[e];
2204 int nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2205 int nCoeffsElement =
m_fields[0]->GetExp(e)->GetNcoeffs();
2206 int numCutOff = NumModesElement - 1;
2211 Array<OneD, NekDouble> SolPElementPhys(nQuadPointsElement,0.0);
2212 Array<OneD, NekDouble> SolPElementCoeffs(nCoeffsElement,0.0);
2214 Array<OneD, NekDouble> SolPmOneElementPhys(nQuadPointsElement,0.0);
2215 Array<OneD, NekDouble> SolPmOneElementCoeffs(nCoeffsElement,0.0);
2219 for (
int i = 0; i < nQuadPointsElement; i++)
2221 SolPElementPhys[i] = SolP[CoeffsCount+i];
2224 m_fields[0]->GetExp(e)->FwdTrans(SolPElementPhys,
2232 m_fields[0]->GetExp(e)->ReduceOrderCoeffs(numCutOff,
2234 SolPmOneElementCoeffs);
2236 m_fields[0]->GetExp(e)->BwdTrans(SolPmOneElementCoeffs,
2237 SolPmOneElementPhys);
2239 for (
int i = 0; i < nQuadPointsElement; i++)
2241 SolPmOne[CoeffsCount+i] = SolPmOneElementPhys[i];
2251 SolPmOneElementPhys, 1,
2259 for (
int i = 0; i < nQuadPointsElement; i++)
2261 SolPmeanNumerator += SolNorm[i];
2262 SolPmeanDenumerator += SolPElementPhys[i];
2265 for (
int i = 0; i < nQuadPointsElement; ++i)
2267 Sensor[CoeffsCount+i] = sqrt(SolPmeanNumerator/nQuadPointsElement)
2268 /sqrt(SolPmeanDenumerator/nQuadPointsElement);
2270 Sensor[CoeffsCount+i] = log10(Sensor[CoeffsCount+i]);
2272 CoeffsCount += nQuadPointsElement;
2277 for (e = 0; e < nElements; e++)
2279 NumModesElement = ExpOrderElement[e];
2283 nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2285 for (
int i = 0; i < nQuadPointsElement; i++)
2287 if (Sensor[CoeffsCount+i] <= (Phi0 - DeltaPhi))
2289 SensorKappa[CoeffsCount+i] = 0;
2291 else if(Sensor[CoeffsCount+i] >= (Phi0 + DeltaPhi))
2293 SensorKappa[CoeffsCount+i] = ThetaS;
2295 else if(abs(Sensor[CoeffsCount+i]-Phi0) < DeltaPhi)
2297 SensorKappa[CoeffsCount+i] = ThetaS/2*(1+sin(M_PI*
2298 (Sensor[CoeffsCount+i]-Phi0)
2303 CoeffsCount += nQuadPointsElement;
2309 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
2310 Array<
OneD, Array<OneD, NekDouble> > outarrayForcing)
2312 const int nPts =
m_fields[0]->GetTotPoints();
2313 const int nvariables =
m_fields.num_elements();
2314 const int nElements =
m_fields[0]->GetExpSize();
2320 Array<OneD, NekDouble> Sensor(nPts, 0.0);
2321 Array<OneD, NekDouble> SensorKappa(nPts, 0.0);
2322 Array <OneD, NekDouble > Lambda(nPts, 0.0);
2323 Array <OneD, NekDouble > Tau(nPts, 1.0);
2324 Array <OneD, NekDouble > soundspeed(nPts, 0.0);
2325 Array <OneD, NekDouble > pressure(nPts, 0.0);
2326 Array <OneD, NekDouble > temperature(nPts, 0.0);
2327 Array <OneD, NekDouble > absVelocity(nPts, 0.0);
2328 Array <OneD, NekDouble > hel(nPts, 0.0);
2329 Array <OneD, NekDouble > h_minmin(m_spacedim, 0.0);
2332 Array<OneD, NekDouble> pOrder (nPts, 0.0);
2338 GetSensor(inarray, Sensor, SensorKappa);
2341 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambda, 1);
2347 for (
int e = 0; e < nElements; e++)
2349 int nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2351 for (
int n = 0; n < nQuadPointsElement; n++)
2353 pOrder[n + PointCount] = pOrderElmt[e];
2355 Tau[n + PointCount] = 1.0/(
m_C1*pOrder[n + PointCount]*LambdaMax);
2357 outarrayForcing[nvariables-1][n + PointCount] = 1/Tau[n + PointCount]*(
m_hFactor*LambdaMax/pOrder[n + PointCount]*SensorKappa[n + PointCount]-inarray[nvariables-1][n + PointCount]);
2359 PointCount += nQuadPointsElement;
2364 Array<
OneD, Array<OneD, NekDouble> > &outarray,
2365 Array<OneD, NekDouble > &hmin)
2368 const int nElements =
m_fields[0]->GetExpSize();
2375 for (
int e = 0; e < nElements; e++)
2378 Array <OneD, NekDouble> L1(nedges, 0.0);
2380 for (
int j = 0; j < nedges; ++j)
2391 if (boost::dynamic_pointer_cast<SpatialDomains::QuadGeom>(
m_fields[0]->GetExp(e)->GetGeom()))
2395 ElQuadGeom->
GetEdge(j)->GetVertex(0)->GetCoords(x0,y0,z0);
2396 ElQuadGeom->GetEdge(j)->GetVertex(1)->GetCoords(x1,y1,z1);
2398 L1[j] = sqrt(pow((x0-x1),2)+pow((y0-y1),2)+pow((z0-z1),2));
2402 ASSERTL0(
false,
"GetElementDimensions() is only implemented for quadrilateral elements");
2407 if(boost::dynamic_pointer_cast<SpatialDomains::QuadGeom>(
m_fields[0]->GetExp(e)->GetGeom()))
2409 hx = min(L1[0], L1[2]);
2410 hy = min(L1[1], L1[3]);
2412 outarray[0][e] = hx;
2413 outarray[1][e] = hy;
2417 hmin[0] =
Vmath::Vmin(outarray[0].num_elements(), outarray[0], 1);
2418 hmin[1] =
Vmath::Vmin(outarray[1].num_elements(), outarray[1], 1);
2422 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
2423 Array<OneD, NekDouble> &Vtot)
2428 Array<OneD, Array<OneD, NekDouble> > velocity (m_spacedim);
2434 velocity[i] = Array<OneD, NekDouble>(nTotQuadPoints);
2452 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
2453 Array<OneD, NekDouble > &eps_bar)
2455 int nvariables = physfield.num_elements();
2456 int nPts =
m_fields[0]->GetTotPoints();
2458 Array<OneD, NekDouble > pressure (nPts, 0.0);
2459 Array<OneD, NekDouble > temperature (nPts, 0.0);
2460 Array <OneD, NekDouble > sensor (nPts, 0.0);
2461 Array <OneD, NekDouble > SensorKappa (nPts, 0.0);
2462 Array <OneD, NekDouble > absVelocity (nPts, 0.0);
2463 Array <OneD, NekDouble > soundspeed (nPts, 0.0);
2464 Array <OneD, NekDouble > Lambda (nPts, 0.0);
2465 Array <OneD, NekDouble > mu_var (nPts, 0.0);
2466 Array <OneD, NekDouble > h_minmin (m_spacedim, 0.0);
2474 GetSensor(physfield, sensor, SensorKappa);
2477 Vmath::Vadd(nPts, absVelocity, 1, soundspeed, 1, Lambda, 1);
2481 const int nElements =
m_fields[0]->GetExpSize();
2500 for (
int e = 0; e < eps_bar.num_elements(); e++)
2502 if (physfield[nvariables-1][e] <= (Phi0 - DeltaPhi))
2506 else if(physfield[nvariables-1][e] >= (Phi0 + DeltaPhi))
2510 else if(abs(physfield[nvariables-1][e]-Phi0) < DeltaPhi)
2512 eps_bar[e] =
m_mu0/2*(1+sin(M_PI*
2513 (physfield[nvariables-1][e]-Phi0)/(2*DeltaPhi)));
2520 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
2521 Array<OneD, NekDouble > &mu_var)
2523 const int nElements =
m_fields[0]->GetExpSize();
2528 Array<OneD, NekDouble> S_e (nTotQuadPoints, 0.0);
2529 Array<OneD, NekDouble> se (nTotQuadPoints, 0.0);
2530 Array<OneD, NekDouble> Sensor (nTotQuadPoints, 0.0);
2531 Array<OneD, NekDouble> SensorKappa(nTotQuadPoints, 0.0);
2532 Array<OneD, NekDouble> absVelocity(nTotQuadPoints, 0.0);
2533 Array<OneD, NekDouble> soundspeed (nTotQuadPoints, 0.0);
2534 Array<OneD, NekDouble> pressure (nTotQuadPoints, 0.0);
2539 GetSensor (physfield, Sensor, SensorKappa);
2542 Array<OneD, NekDouble> Lambda(nTotQuadPoints, 1.0);
2543 Vmath::Vadd(nTotQuadPoints, absVelocity, 1, soundspeed, 1, Lambda, 1);
2545 for (
int e = 0; e < nElements; e++)
2556 int nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2557 Array <OneD, NekDouble> one2D(nQuadPointsElement, 1.0);
2559 for (
int n = 0; n < nQuadPointsElement; n++)
2565 mu_var[n+PointCount] = 0;
2570 mu_var[n+PointCount] = mu_0*(0.5*(1+sin(
2575 mu_var[n+PointCount] = mu_0;
2579 PointCount += nQuadPointsElement;
2584 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
2585 Array<OneD, NekDouble > &PolyOrder)
2590 int nElements =
m_fields[0]->GetExpSize();
2591 int npts =
m_fields[0]->GetTotPoints();
2593 Array<OneD, NekDouble > Sensor (npts, 0.0);
2594 Array<OneD, NekDouble > SensorKappa (npts, 0.0);
2595 Array<OneD, NekDouble > se (npts,0.0);
2597 GetSensor(physfield, Sensor, SensorKappa);
2599 int nQuadPointsElement = 0;
2603 int MinOrderShock = 4;
2605 std::ofstream m_file(
"VariablePComposites.txt", std::ios_base::app);
2606 for (
int e = 0; e < nElements; e++)
2608 m_file <<
"<C ID=\"" << e+1 <<
"\"> Q[" << e <<
"] </C>"<< endl;
2612 std::ofstream m_file2(
"VariablePExpansions.txt", std::ios_base::app);
2614 for (e = 0; e < nElements; e++)
2616 nQuadPointsElement =
m_fields[0]->GetExp(e)->GetTotPoints();
2627 for (
int i = 0; i < nQuadPointsElement; i++)
2629 se[npCount + i] = (Sensor[npCount + i]);
2631 if (se[npCount + i] > s_ds)
2633 if (PolyOrder[npCount + i] > MinOrderShock)
2635 PolyOrder[npCount + i] = PolyOrder[npCount + i] - 1;
2637 else if(PolyOrder[e] < MinOrderShock)
2639 PolyOrder[npCount + i] = PolyOrder[npCount + i] + 1;
2643 else if(se[npCount + i] > s_sm && se[npCount + i] < s_ds)
2645 if (PolyOrder[npCount + i] < MaxOrder)
2647 PolyOrder[npCount + i] = PolyOrder[npCount + i] + 2;
2650 else if(se[npCount + i] > s_fl && se[npCount + i] < s_sm)
2652 PolyOrder[npCount + i] = PolyOrder[npCount + i] + 1;
2654 else if(se[npCount + i] < s_fl)
2656 if (PolyOrder[npCount + i] > MinOrder)
2658 PolyOrder[npCount + i] = PolyOrder[npCount + i];
2662 m_file2 <<
"<E COMPOSITE= \"C[" << e+1
2663 <<
"]\" NUMMODES=\"" << PolyOrder[npCount + 1]
2664 <<
"\" TYPE=\"MODIFIED\" FIELDS=\"rho,rhou,rhov,rhow,E\" />"
2666 npCount += nQuadPointsElement;
2673 std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
2674 std::vector<std::string> &variables)
2676 const int nPhys =
m_fields[0]->GetNpoints();
2677 const int nCoeffs =
m_fields[0]->GetNcoeffs();
2678 Array<OneD, Array<OneD, NekDouble> > tmp(
m_fields.num_elements());
2680 for (
int i = 0; i <
m_fields.num_elements(); ++i)
2685 Array<OneD, NekDouble> pressure(nPhys), soundspeed(nPhys), mach(nPhys), sensor(nPhys), SensorKappa(nPhys), smooth(nPhys);
2689 GetMach (tmp, soundspeed, mach);
2693 Array<OneD, NekDouble> pFwd(nCoeffs), sFwd(nCoeffs), mFwd(nCoeffs), sensFwd(nCoeffs), smoothFwd(nCoeffs);
2695 m_fields[0]->FwdTrans(pressure, pFwd);
2696 m_fields[0]->FwdTrans(soundspeed, sFwd);
2698 m_fields[0]->FwdTrans(sensor, sensFwd);
2699 m_fields[0]->FwdTrans(smooth, smoothFwd);
2701 variables.push_back (
"p");
2702 variables.push_back (
"a");
2703 variables.push_back (
"Mach");
2704 variables.push_back (
"Sensor");
2705 variables.push_back (
"SmoothVisc");
2706 fieldcoeffs.push_back(pFwd);
2707 fieldcoeffs.push_back(sFwd);
2708 fieldcoeffs.push_back(mFwd);
2709 fieldcoeffs.push_back(sensFwd);
2710 fieldcoeffs.push_back(smoothFwd);