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);
172 for (i = 0; i < nvariables; ++i)
183 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
184 Array<
OneD, Array<OneD, NekDouble> > &outarray,
188 int nvariables = inarray.num_elements();
197 for(i = 0; i < nvariables; ++i)
207 ASSERTL0(
false,
"No Continuous Galerkin for Euler equations");
211 ASSERTL0(
false,
"Unknown projection scheme");
228 Array<
OneD, Array<OneD, NekDouble> > &inarray,
232 int nvariables =
m_fields.num_elements();
236 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
239 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
246 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
249 ASSERTL0(
false,
"WallViscous is a wrong bc for the "
254 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
261 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
268 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
275 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
278 for (
int i = 0; i < nvariables; ++i)
281 m_fields[i]->EvaluateBoundaryConditions(time, varName);
286 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
293 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
299 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
309 Array<OneD, NekDouble> &outfield,
332 const Array<OneD, NekDouble> &x,
333 const Array<OneD, NekDouble> &y,
334 const Array<OneD, NekDouble> &z,
335 Array<
OneD, Array<OneD, NekDouble> > &u,
339 int nq = x.num_elements();
349 NekDouble fac = 1.0/(16.0*gamma*M_PI*M_PI);
358 for (
int i = 0; i < nq; ++i)
360 xbar = x[i] - u0*time - x0;
361 ybar = y[i] - v0*time - y0;
362 r = sqrt(xbar*xbar + ybar*ybar);
363 tmp = beta*exp(1-r*r);
364 u[0][i+o] = pow(1.0 - (gamma-1.0)*tmp*tmp*fac, 1.0/(gamma-1.0));
365 u[1][i+o] = u[0][i+o]*(u0 - tmp*ybar/(2*M_PI));
366 u[2][i+o] = u[0][i+o]*(v0 + tmp*xbar/(2*M_PI));
367 u[
m_spacedim+1][i+o] = pow(u[0][i+o], gamma)/(gamma-1.0) +
368 0.5*(u[1][i+o]*u[1][i+o] + u[2][i+o]*u[2][i+o]) / u[0][i+o];
377 Array<OneD, NekDouble> &outarray,
381 Array<OneD, NekDouble> x(nTotQuadPoints);
382 Array<OneD, NekDouble> y(nTotQuadPoints);
383 Array<OneD, NekDouble> z(nTotQuadPoints);
384 Array<OneD, Array<OneD, NekDouble> > u(
m_spacedim+2);
390 u[i] = Array<OneD, NekDouble>(nTotQuadPoints);
404 Array<OneD, NekDouble> x(nTotQuadPoints);
405 Array<OneD, NekDouble> y(nTotQuadPoints);
406 Array<OneD, NekDouble> z(nTotQuadPoints);
407 Array<OneD, Array<OneD, NekDouble> > u(
m_spacedim+2);
413 u[i] = Array<OneD, NekDouble>(nTotQuadPoints);
419 for(
int i = 0; i <
m_fields.num_elements(); ++i)
435 Array<
OneD, Array<OneD, NekDouble> > &physarray)
437 int nvariables = physarray.num_elements();
439 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
440 const Array<OneD, const int> &bndTraceMap =
m_fields[0]->GetTraceBndMap();
443 for (
int i = 0; i < nvariables; ++i)
445 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
446 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
450 e_max =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
452 for(
int e = 0; e < e_max; ++e)
455 GetBndCondExpansions()[bcRegion]->GetExp(e)->GetTotPoints();
457 GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
458 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(bndTraceMap[cnt++]);
460 Array<OneD,NekDouble> x(npoints, 0.0);
461 Array<OneD,NekDouble> y(npoints, 0.0);
462 Array<OneD,NekDouble> z(npoints, 0.0);
464 m_fields[0]->GetBndCondExpansions()[bcRegion]->
465 GetExp(e)->GetCoords(x, y, z);
469 for (
int i = 0; i < nvariables; ++i)
472 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
473 UpdatePhys())[id1], 1);
483 Array<OneD, NekDouble> &outarray)
487 Array<OneD, NekDouble> rho(nTotQuadPoints, 100.0);
488 Array<OneD, NekDouble> rhou(nTotQuadPoints);
489 Array<OneD, NekDouble> rhov(nTotQuadPoints);
490 Array<OneD, NekDouble> E(nTotQuadPoints);
491 Array<OneD, NekDouble> x(nTotQuadPoints);
492 Array<OneD, NekDouble> y(nTotQuadPoints);
493 Array<OneD, NekDouble> z(nTotQuadPoints);
498 NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
512 NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
514 for (
int i = 0; i < nTotQuadPoints; ++i)
516 while ((abs(errV) > toll) || (abs(errTheta) > toll))
520 c = sqrt(1.0 - gamma_1_2 * VV);
524 J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
525 1.0 / (5.0 * c * c * c * c * c) -
526 0.5 * log((1.0 + c) / (1.0 - c));
528 r = pow(c, 1.0 / gamma_1_2);
529 xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
530 yi = phi / (r * V) * sqrt(1.0 - VV * pp);
531 par1 = 25.0 - 5.0 * VV;
537 J11 = 39062.5 / pow(par1, 3.5) * (1.0 / VV - 2.0 / VV * ss) *
538 V + 1562.5 / pow(par1, 2.5) * (-2.0 / (VV * V) + 4.0 /
539 (VV * V) * ss) + 12.5 / pow(par1, 1.5) * V + 312.5 /
540 pow(par1, 2.5) * V + 7812.5 / pow(par1, 3.5) * V -
541 0.25 * (-1.0 / pow(par1, 0.5) * V/(1.0 - 0.2 *
542 pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
543 pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
544 pow(par1, 0.5) * V) / (1.0 + 0.2 * pow(par1, 0.5)) *
545 (1.0 - 0.2 * pow(par1, 0.5));
547 J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
548 J21 = -6250.0 / (VV * V) * sint /
549 pow(par1, 2.5) * pow((1.0 - ss), 0.5) +
550 78125.0 / V * sint / pow(par1, 3.5) *
551 pow((1.0 - ss), 0.5);
554 if(abs(y[i])<toll && abs(cos(theta))<toll)
556 J22 = -39062.5 / pow(par1, 3.5) / V + 3125 /
557 pow(par1, 2.5) / (VV * V) + 12.5 / pow(par1, 1.5) *
558 V + 312.5 / pow(par1, 2.5) * V + 7812.5 /
559 pow(par1, 3.5) * V - 0.25 * (-1.0 / pow(par1, 0.5) *
560 V / (1.0 - 0.2 * pow(par1, 0.5)) - (1.0 + 0.2 *
561 pow(par1, 0.5)) / pow((1.0 - 0.2 *
562 pow(par1, 0.5)), 2.0) / pow(par1, 0.5) * V) /
563 (1.0 + 0.2 * pow(par1, 0.5)) * (1.0 - 0.2 *
567 dV = -1.0 / J22 * Fx;
573 J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
574 pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
575 pow(par1, 2.5) / pow((1.0 - ss), 0.5) * cos(theta);
577 det = -1.0 / (J11 * J22 - J12 * J21);
580 dV = det * ( J22 * Fx - J12 * Fy);
581 dtheta = det * (-J21 * Fx + J11 * Fy);
585 theta = theta + dtheta;
588 errTheta = abs(dtheta);
592 c = sqrt(1.0 - gamma_1_2 * VV);
593 r = pow(c, 1.0 / gamma_1_2);
596 rhou[i] = rho[i] * V * cos(theta);
597 rhov[i] = rho[i] * V * sin(theta);
598 P = (c * c) * rho[i] / gamma;
599 E[i] = P / (gamma - 1.0) + 0.5 *
600 (rhou[i] * rhou[i] / rho[i] + rhov[i] * rhov[i] / rho[i]);
624 ASSERTL0(
false,
"Error in variable number!");
635 int nbnd =
m_fields[0]->GetBndConditions().num_elements();
638 for(
int bcRegion=0; bcRegion < nbnd; ++bcRegion)
642 GetBndCondExpansions()[bcRegion]->GetNpoints();
644 Array<OneD,NekDouble> x0(npoints, 0.0);
645 Array<OneD,NekDouble> x1(npoints, 0.0);
646 Array<OneD,NekDouble> x2(npoints, 0.0);
648 Array<OneD, NekDouble> rho(npoints, 0.0);
649 Array<OneD, NekDouble> rhou(npoints, 0.0);
650 Array<OneD, NekDouble> rhov(npoints, 0.0);
651 Array<OneD, NekDouble> E(npoints, 0.0);
653 m_fields[0]->GetBndCondExpansions()[bcRegion]->
654 GetCoords(x0, x1, x2);
657 NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
671 NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
674 for (
int j = 0; j < npoints; j++)
676 while ((abs(errV) > toll) || (abs(errTheta) > toll))
681 c = sqrt(1.0 - gamma_1_2 * VV);
685 J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
686 1.0 / (5.0 * c * c * c * c * c) -
687 0.5 * log((1.0 + c) / (1.0 - c));
689 r = pow(c, 1.0 / gamma_1_2);
690 xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
691 yi = phi / (r * V) * sqrt(1.0 - VV * pp);
692 par1 = 25.0 - 5.0 * VV;
698 J11 = 39062.5 / pow(par1, 3.5) *
699 (1.0 / VV - 2.0 / VV * ss) * V +
700 1562.5 / pow(par1, 2.5) * (-2.0 /
701 (VV * V) + 4.0 / (VV * V) * ss) +
702 12.5 / pow(par1, 1.5) * V +
703 312.5 / pow(par1, 2.5) * V +
704 7812.5 / pow(par1, 3.5) * V -
705 0.25 * (-1.0 / pow(par1, 0.5) * V /
706 (1.0 - 0.2 * pow(par1, 0.5)) - (1.0 + 0.2 *
707 pow(par1, 0.5)) / pow((1.0 - 0.2 *
708 pow(par1, 0.5)), 2.0) /
709 pow(par1, 0.5) * V) /
710 (1.0 + 0.2 * pow(par1, 0.5)) *
711 (1.0 - 0.2 * pow(par1, 0.5));
713 J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
714 J21 = -6250.0 / (VV * V) * sint / pow(par1, 2.5) *
715 pow((1.0 - ss), 0.5) + 78125.0 / V * sint /
716 pow(par1, 3.5) * pow((1.0 - ss), 0.5);
719 if (abs(x1[j]) < toll && abs(cos(theta)) < toll)
722 J22 = -39062.5 / pow(par1, 3.5) / V +
723 3125 / pow(par1, 2.5) / (VV * V) + 12.5 /
724 pow(par1, 1.5) * V + 312.5 / pow(par1, 2.5) * V +
725 7812.5 / pow(par1, 3.5) * V -
726 0.25 * (-1.0 / pow(par1, 0.5) * V /
727 (1.0 - 0.2 * pow(par1, 0.5)) -
728 (1.0 + 0.2 * pow(par1, 0.5)) /
729 pow((1.0 - 0.2* pow(par1, 0.5)), 2.0) /
731 (1.0 + 0.2 * pow(par1, 0.5)) *
732 (1.0 - 0.2 * pow(par1, 0.5));
735 dV = -1.0 / J22 * Fx;
742 J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
743 pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
744 pow(par1, 2.5) / pow((1.0 - ss), 0.5) *
747 det = -1.0 / (J11 * J22 - J12 * J21);
750 dV = det * ( J22 * Fx - J12 * Fy);
751 dtheta = det * (-J21 * Fx + J11 * Fy);
755 theta = theta + dtheta;
758 errTheta = abs(dtheta);
762 c = sqrt(1.0 - gamma_1_2 * VV);
763 rho[j] = pow(c, 1.0 / gamma_1_2) * exp(-1.0);
764 rhou[j] = rho[j] * V * cos(theta) * exp(-1.0);
765 rhov[j] = rho[j] * V * sin(theta) * exp(-1.0);
766 P = (c * c) * rho[j] / gamma;
767 E[j] = P / (gamma - 1.0) + 0.5 *
769 rho[j] + rhov[j] * rhov[j] / rho[j]);
773 V = kExt * sin(theta);
778 m_fields[0]->GetBndCondExpansions()[bcRegion]->SetPhys(rho);
779 m_fields[1]->GetBndCondExpansions()[bcRegion]->SetPhys(rhou);
780 m_fields[2]->GetBndCondExpansions()[bcRegion]->SetPhys(rhov);
781 m_fields[3]->GetBndCondExpansions()[bcRegion]->SetPhys(E);
784 for(
int i = 0; i <
m_fields.num_elements(); ++i)
786 m_fields[i]->GetBndCondExpansions()[bcRegion]->
787 FwdTrans_BndConstrained(
788 m_fields[i]->GetBndCondExpansions()[bcRegion]->
790 m_fields[i]->GetBndCondExpansions()[bcRegion]->
800 Array<OneD,NekDouble> x0(nq);
801 Array<OneD,NekDouble> x1(nq);
802 Array<OneD,NekDouble> x2(nq);
808 for(
int j = 0; j < nq; j++)
819 for (
int bcRegion = 0; bcRegion < nbnd; ++bcRegion)
823 GetBndCondExpansions()[bcRegion]->GetNpoints();
825 Array<OneD,NekDouble> xb0(npoints, 0.0);
826 Array<OneD,NekDouble> xb1(npoints, 0.0);
827 Array<OneD,NekDouble> xb2(npoints, 0.0);
829 m_fields[0]->GetBndCondExpansions()[bcRegion]->
830 GetCoords(xb0, xb1, xb2);
832 for (
int k = 0; k < npoints; k++)
834 Dist = sqrt((xb0[k] - x0[j]) * (xb0[k] - x0[j]) +
835 (xb1[k] - x1[j]) * (xb1[k] - x1[j]));
839 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
841 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
843 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
845 GetBndCondExpansions()[bcRegion]->GetPhys())[k];
850 rhou = rhou / SumDist;
851 rhov = rhov / SumDist;
854 (
m_fields[0]->UpdatePhys())[j] = rho;
855 (
m_fields[1]->UpdatePhys())[j] = rhou;
856 (
m_fields[2]->UpdatePhys())[j] = rhov;
861 for (
int i = 0 ; i <
m_fields.num_elements(); i++)
880 Array<
OneD, Array<OneD, NekDouble> > &physarray)
882 int nvariables = physarray.num_elements();
884 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
890 int nPointsTot =
m_fields[0]->GetTotPoints();
891 int nPointsTot_plane =
m_fields[0]->GetPlane(0)->GetTotPoints();
892 n_planes = nPointsTot/nPointsTot_plane;
893 nTraceNumPoints = nTraceNumPoints * n_planes;
897 for (
int i = 0; i < nvariables; ++i)
899 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
900 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
903 int id2, id2_plane, e_max;
905 e_max =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
907 for(
int e = 0; e < e_max; ++e)
910 GetBndCondExpansions()[bcRegion]->GetExp(e)->GetTotPoints();
912 GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
917 int cnt_plane = cnt/n_planes;
919 int e_max_plane = e_max/n_planes;
922 int planeID = floor((e + 0.5 )/ e_max_plane );
923 e_plane = e - e_max_plane*planeID;
925 id2_plane =
m_fields[0]->GetTrace()->GetPhys_Offset(
927 GetBndCondCoeffsToGlobalCoeffsMap(
928 cnt_plane + e_plane));
929 id2 = id2_plane + planeID*nTracePts_plane;
934 GetTrace()->GetPhys_Offset(
m_fields[0]->GetTraceMap()->
935 GetBndCondTraceToGlobalTraceMap(cnt++));
938 Array<OneD,NekDouble> x0(npoints, 0.0);
939 Array<OneD,NekDouble> x1(npoints, 0.0);
940 Array<OneD,NekDouble> x2(npoints, 0.0);
942 m_fields[0]->GetBndCondExpansions()[bcRegion]->
943 GetExp(e)->GetCoords(x0, x1, x2);
946 NekDouble c, k, phi, r, J, VV, pp, sint, P, ss;
960 NekDouble gamma_1_2 = (gamma - 1.0) / 2.0;
963 for (
int j = 0; j < npoints; j++)
966 while ((abs(errV) > toll) || (abs(errTheta) > toll))
970 c = sqrt(1.0 - gamma_1_2 * VV);
974 J = 1.0 / c + 1.0 / (3.0 * c * c * c) +
975 1.0 / (5.0 * c * c * c * c * c) -
976 0.5 * log((1.0 + c) / (1.0 - c));
978 r = pow(c, 1.0 / gamma_1_2);
979 xi = 1.0 / (2.0 * r) * (1.0 / VV - 2.0 * pp) + J / 2.0;
980 yi = phi / (r * V) * sqrt(1.0 - VV * pp);
981 par1 = 25.0 - 5.0 * VV;
987 J11 = 39062.5 / pow(par1, 3.5) *
988 (1.0 / VV - 2.0 / VV * ss) * V + 1562.5 /
989 pow(par1, 2.5) * (-2.0 / (VV * V) + 4.0 /
990 (VV * V) * ss) + 12.5 / pow(par1, 1.5) * V +
991 312.5 / pow(par1, 2.5) * V + 7812.5 /
992 pow(par1, 3.5) * V - 0.25 *
993 (-1.0 / pow(par1, 0.5) * V / (1.0 - 0.2 *
994 pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
995 pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
996 pow(par1, 0.5) * V) / (1.0 + 0.2 * pow(par1, 0.5)) *
997 (1.0 - 0.2 * pow(par1, 0.5));
999 J12 = -6250.0 / pow(par1, 2.5) / VV * sint * cos(theta);
1000 J21 = -6250.0 / (VV * V) * sint / pow(par1, 2.5) *
1001 pow((1.0 - ss), 0.5) + 78125.0 / V * sint /
1002 pow(par1, 3.5) * pow((1.0 - ss), 0.5);
1005 if (abs(x1[j]) < toll && abs(cos(theta)) < toll)
1007 J22 = -39062.5 / pow(par1, 3.5) / V + 3125 /
1008 pow(par1, 2.5) / (VV * V) + 12.5 /
1009 pow(par1, 1.5) * V + 312.5 / pow(par1, 2.5) *
1010 V + 7812.5 / pow(par1, 3.5) * V - 0.25 *
1011 (-1.0 / pow(par1, 0.5) * V / (1.0 - 0.2 *
1012 pow(par1, 0.5)) - (1.0 + 0.2 * pow(par1, 0.5)) /
1013 pow((1.0 - 0.2 * pow(par1, 0.5)), 2.0) /
1014 pow(par1, 0.5) * V) / (1.0 + 0.2 *
1015 pow(par1, 0.5)) * (1.0 - 0.2 * pow(par1, 0.5));
1018 dV = -1.0 / J22 * Fx;
1024 J22 = 3125.0 / VV * cos(theta) / pow(par1, 2.5) *
1025 pow((1.0 - ss), 0.5) - 3125.0 / VV * ss /
1026 pow(par1, 2.5) / pow((1.0 - ss), 0.5) *
1029 det = -1.0 / (J11 * J22 - J12 * J21);
1032 dV = det * ( J22 * Fx - J12 * Fy);
1033 dtheta = det * (-J21 * Fx + J11 * Fy);
1037 theta = theta + dtheta;
1040 errTheta = abs(dtheta);
1043 c = sqrt(1.0 - gamma_1_2 * VV);
1046 std::string restartstr =
"RESTART";
1047 if (time<timeramp &&
1048 !(
m_session->DefinesFunction(
"InitialConditions") &&
1049 m_session->GetFunctionType(
"InitialConditions", 0) ==
1052 Fwd[0][kk] = pow(c, 1.0 / gamma_1_2) *
1053 exp(-1.0 + time /timeramp);
1055 Fwd[1][kk] = Fwd[0][kk] * V * cos(theta) *
1056 exp(-1 + time / timeramp);
1058 Fwd[2][kk] = Fwd[0][kk] * V * sin(theta) *
1059 exp(-1 + time / timeramp);
1063 Fwd[0][kk] = pow(c, 1.0 / gamma_1_2);
1064 Fwd[1][kk] = Fwd[0][kk] * V * cos(theta);
1065 Fwd[2][kk] = Fwd[0][kk] * V * sin(theta);
1068 P = (c * c) * Fwd[0][kk] / gamma;
1069 Fwd[3][kk] = P / (gamma - 1.0) + 0.5 *
1070 (Fwd[1][kk] * Fwd[1][kk] / Fwd[0][kk] +
1071 Fwd[2][kk] * Fwd[2][kk] / Fwd[0][kk]);
1076 V = kExt * sin(theta);
1079 for (
int i = 0; i < nvariables; ++i)
1082 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
1083 UpdatePhys())[id1],1);