39 #include <boost/algorithm/string.hpp>
49 "Euler equations in conservative variables without "
50 "artificial diffusion.");
62 if(
m_session->DefinesSolverInfo(
"PROBLEMTYPE"))
65 std::string ProblemTypeStr =
88 ASSERTL0(
false,
"Implicit CFE not set up.");
113 bool dumpInitialConditions,
132 int phystot =
m_fields[0]->GetTotPoints();
133 Array<OneD, NekDouble> noise(phystot);
135 m_session->LoadParameter(
"Noise", Noise,0.0);
136 int m_nConvectiveFields =
m_fields.num_elements();
140 for(
int i = 0; i < m_nConvectiveFields; i++)
148 if (dumpInitialConditions)
159 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
160 Array<
OneD, Array<OneD, NekDouble> > &outarray,
164 int nvariables = inarray.num_elements();
167 Array<OneD, Array<OneD, NekDouble> > advVel(
m_spacedim);
171 for (i = 0; i < nvariables; ++i)
182 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
183 Array<
OneD, Array<OneD, NekDouble> > &outarray,
187 int nvariables = inarray.num_elements();
196 for(i = 0; i < nvariables; ++i)
206 ASSERTL0(
false,
"No Continuous Galerkin for Euler equations");
210 ASSERTL0(
false,
"Unknown projection scheme");
227 Array<
OneD, Array<OneD, NekDouble> > &inarray,
231 int nvariables =
m_fields.num_elements();
235 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
238 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
245 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
248 ASSERTL0(
false,
"WallViscous is a wrong bc for the "
253 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
260 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
267 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
274 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
277 for (
int i = 0; i < nvariables; ++i)
280 m_fields[i]->EvaluateBoundaryConditions(time, varName);
285 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
292 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
298 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
308 Array<OneD, NekDouble> &outfield,
331 const Array<OneD, NekDouble> &x,
332 const Array<OneD, NekDouble> &y,
333 const Array<OneD, NekDouble> &z,
334 Array<
OneD, Array<OneD, NekDouble> > &u,
338 int nq = x.num_elements();
348 NekDouble fac = 1.0/(16.0*gamma*M_PI*M_PI);
357 for (
int i = 0; i < nq; ++i)
359 xbar = x[i] - u0*time - x0;
360 ybar = y[i] - v0*time - y0;
361 r = sqrt(xbar*xbar + ybar*ybar);
362 tmp = beta*exp(1-r*r);
363 u[0][i+o] = pow(1.0 - (gamma-1.0)*tmp*tmp*fac, 1.0/(gamma-1.0));
364 u[1][i+o] = u[0][i+o]*(u0 - tmp*ybar/(2*M_PI));
365 u[2][i+o] = u[0][i+o]*(v0 + tmp*xbar/(2*M_PI));
366 u[
m_spacedim+1][i+o] = pow(u[0][i+o], gamma)/(gamma-1.0) +
367 0.5*(u[1][i+o]*u[1][i+o] + u[2][i+o]*u[2][i+o]) / u[0][i+o];
376 Array<OneD, NekDouble> &outarray,
380 Array<OneD, NekDouble> x(nTotQuadPoints);
381 Array<OneD, NekDouble> y(nTotQuadPoints);
382 Array<OneD, NekDouble> z(nTotQuadPoints);
383 Array<OneD, Array<OneD, NekDouble> > u(
m_spacedim+2);
389 u[i] = Array<OneD, NekDouble>(nTotQuadPoints);
403 Array<OneD, NekDouble> x(nTotQuadPoints);
404 Array<OneD, NekDouble> y(nTotQuadPoints);
405 Array<OneD, NekDouble> z(nTotQuadPoints);
406 Array<OneD, Array<OneD, NekDouble> > u(
m_spacedim+2);
412 u[i] = Array<OneD, NekDouble>(nTotQuadPoints);
418 for(
int i = 0; i <
m_fields.num_elements(); ++i)
434 Array<
OneD, Array<OneD, NekDouble> > &physarray)
436 int nvariables = physarray.num_elements();
438 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
439 const Array<OneD, const int> &bndTraceMap =
m_fields[0]->GetTraceBndMap();
442 for (
int i = 0; i < nvariables; ++i)
444 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
445 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
449 e_max =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
451 for(
int e = 0; e < e_max; ++e)
454 GetBndCondExpansions()[bcRegion]->GetExp(e)->GetTotPoints();
456 GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
457 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(bndTraceMap[cnt++]);
459 Array<OneD,NekDouble> x(npoints, 0.0);
460 Array<OneD,NekDouble> y(npoints, 0.0);
461 Array<OneD,NekDouble> z(npoints, 0.0);
463 m_fields[0]->GetBndCondExpansions()[bcRegion]->
464 GetExp(e)->GetCoords(x, y, z);
468 for (
int i = 0; i < nvariables; ++i)
471 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
472 UpdatePhys())[id1], 1);
482 Array<OneD, NekDouble> &outarray)
486 Array<OneD, NekDouble> rho(nTotQuadPoints, 100.0);
487 Array<OneD, NekDouble> rhou(nTotQuadPoints);
488 Array<OneD, NekDouble> rhov(nTotQuadPoints);
489 Array<OneD, NekDouble> E(nTotQuadPoints);
490 Array<OneD, NekDouble> x(nTotQuadPoints);
491 Array<OneD, NekDouble> y(nTotQuadPoints);
492 Array<OneD, NekDouble> z(nTotQuadPoints);
497 NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
511 NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
513 for (
int i = 0; i < nTotQuadPoints; ++i)
515 while ((abs(errV) > toll) || (abs(errTheta) > toll))
519 c = sqrt(1.0 - gamma_1_2 * VV);
523 J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
524 1.0 / (5.0 * c * c * c * c * c) -
525 0.5 * log((1.0 + c) / (1.0 - c));
527 r = pow(c, 1.0 / gamma_1_2);
528 xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
529 yi = phi / (r * V) * sqrt(1.0 - VV * pp);
530 par1 = 25.0 - 5.0 * VV;
536 J11 = 39062.5 / pow(par1, 3.5) * (1.0 / VV - 2.0 / VV * ss) *
537 V + 1562.5 / pow(par1, 2.5) * (-2.0 / (VV * V) + 4.0 /
538 (VV * V) * ss) + 12.5 / pow(par1, 1.5) * V + 312.5 /
539 pow(par1, 2.5) * V + 7812.5 / pow(par1, 3.5) * V -
540 0.25 * (-1.0 / pow(par1, 0.5) * V/(1.0 - 0.2 *
541 pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
542 pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
543 pow(par1, 0.5) * V) / (1.0 + 0.2 * pow(par1, 0.5)) *
544 (1.0 - 0.2 * pow(par1, 0.5));
546 J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
547 J21 = -6250.0 / (VV * V) * sint /
548 pow(par1, 2.5) * pow((1.0 - ss), 0.5) +
549 78125.0 / V * sint / pow(par1, 3.5) *
550 pow((1.0 - ss), 0.5);
553 if(abs(y[i])<toll && abs(cos(theta))<toll)
555 J22 = -39062.5 / pow(par1, 3.5) / V + 3125 /
556 pow(par1, 2.5) / (VV * V) + 12.5 / pow(par1, 1.5) *
557 V + 312.5 / pow(par1, 2.5) * V + 7812.5 /
558 pow(par1, 3.5) * V - 0.25 * (-1.0 / pow(par1, 0.5) *
559 V / (1.0 - 0.2 * pow(par1, 0.5)) - (1.0 + 0.2 *
560 pow(par1, 0.5)) / pow((1.0 - 0.2 *
561 pow(par1, 0.5)), 2.0) / pow(par1, 0.5) * V) /
562 (1.0 + 0.2 * pow(par1, 0.5)) * (1.0 - 0.2 *
566 dV = -1.0 / J22 * Fx;
572 J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
573 pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
574 pow(par1, 2.5) / pow((1.0 - ss), 0.5) * cos(theta);
576 det = -1.0 / (J11 * J22 - J12 * J21);
579 dV = det * ( J22 * Fx - J12 * Fy);
580 dtheta = det * (-J21 * Fx + J11 * Fy);
584 theta = theta + dtheta;
587 errTheta = abs(dtheta);
591 c = sqrt(1.0 - gamma_1_2 * VV);
592 r = pow(c, 1.0 / gamma_1_2);
595 rhou[i] = rho[i] * V * cos(theta);
596 rhov[i] = rho[i] * V * sin(theta);
597 P = (c * c) * rho[i] / gamma;
598 E[i] = P / (gamma - 1.0) + 0.5 *
599 (rhou[i] * rhou[i] / rho[i] + rhov[i] * rhov[i] / rho[i]);
623 ASSERTL0(
false,
"Error in variable number!");
634 int nbnd =
m_fields[0]->GetBndConditions().num_elements();
637 for(
int bcRegion=0; bcRegion < nbnd; ++bcRegion)
641 GetBndCondExpansions()[bcRegion]->GetNpoints();
643 Array<OneD,NekDouble> x0(npoints, 0.0);
644 Array<OneD,NekDouble> x1(npoints, 0.0);
645 Array<OneD,NekDouble> x2(npoints, 0.0);
647 Array<OneD, NekDouble> rho(npoints, 0.0);
648 Array<OneD, NekDouble> rhou(npoints, 0.0);
649 Array<OneD, NekDouble> rhov(npoints, 0.0);
650 Array<OneD, NekDouble> E(npoints, 0.0);
652 m_fields[0]->GetBndCondExpansions()[bcRegion]->
653 GetCoords(x0, x1, x2);
656 NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
670 NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
673 for (
int j = 0; j < npoints; j++)
675 while ((abs(errV) > toll) || (abs(errTheta) > toll))
680 c = sqrt(1.0 - gamma_1_2 * VV);
684 J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
685 1.0 / (5.0 * c * c * c * c * c) -
686 0.5 * log((1.0 + c) / (1.0 - c));
688 r = pow(c, 1.0 / gamma_1_2);
689 xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
690 yi = phi / (r * V) * sqrt(1.0 - VV * pp);
691 par1 = 25.0 - 5.0 * VV;
697 J11 = 39062.5 / pow(par1, 3.5) *
698 (1.0 / VV - 2.0 / VV * ss) * V +
699 1562.5 / pow(par1, 2.5) * (-2.0 /
700 (VV * V) + 4.0 / (VV * V) * ss) +
701 12.5 / pow(par1, 1.5) * V +
702 312.5 / pow(par1, 2.5) * V +
703 7812.5 / pow(par1, 3.5) * V -
704 0.25 * (-1.0 / pow(par1, 0.5) * V /
705 (1.0 - 0.2 * pow(par1, 0.5)) - (1.0 + 0.2 *
706 pow(par1, 0.5)) / pow((1.0 - 0.2 *
707 pow(par1, 0.5)), 2.0) /
708 pow(par1, 0.5) * V) /
709 (1.0 + 0.2 * pow(par1, 0.5)) *
710 (1.0 - 0.2 * pow(par1, 0.5));
712 J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
713 J21 = -6250.0 / (VV * V) * sint / pow(par1, 2.5) *
714 pow((1.0 - ss), 0.5) + 78125.0 / V * sint /
715 pow(par1, 3.5) * pow((1.0 - ss), 0.5);
718 if (abs(x1[j]) < toll && abs(cos(theta)) < toll)
721 J22 = -39062.5 / pow(par1, 3.5) / V +
722 3125 / pow(par1, 2.5) / (VV * V) + 12.5 /
723 pow(par1, 1.5) * V + 312.5 / pow(par1, 2.5) * V +
724 7812.5 / pow(par1, 3.5) * V -
725 0.25 * (-1.0 / pow(par1, 0.5) * V /
726 (1.0 - 0.2 * pow(par1, 0.5)) -
727 (1.0 + 0.2 * pow(par1, 0.5)) /
728 pow((1.0 - 0.2* pow(par1, 0.5)), 2.0) /
730 (1.0 + 0.2 * pow(par1, 0.5)) *
731 (1.0 - 0.2 * pow(par1, 0.5));
734 dV = -1.0 / J22 * Fx;
741 J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
742 pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
743 pow(par1, 2.5) / pow((1.0 - ss), 0.5) *
746 det = -1.0 / (J11 * J22 - J12 * J21);
749 dV = det * ( J22 * Fx - J12 * Fy);
750 dtheta = det * (-J21 * Fx + J11 * Fy);
754 theta = theta + dtheta;
757 errTheta = abs(dtheta);
761 c = sqrt(1.0 - gamma_1_2 * VV);
762 rho[j] = pow(c, 1.0 / gamma_1_2) * exp(-1.0);
763 rhou[j] = rho[j] * V * cos(theta) * exp(-1.0);
764 rhov[j] = rho[j] * V * sin(theta) * exp(-1.0);
765 P = (c * c) * rho[j] / gamma;
766 E[j] = P / (gamma - 1.0) + 0.5 *
768 rho[j] + rhov[j] * rhov[j] / rho[j]);
772 V = kExt * sin(theta);
777 m_fields[0]->GetBndCondExpansions()[bcRegion]->SetPhys(rho);
778 m_fields[1]->GetBndCondExpansions()[bcRegion]->SetPhys(rhou);
779 m_fields[2]->GetBndCondExpansions()[bcRegion]->SetPhys(rhov);
780 m_fields[3]->GetBndCondExpansions()[bcRegion]->SetPhys(E);
783 for(
int i = 0; i <
m_fields.num_elements(); ++i)
785 m_fields[i]->GetBndCondExpansions()[bcRegion]->
786 FwdTrans_BndConstrained(
787 m_fields[i]->GetBndCondExpansions()[bcRegion]->
789 m_fields[i]->GetBndCondExpansions()[bcRegion]->
799 Array<OneD,NekDouble> x0(nq);
800 Array<OneD,NekDouble> x1(nq);
801 Array<OneD,NekDouble> x2(nq);
807 for(
int j = 0; j < nq; j++)
818 for (
int bcRegion = 0; bcRegion < nbnd; ++bcRegion)
822 GetBndCondExpansions()[bcRegion]->GetNpoints();
824 Array<OneD,NekDouble> xb0(npoints, 0.0);
825 Array<OneD,NekDouble> xb1(npoints, 0.0);
826 Array<OneD,NekDouble> xb2(npoints, 0.0);
828 m_fields[0]->GetBndCondExpansions()[bcRegion]->
829 GetCoords(xb0, xb1, xb2);
831 for (
int k = 0; k < npoints; k++)
833 Dist = sqrt((xb0[k] - x0[j]) * (xb0[k] - x0[j]) +
834 (xb1[k] - x1[j]) * (xb1[k] - x1[j]));
838 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
840 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
842 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
844 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
849 rhou = rhou / SumDist;
850 rhov = rhov / SumDist;
853 (
m_fields[0]->UpdatePhys())[j] = rho;
854 (
m_fields[1]->UpdatePhys())[j] = rhou;
855 (
m_fields[2]->UpdatePhys())[j] = rhov;
860 for (
int i = 0 ; i <
m_fields.num_elements(); i++)
879 Array<
OneD, Array<OneD, NekDouble> > &physarray)
881 int nvariables = physarray.num_elements();
883 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
889 int nPointsTot =
m_fields[0]->GetTotPoints();
890 int nPointsTot_plane =
m_fields[0]->GetPlane(0)->GetTotPoints();
891 n_planes = nPointsTot/nPointsTot_plane;
892 nTraceNumPoints = nTraceNumPoints * n_planes;
896 for (
int i = 0; i < nvariables; ++i)
898 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
899 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
902 int id2, id2_plane, e_max;
904 e_max =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
906 for(
int e = 0; e < e_max; ++e)
909 GetBndCondExpansions()[bcRegion]->GetExp(e)->GetTotPoints();
911 GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
916 int cnt_plane = cnt/n_planes;
918 int e_max_plane = e_max/n_planes;
921 int planeID = floor((e + 0.5 )/ e_max_plane );
922 e_plane = e - e_max_plane*planeID;
924 id2_plane =
m_fields[0]->GetTrace()->GetPhys_Offset(
926 GetBndCondCoeffsToGlobalCoeffsMap(
927 cnt_plane + e_plane));
928 id2 = id2_plane + planeID*nTracePts_plane;
933 GetTrace()->GetPhys_Offset(
m_fields[0]->GetTraceMap()->
934 GetBndCondTraceToGlobalTraceMap(cnt++));
937 Array<OneD,NekDouble> x0(npoints, 0.0);
938 Array<OneD,NekDouble> x1(npoints, 0.0);
939 Array<OneD,NekDouble> x2(npoints, 0.0);
941 m_fields[0]->GetBndCondExpansions()[bcRegion]->
942 GetExp(e)->GetCoords(x0, x1, x2);
945 NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
959 NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
962 for (
int j = 0; j < npoints; j++)
965 while ((abs(errV) > toll) || (abs(errTheta) > toll))
969 c = sqrt(1.0 - gamma_1_2 * VV);
973 J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
974 1.0 / (5.0 * c * c * c * c * c) -
975 0.5 * log((1.0 + c) / (1.0 - c));
977 r = pow(c, 1.0 / gamma_1_2);
978 xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
979 yi = phi / (r * V) * sqrt(1.0 - VV * pp);
980 par1 = 25.0 - 5.0 * VV;
986 J11 = 39062.5 / pow(par1, 3.5) *
987 (1.0 / VV - 2.0 / VV * ss) * V + 1562.5 /
988 pow(par1, 2.5) * (-2.0 / (VV * V) + 4.0 /
989 (VV * V) * ss) + 12.5 / pow(par1, 1.5) * V +
990 312.5 / pow(par1, 2.5) * V + 7812.5 /
991 pow(par1, 3.5) * V - 0.25 *
992 (-1.0 / pow(par1, 0.5) * V / (1.0 - 0.2 *
993 pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
994 pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
995 pow(par1, 0.5) * V) / (1.0 + 0.2 * pow(par1, 0.5)) *
996 (1.0 - 0.2 * pow(par1, 0.5));
998 J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
999 J21 = -6250.0 / (VV * V) * sint / pow(par1, 2.5) *
1000 pow((1.0 - ss), 0.5) + 78125.0 / V * sint /
1001 pow(par1, 3.5) * pow((1.0 - ss), 0.5);
1004 if (abs(x1[j]) < toll && abs(cos(theta)) < toll)
1006 J22 = -39062.5 / pow(par1, 3.5) / V + 3125 /
1007 pow(par1, 2.5) / (VV * V) + 12.5 /
1008 pow(par1, 1.5) * V + 312.5 / pow(par1, 2.5) *
1009 V + 7812.5 / pow(par1, 3.5) * V - 0.25 *
1010 (-1.0 / pow(par1, 0.5) * V / (1.0 - 0.2 *
1011 pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
1012 pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
1013 pow(par1, 0.5) * V) / (1.0 + 0.2 *
1014 pow(par1, 0.5)) * (1.0 - 0.2 * pow(par1, 0.5));
1017 dV = -1.0 / J22 * Fx;
1023 J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
1024 pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
1025 pow(par1, 2.5) / pow((1.0 - ss), 0.5) *
1028 det = -1.0 / (J11 * J22 - J12 * J21);
1031 dV = det * ( J22 * Fx - J12 * Fy);
1032 dtheta = det * (-J21 * Fx + J11 * Fy);
1036 theta = theta + dtheta;
1039 errTheta = abs(dtheta);
1042 c = sqrt(1.0 - gamma_1_2 * VV);
1045 std::string restartstr =
"RESTART";
1046 if (time<timeramp &&
1047 !(
m_session->DefinesFunction(
"InitialConditions") &&
1048 m_session->GetFunctionType(
"InitialConditions", 0) ==
1051 Fwd[0][kk] = pow(c, 1.0 / gamma_1_2) *
1052 exp(-1.0 + time /timeramp);
1054 Fwd[1][kk] = Fwd[0][kk] * V * cos(theta) *
1055 exp(-1 + time / timeramp);
1057 Fwd[2][kk] = Fwd[0][kk] * V * sin(theta) *
1058 exp(-1 + time / timeramp);
1062 Fwd[0][kk] = pow(c, 1.0 / gamma_1_2);
1063 Fwd[1][kk] = Fwd[0][kk] * V * cos(theta);
1064 Fwd[2][kk] = Fwd[0][kk] * V * sin(theta);
1067 P = (c * c) * Fwd[0][kk] / gamma;
1068 Fwd[3][kk] = P / (gamma - 1.0) + 0.5 *
1069 (Fwd[1][kk] * Fwd[1][kk] / Fwd[0][kk] +
1070 Fwd[2][kk] * Fwd[2][kk] / Fwd[0][kk]);
1075 V = kExt * sin(theta);
1078 for (
int i = 0; i < nvariables; ++i)
1081 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
1082 UpdatePhys())[id1],1);