107 c = pow(v[3], (
Omega - 1.0));
108 dcdg = (
Omega - 1.0) * pow(v[3], (
Omega - 2.0));
119 dv[2] = -v[2] * (cp + v[0]) / c;
121 dv[4] = -v[4] * (cp +
m_Pr * v[0]) / c -
139 for (
int i = 0; i < n; i++)
141 yt[i] = y[i] + hh * dydx[i];
146 for (
int i = 0; i < n; i++)
148 yt[i] = y[i] + hh * dyt[i];
153 for (
int i = 0; i < n; i++)
155 yt[i] = y[i] + h * dym[i];
156 dym[i] = dyt[i] + dym[i];
161 for (
int i = 0; i < n; i++)
163 yout[i] = y[i] + h6 * (dydx[i] + dyt[i] + 2 * dym[i]);
179 for (
int i = 0; i < nvar; i++)
192 RK4(v, dv, nvar, x, h, v);
196 cout <<
"bug" << endl;
202 for (
int i = 0; i < nvar; i++)
241 z[i] =
z[i - 1] + 0.5 * (xx[i] - xx[i - 1]) * (ff[3][i] + ff[3][i - 1]);
242 dm = ff[3][i - 1] - ff[1][i - 1];
243 dd = ff[3][i] - ff[1][i];
244 sumd = sumd + 0.5 * (xx[i] - xx[i - 1]) * (dd + dm);
250 file3.open(
"physical_data.dat");
256 for (
int k = 0; k < 5; k++)
263 rho[i] = (1.0 / ff[3][i]);
266 velocity[i] = ff[0][i];
271 for (
int i = 0; i < nQuadraturePts; i++)
276 <<
" " << i <<
"/" << nQuadraturePts << endl;
279 xcher = x_QuadraturePts[i];
280 ycher = y_QuadraturePts[i];
284 rex = 0.5 * pow(((
m_Re) / scale), 2) + (
m_Re)*xin;
285 delsx =
sqrt(2.0 / rex) * scale * (xin)*
m_Pr;
286 scale = scale / delsx;
288 scale2 = ycher * (scale * delta) /
sqrt(
etamax);
289 coeff = 0.5 *
sqrt(2 / (xcher *
m_Re));
293 u_QuadraturePts[i] = 1;
294 rho_QuadraturePts[i] = 1;
295 T_QuadraturePts[i] = 1.0 / rho_QuadraturePts[i];
299 file3 << xcher <<
" " << ycher <<
" "
307 if ((
z[j] <= scale2) && (
z[j + 1] > scale2))
315 ASSERTL0(
false,
"Could not determine index in CompressibleBL");
318 u_QuadraturePts[i] = u[index];
319 rho_QuadraturePts[i] = rho[index];
320 T_QuadraturePts[i] = 1.0 / rho_QuadraturePts[i];
321 v_QuadraturePts[i] = coeff * (u[index] * scale2 - velocity[index]);
330int main(
int argc,
char *argv[])
338 int i, j, k, numModes;
344 for (i = 0; i < nmax; i++)
360 LibUtilities::SessionReader::CreateInstance(argc, argv);
364 SpatialDomains::MeshGraphIO::Read(vSession);
366 int expdim = graphShPt->GetMeshDimension();
368 int nElements, nQuadraturePts = 0;
375 vSession, graphShPt, vSession->GetVariable(0));
378 nElements = Domain->GetExpSize();
379 std::cout <<
"Number of elements = " << nElements
383 nQuadraturePts = Domain->GetTotPoints();
384 std::cout <<
"Number of quadrature points = " << nQuadraturePts
391 Domain->GetCoords(x_QuadraturePts, y_QuadraturePts, z_QuadraturePts);
395 ASSERTL0(
false,
"Routine available for 2D and 3D problem only.")
399 vSession->LoadParameter(
"Re",
m_Re, 1.0);
400 vSession->LoadParameter(
"Mach",
m_Mach, 1.0);
401 vSession->LoadParameter(
"TInf",
m_Tinf, 1.0);
402 vSession->LoadParameter(
"Twall",
m_Twall, 1.0);
403 vSession->LoadParameter(
"Gamma",
m_Gamma, 1.0);
404 vSession->LoadParameter(
"Pr",
m_Pr, 1.0);
405 vSession->LoadParameter(
"L",
m_long, 1.0);
406 vSession->LoadParameter(
"rhoInf",
m_rhoInf, 1.0);
407 vSession->LoadParameter(
"uInf",
m_uInf, 1.0);
408 vSession->LoadParameter(
"GasConstant",
m_R, 1.0);
409 vSession->LoadParameter(
"vInf",
m_vInf, 1.0);
410 vSession->LoadParameter(
"mu",
m_mu, 1.0);
417 cout <<
"Number of points"
434 v[0] = 0.47 * pow(v[1], 0.21);
438 v[1] = 0.062 * pow(
m_Mach, 2) -
440 v[0] = 0.45 - 0.01 *
m_Mach + (
m_Tw - 1.0) * 0.06;
469 for (k = 0; k < maxit; k++)
487 cout <<
"err" << scientific << setprecision(9) <<
" " << err << endl;
493 cout <<
"Calculating" << endl;
495 y_QuadraturePts, u_QuadraturePts, v_QuadraturePts,
496 rho_QuadraturePts, T_QuadraturePts);
503 vstart[2] = v[0] + dv[0];
524 vstart[3] = v[1] + dv[1];
529 vstart[4] = v[1] + dv[1];
537 al11 = (f1[0] - f[0]) / dv[0];
538 al21 = (f1[1] - f[1]) / dv[0];
539 al12 = (f2[0] - f[0]) / dv[1];
540 al22 = (f2[1] - f[1]) / dv[1];
541 det = al11 * al22 - al21 * al12;
543 dv[0] = (-al22 * f[0] + al12 * f[1]) / det;
544 dv[1] = (al21 * f[0] - al11 * f[1]) / det;
549 else if (expdim == 3)
554 cout <<
"Calculating" << endl;
556 z_QuadraturePts, u_QuadraturePts, v_QuadraturePts,
557 rho_QuadraturePts, T_QuadraturePts);
564 vstart[2] = v[0] + dv[0];
585 vstart[3] = v[1] + dv[1];
590 vstart[4] = v[1] + dv[1];
598 al11 = (f1[0] - f[0]) / dv[0];
599 al21 = (f1[1] - f[1]) / dv[0];
600 al12 = (f2[0] - f[0]) / dv[1];
601 al22 = (f2[1] - f[1]) / dv[1];
602 det = al11 * al22 - al21 * al12;
604 dv[0] = (-al22 * f[0] + al12 * f[1]) / det;
605 dv[1] = (al21 * f[0] - al11 * f[1]) / det;
615 verif.open(
"similarity_solution.dat");
616 for (i = 0; i < nQuadraturePts; i++)
618 verif << scientific << setprecision(9) << x_QuadraturePts[i] <<
" \t "
619 << y_QuadraturePts[i] <<
" \t ";
620 verif << scientific << setprecision(9) << u_QuadraturePts[i] <<
" \t "
621 << v_QuadraturePts[i] <<
" \t ";
622 verif << scientific << setprecision(9) << rho_QuadraturePts[i]
623 <<
" \t " << T_QuadraturePts[i] << endl;
628 for (i = 0; i < nQuadraturePts; i++)
630 rho_QuadraturePts[i] = rho_QuadraturePts[i] *
m_rhoInf;
631 u_QuadraturePts[i] = u_QuadraturePts[i] *
m_uInf;
632 v_QuadraturePts[i] = v_QuadraturePts[i] *
m_uInf;
633 T_QuadraturePts[i] = T_QuadraturePts[i] *
m_Tinf;
635 T_QuadraturePts[i] = T_QuadraturePts[i] * rho_QuadraturePts[i] *
m_R;
636 T_QuadraturePts[i] = T_QuadraturePts[i] / (
m_Gamma - 1);
639 0.5 * rho_QuadraturePts[i] *
640 (pow(u_QuadraturePts[i], 2.0) + pow(v_QuadraturePts[i], 2.0));
642 u_QuadraturePts[i] = u_QuadraturePts[i] * rho_QuadraturePts[i];
643 v_QuadraturePts[i] = v_QuadraturePts[i] * rho_QuadraturePts[i];
650 vSession, graphShPt, vSession->GetVariable(0));
655 vSession, graphShPt);
659 vSession, graphShPt);
663 vSession, graphShPt);
667 vSession, graphShPt);
672 Basis = Domain->GetExp(0)->GetBasis(0);
675 std::cout <<
"Number of modes = " << numModes << std::endl;
679 Vmath::Vcopy(nQuadraturePts, u_QuadraturePts, 1, Exp2D_uk->UpdatePhys(),
681 Vmath::Vcopy(nQuadraturePts, v_QuadraturePts, 1, Exp2D_vk->UpdatePhys(),
684 Exp2D_rhok->UpdatePhys(), 1);
685 Vmath::Vcopy(nQuadraturePts, T_QuadraturePts, 1, Exp2D_Tk->UpdatePhys(),
695 Exp[0]->FwdTrans(Exp2D_rhok->GetPhys(), Exp[0]->UpdateCoeffs());
696 Exp[1]->FwdTrans(Exp2D_uk->GetPhys(), Exp[1]->UpdateCoeffs());
697 Exp[2]->FwdTrans(Exp2D_vk->GetPhys(), Exp[2]->UpdateCoeffs());
698 Exp[3]->FwdTrans(Exp2D_Tk->GetPhys(), Exp[3]->UpdateCoeffs());
701 cout << argv[1] << endl;
702 string tmp = argv[1];
703 int len = tmp.size();
704 for (i = 0; i < len - 4; ++i)
706 file_name += argv[1][i];
708 file_name = file_name +
".rst";
711 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
712 Exp[0]->GetFieldDefinitions();
713 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
715 for (j = 0; j < 4; j++)
717 for (i = 0; i < FieldDef.size(); i++)
721 FieldDef[i]->m_fields.push_back(
"rho");
725 FieldDef[i]->m_fields.push_back(
"rhou");
729 FieldDef[i]->m_fields.push_back(
"rhov");
733 FieldDef[i]->m_fields.push_back(
"E");
735 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
741 else if (expdim == 3)
745 vSession, graphShPt, vSession->GetVariable(0));
753 vSession, graphShPt);
757 vSession, graphShPt);
761 vSession, graphShPt);
765 vSession, graphShPt);
769 vSession, graphShPt);
774 Basis = Domain->GetExp(0)->GetBasis(0);
777 std::cout <<
"Number of modes = " << numModes << std::endl;
782 Exp3D_rhok->UpdatePhys(), 1);
783 Vmath::Vcopy(nQuadraturePts, u_QuadraturePts, 1, Exp3D_uk->UpdatePhys(),
785 Vmath::Vcopy(nQuadraturePts, w_QuadraturePts, 1, Exp3D_vk->UpdatePhys(),
787 Vmath::Vcopy(nQuadraturePts, v_QuadraturePts, 1, Exp3D_wk->UpdatePhys(),
789 Vmath::Vcopy(nQuadraturePts, T_QuadraturePts, 1, Exp3D_Tk->UpdatePhys(),
800 Exp[0]->FwdTrans(Exp3D_rhok->GetPhys(), Exp[0]->UpdateCoeffs());
801 Exp[1]->FwdTrans(Exp3D_uk->GetPhys(), Exp[1]->UpdateCoeffs());
802 Exp[2]->FwdTrans(Exp3D_vk->GetPhys(), Exp[2]->UpdateCoeffs());
803 Exp[3]->FwdTrans(Exp3D_wk->GetPhys(), Exp[3]->UpdateCoeffs());
804 Exp[4]->FwdTrans(Exp3D_Tk->GetPhys(), Exp[4]->UpdateCoeffs());
807 cout << argv[1] << endl;
808 string tmp = argv[1];
809 int len = tmp.size();
810 for (i = 0; i < len - 4; ++i)
812 file_name += argv[1][i];
814 file_name = file_name +
".rst";
817 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
818 Exp[0]->GetFieldDefinitions();
819 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
821 for (j = 0; j < 5; j++)
823 for (i = 0; i < FieldDef.size(); i++)
827 FieldDef[i]->m_fields.push_back(
"rho");
831 FieldDef[i]->m_fields.push_back(
"rhou");
835 FieldDef[i]->m_fields.push_back(
"rhov");
839 FieldDef[i]->m_fields.push_back(
"rhow");
843 FieldDef[i]->m_fields.push_back(
"E");
845 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
852 std::cout <<
"----------------------------------------------------\n";
853 std::cout <<
"\n=================================================\n";
854 std::cout <<
"Similarity solution \n";
855 std::cout <<
"===================================================\n";
856 std::cout <<
"***************************************************\n";
857 std::cout <<
"DATA FROM THE SESSION FILE:\n";
858 std::cout <<
"Reynolds number = " <<
m_Re <<
"\t[-]"
860 std::cout <<
"Mach number = " <<
m_Mach <<
"\t[-]"
862 std::cout <<
"Characteristic length = " <<
m_long <<
"\t[m]"
864 std::cout <<
"U_infinity = " <<
m_uInf <<
"\t[m/s]"
866 std::cout <<
"***************************************************\n";
867 std::cout <<
"---------------------------------------------------\n";
868 std::cout <<
"MESH and EXPANSION DATA:\n";
869 std::cout <<
"Done." << std::endl;
int main(int argc, char *argv[])
void OUTPUT(int m_xpoints, Array< OneD, NekDouble > xx, Array< OneD, Array< OneD, NekDouble > > ff, int nQuadraturePts, Array< OneD, NekDouble > x_QuadraturePts, Array< OneD, NekDouble > y_QuadraturePts, Array< OneD, NekDouble > u_QuadraturePts, Array< OneD, NekDouble > v_QuadraturePts, Array< OneD, NekDouble > rho_QuadraturePts, Array< OneD, NekDouble > T_QuadraturePts)
void RKDUMB(Array< OneD, NekDouble > vstart, int nvar, NekDouble x1, NekDouble x2, int m_xpoints, Array< OneD, NekDouble > xx, Array< OneD, Array< OneD, NekDouble > > y)
void COMPBL(Array< OneD, NekDouble > v, Array< OneD, NekDouble > dv)
void RK4(Array< OneD, NekDouble > y, Array< OneD, NekDouble > dydx, int n, NekDouble x, NekDouble h, Array< OneD, NekDouble > yout)
#define ASSERTL0(condition, msg)
Represents a basis of a given type.
int GetNumModes() const
Return order of basis from the basis specification.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< Basis > BasisSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ContField > ContFieldSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::vector< double > z(NPUPPER)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)