Evaluation of the velocity gradient in the cartesian directions Du_x: traceFieldsAdded[10] Du_y: traceFieldsAdded[11] Dv_x: traceFieldsAdded[12] Dv_y: traceFieldsAdded[13]
70 string fname = std::string(argv[2]);
71 int fdot = fname.find_last_of(
'.');
72 if (fdot != std::string::npos)
74 string ending = fname.substr(fdot);
79 if (ending ==
".chk" || ending ==
".fld")
81 fname = fname.substr(0,fdot);
85 fname = fname +
".txt";
93 int nBndEdgePts, nBndEdges, nBndRegions;
98 "Usage: ExtractSurface2DCFS meshfile fieldFile\n");
100 "Extracts a surface from a 2D fld file"
101 "(only for CompressibleFlowSolver and purely 2D .fld files)\n");
106 = LibUtilities::SessionReader::CreateInstance(3, argv);
108 SpatialDomains::MeshGraph::Read(vSession);
110 std::string m_ViscosityType;
123 int nDimensions = m_spacedim;
127 ASSERTL0(vSession->DefinesParameter(
"Gamma"),
128 "Compressible flow sessions must define a Gamma parameter.");
129 vSession->LoadParameter(
"Gamma", m_gamma, 1.4);
132 ASSERTL0(vSession->DefinesParameter(
"pInf"),
133 "Compressible flow sessions must define a pInf parameter.");
134 vSession->LoadParameter(
"pInf", m_pInf, 101325);
137 ASSERTL0(vSession->DefinesParameter(
"rhoInf"),
138 "Compressible flow sessions must define a rhoInf parameter.");
139 vSession->LoadParameter(
"rhoInf",
m_rhoInf, 1.225);
142 ASSERTL0(vSession->DefinesParameter(
"uInf"),
143 "Compressible flow sessions must define a uInf parameter.");
144 vSession->LoadParameter(
"uInf",
m_uInf, 0.1);
147 if (m_spacedim == 2 || m_spacedim == 3)
149 ASSERTL0(vSession->DefinesParameter(
"vInf"),
150 "Compressible flow sessions must define a vInf parameter"
151 "for 2D/3D problems.");
152 vSession->LoadParameter(
"vInf",
m_vInf, 0.0);
158 ASSERTL0(vSession->DefinesParameter(
"wInf"),
159 "Compressible flow sessions must define a wInf parameter"
161 vSession->LoadParameter(
"wInf", m_wInf, 0.0);
164 vSession->LoadParameter (
"GasConstant", m_gasConstant, 287.058);
165 vSession->LoadParameter (
"Twall",
m_Twall, 300.15);
166 vSession->LoadSolverInfo(
"ViscosityType", m_ViscosityType,
"Constant");
167 vSession->LoadParameter (
"mu",
m_mu, 1.78e-05);
171 string fieldFile(argv[2]);
172 vector<LibUtilities::FieldDefinitionsSharedPtr> fieldDef;
173 vector<vector<NekDouble> > fieldData;
180 vector< vector<LibUtilities::PointsType> > pointsType;
181 for (i = 0; i < fieldDef.size(); ++i)
183 vector<LibUtilities::PointsType> ptype;
184 for (j = 0; j < 2; ++j)
188 pointsType.push_back(ptype);
190 graphShPt->SetExpansionInfo(fieldDef, pointsType);
197 int nfields = fieldDef[0]->m_fields.size();
201 for(i = 0; i < pFields.size(); i++)
205 vSession, graphShPt, vSession->GetVariable(i));
214 for (i = 1; i < nfields; ++i)
220 int nSolutionPts = pFields[0]->GetNpoints();
221 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
222 int nElements = pFields[0]->GetExpSize();
238 pFields[0]->GetCoords(x, y, z);
240 pFields[0]->ExtractTracePhys(x, traceX);
241 pFields[0]->ExtractTracePhys(y, traceY);
242 pFields[0]->ExtractTracePhys(z, traceZ);
252 for (j = 0; j < nfields; ++j)
259 for (i = 0; i < fieldData.size(); ++i)
261 Exp[j]->ExtractDataToCoeffs(fieldDef[i], fieldData[i],
262 fieldDef[i]->m_fields[j],
263 Exp[j]->UpdateCoeffs());
265 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(), Exp[j]->UpdatePhys());
266 Vmath::Vcopy(nSolutionPts, Exp[j]->GetPhys(), 1, uFields[j], 1);
267 pFields[0]->ExtractTracePhys(uFields[j], traceFields[j]);
272 int nfieldsAdded = 20;
276 for (j = 0; j < nfieldsAdded; ++j)
290 for(i = 0; i < nDimensions; ++i)
294 pFields[0]->GetTrace()->GetNormals(m_traceNormals);
297 for(i = 0; i < nDimensions; ++i)
305 &m_traceNormals[0][0], 1,
306 &traceFieldsAdded[0][0], 1);
310 &m_traceNormals[1][0], 1,
311 &traceFieldsAdded[1][0], 1);
315 &m_traceNormals[1][0], 1,
316 &m_traceTangents[0][0], 1);
317 Vmath::Neg(nTracePts, &m_traceTangents[0][0], 1);
320 &m_traceTangents[0][0], 1,
321 &traceFieldsAdded[2][0], 1);
325 &m_traceNormals[0][0], 1,
326 &m_traceTangents[1][0], 1);
329 &m_traceTangents[1][0], 1,
330 &traceFieldsAdded[3][0], 1);
340 for (i = 0; i < m_spacedim; i++)
343 &uFields[i + 1][0], 1,
344 &uFields[i + 1][0], 1,
364 &uFields[nfields - 1][0], 1,
373 pFields[0]->ExtractTracePhys(
pressure, traceFieldsAdded[4]);
387 NekDouble GasConstantInv = 1.0/m_gasConstant;
393 pFields[0]->ExtractTracePhys(temperature, traceFieldsAdded[5]);
402 for (i = 0; i < nDimensions; ++ i)
408 for (i = 0; i < nDimensions; ++ i)
410 for (n = 0; n < nElements; n++)
412 phys_offset = pFields[0]->GetPhys_Offset(n);
414 pFields[i]->GetExp(n)->PhysDeriv(
415 i, temperature + phys_offset,
416 auxArray = Dtemperature[i] + phys_offset);
419 pFields[0]->ExtractTracePhys(Dtemperature[i], traceDtemperature[i]);
422 for(i = 0; i < nDimensions; ++i)
425 &m_traceNormals[i][0], 1,
426 &traceDtemperature[i][0], 1,
430 &traceFieldsAdded[6][0], 1,
432 &traceFieldsAdded[6][0], 1);
444 for (i = 0; i < nDimensions; ++ i)
450 for (i = 0; i < nDimensions; ++ i)
452 for (n = 0; n < nElements; n++)
454 phys_offset = pFields[0]->GetPhys_Offset(n);
456 pFields[i]->GetExp(n)->PhysDeriv(
458 auxArray = Dpressure[i] + phys_offset);
461 pFields[0]->ExtractTracePhys(Dpressure[i], traceDpressure[i]);
465 for(i = 0; i < nDimensions; ++i)
468 &m_traceTangents[i][0], 1,
469 &traceDpressure[i][0], 1,
473 &traceFieldsAdded[7][0], 1,
475 &traceFieldsAdded[7][0], 1);
480 &traceDpressure[0][0], 1,
481 &traceFieldsAdded[8][0], 1);
485 &traceDpressure[1][0], 1,
486 &traceFieldsAdded[9][0], 1);
498 for (i = 0; i < nDimensions; ++ i)
504 Vmath::Vdiv(nSolutionPts, uFields[i+1], 1, uFields[0], 1,
507 for (j = 0; j < nDimensions; ++j)
514 for (i = 0; i < nDimensions; ++i)
516 for (j = 0; j < nDimensions; ++j)
518 for (n = 0; n < nElements; n++)
520 phys_offset = pFields[0]->GetPhys_Offset(n);
522 pFields[i]->GetExp(n)->PhysDeriv(
523 j, velocity[i] + phys_offset,
524 auxArray = Dvelocity[i][j] + phys_offset);
528 pFields[0]->ExtractTracePhys(Dvelocity[i][j], traceDvelocity[i][j]);
533 &traceDvelocity[0][0][0], 1,
534 &traceFieldsAdded[10][0], 1);
536 &traceDvelocity[0][1][0], 1,
537 &traceFieldsAdded[11][0], 1);
539 &traceDvelocity[1][0][0], 1,
540 &traceFieldsAdded[12][0], 1);
542 &traceDvelocity[1][1][0], 1,
543 &traceFieldsAdded[13][0], 1);
561 if (m_ViscosityType ==
"Variable")
567 for (
int i = 0; i < nSolutionPts; ++i)
569 ratio = temperature[i] / T_star;
570 mu[i] = mu_star * ratio *
sqrt(ratio) *
571 (T_star + 110.0) / (temperature[i] + 110.0);
584 Vmath::Smul(nSolutionPts, 2.0, &mu[0], 1, &mu2[0], 1);
588 &Dvelocity[0][0][0], 1, &divVel[0], 1);
590 &Dvelocity[1][1][0], 1, &divVel[0], 1);
593 Vmath::Smul(nSolutionPts, lambda, &divVel[0], 1, &divVel[0], 1);
594 Vmath::Vmul(nSolutionPts, &mu[0], 1, &divVel[0], 1, &divVel[0], 1);
598 for (j = 0; j < m_spacedim; ++j)
603 Vmath::Vmul(nSolutionPts, &mu2[0], 1, &Dvelocity[j][j][0], 1,
606 Vmath::Vadd(nSolutionPts, &temp[j][0], 1, &divVel[0], 1, &Sgg[j][0], 1);
614 &Dvelocity[1][0][0], 1, &Sxy[0], 1);
617 Vmath::Vmul(nSolutionPts, &mu[0], 1, &Sxy[0], 1, &Sxy[0], 1);
619 pFields[0]->ExtractTracePhys(Sgg[0], traceFieldsAdded[14]);
620 pFields[0]->ExtractTracePhys(Sgg[1], traceFieldsAdded[15]);
621 pFields[0]->ExtractTracePhys(Sxy, traceFieldsAdded[16]);
636 Vmath::Vcopy(nTracePts, &m_traceNormals[0][0], 1, &cosTeta[0], 1);
639 Vmath::Vcopy(nTracePts, &m_traceNormals[1][0], 1, &sinTeta[0], 1);
642 Vmath::Vsub(nTracePts, &traceFieldsAdded[14][0], 1,
643 &traceFieldsAdded[15][0], 1, &sigma_diff[0], 1);
646 Vmath::Vmul(nTracePts, &cosTeta[0], 1, &sinTeta[0], 1, &tmpTeta[0], 1);
647 Vmath::Smul(nTracePts, 2.0, &tmpTeta[0], 1, &sin2Teta[0], 1);
650 Vmath::Vmul(nTracePts, &cosTeta[0], 1, &cosTeta[0], 1, &cos2Teta[0], 1);
651 Vmath::Vmul(nTracePts, &sinTeta[0], 1, &sinTeta[0], 1, &tmpTeta[0], 1);
652 Vmath::Vsub(nTracePts, &cos2Teta[0], 1, &tmpTeta[0], 1, &cos2Teta[0], 1);
655 Vmath::Smul(nTracePts, -0.5, &sigma_diff[0], 1, &sigma_diff[0], 1);
656 Vmath::Vmul(nTracePts, &sigma_diff[0], 1, &sin2Teta[0], 1, &tau_t[0], 1);
657 Vmath::Vmul(nTracePts, &traceFieldsAdded[16][0], 1, &cos2Teta[0], 1,
659 Vmath::Vadd(nTracePts, &tau_t[0], 1, &tmpTeta[0], 1, &tau_t[0], 1);
661 Vmath::Vcopy(nTracePts, &tau_t[0], 1, &traceFieldsAdded[17][0], 1);
667 pFields[0]->ExtractTracePhys(mu, traceFieldsAdded[18]);
678 Vmath::Smul (nSolutionPts, gamma, soundspeed, 1, soundspeed, 1);
679 Vmath::Vsqrt(nSolutionPts, soundspeed, 1, soundspeed, 1);
684 for (
int i = 0; i < m_spacedim; ++i)
686 Vmath::Vvtvp(nSolutionPts, uFields[i + 1], 1, uFields[i + 1], 1,
690 Vmath::Vdiv(nSolutionPts, mach, 1, uFields[0], 1, mach, 1);
691 Vmath::Vdiv(nSolutionPts, mach, 1, uFields[0], 1, mach, 1);
693 Vmath::Vdiv(nSolutionPts, mach, 1, soundspeed, 1, mach, 1);
695 pFields[0]->ExtractTracePhys(mach, traceFieldsAdded[19]);
700 if (pFields[0]->GetBndCondExpansions().size())
704 nBndRegions = pFields[0]->GetBndCondExpansions().size();
705 for (b = 0; b < nBndRegions; ++b)
707 nBndEdges = pFields[0]->GetBndCondExpansions()[b]->GetExpSize();
708 for (e = 0; e < nBndEdges; ++e)
710 nBndEdgePts = pFields[0]->
711 GetBndCondExpansions()[b]->GetExp(e)->GetNumPoints(0);
713 id2 = pFields[0]->GetTrace()->
714 GetPhys_Offset(pFields[0]->GetTraceMap()->
715 GetBndCondIDToGlobalTraceID(cnt++));
717 if (pFields[0]->GetBndConditions()[b]->
718 GetUserDefined() ==
"WallViscous" ||
719 pFields[0]->GetBndConditions()[b]->
720 GetUserDefined() ==
"WallAdiabatic" ||
721 pFields[0]->GetBndConditions()[b]->
722 GetUserDefined() ==
"Wall")
740 if (pFields[0]->GetBndCondExpansions().size())
742 for (j = 0; j < nfields; ++j)
746 nBndRegions = pFields[j]->GetBndCondExpansions().size();
747 for (b = 0; b < nBndRegions; ++b)
749 nBndEdges = pFields[j]->GetBndCondExpansions()[b]->GetExpSize();
750 for (e = 0; e < nBndEdges; ++e)
752 nBndEdgePts = pFields[j]->
753 GetBndCondExpansions()[b]->GetExp(e)->GetNumPoints(0);
755 id2 = pFields[j]->GetTrace()->
756 GetPhys_Offset(pFields[j]->GetTraceMap()->
757 GetBndCondIDToGlobalTraceID(cnt++));
759 if (pFields[j]->GetBndConditions()[b]->
760 GetUserDefined() ==
"WallViscous" ||
761 pFields[j]->GetBndConditions()[b]->
762 GetUserDefined() ==
"WallAdiabatic" ||
763 pFields[j]->GetBndConditions()[b]->
764 GetUserDefined() ==
"Wall")
767 &surfaceFields[j][id1], 1);
777 if (pFields[0]->GetBndCondExpansions().size())
779 for (j = 0; j < nfieldsAdded; ++j)
783 nBndRegions = pFields[0]->GetBndCondExpansions().size();
784 for (b = 0; b < nBndRegions; ++b)
786 nBndEdges = pFields[0]->GetBndCondExpansions()[b]->GetExpSize();
787 for (e = 0; e < nBndEdges; ++e)
789 nBndEdgePts = pFields[0]->
790 GetBndCondExpansions()[b]->GetExp(e)->GetNumPoints(0);
792 id2 = pFields[0]->GetTrace()->
793 GetPhys_Offset(pFields[0]->GetTraceMap()->
794 GetBndCondIDToGlobalTraceID(cnt++));
796 if (pFields[0]->GetBndConditions()[b]->
797 GetUserDefined() ==
"WallViscous" ||
798 pFields[0]->GetBndConditions()[b]->
799 GetUserDefined() ==
"WallAdiabatic" ||
800 pFields[0]->GetBndConditions()[b]->
801 GetUserDefined() ==
"Wall")
804 &surfaceFieldsAdded[j][id1], 1);
815 std::string vEquation = vSession->GetSolverInfo(
"EQType");
818 BndExp = pFields[0]->GetBndCondExpansions();
829 for(
int i = 0; i < BndExp[0]->GetExpSize(); ++i)
852 for(
int j = 0; j < nbc; ++j)
855 nxOnBnd[j] = surfaceFieldsAdded[0][GlobalIndex];
856 nyOnBnd[j] = surfaceFieldsAdded[1][GlobalIndex];
857 txOnBnd[j] = surfaceFieldsAdded[2][GlobalIndex];
858 tyOnBnd[j] = surfaceFieldsAdded[3][GlobalIndex];
860 PressurOnBnd[j] = surfaceFieldsAdded[4][GlobalIndex];
862 if (vEquation ==
"NavierStokesCFE")
864 ShearStressOnBnd[j] = surfaceFieldsAdded[17][GlobalIndex];
881 Vmath::Vmul(nbc,PressurOnBnd,1,nxOnBnd,1, drag_p,1);
882 Vmath::Vmul(nbc,PressurOnBnd,1,nyOnBnd,1, lift_p,1);
887 Fxp += bc->Integral(drag_p);
888 Fyp += bc->Integral(lift_p);
890 if (vEquation ==
"NavierStokesCFE")
892 Vmath::Vmul(nbc,ShearStressOnBnd,1,txOnBnd,1, drag_v,1);
893 Vmath::Vmul(nbc,ShearStressOnBnd,1,tyOnBnd,1, lift_v,1);
898 Fxv += bc->Integral(drag_v);
899 Fyv += bc->Integral(lift_v);
902 Sref += bc->Integral(Unity);
906 cout <<
"\n Sref = " << Sref << endl;
911 cout <<
" Pressure drag (Fxp) = " << Fxp << endl;
912 cout <<
" Pressure lift (Fyp) = " << Fyp << endl;
913 cout <<
" Viscous drag (Fxv) = " << Fxv << endl;
914 cout <<
" Viscous lift (Fyv) = " << Fyv << endl;
915 cout <<
"\n ==> Total drag = " << Fxp+Fxv << endl;
916 cout <<
" ==> Total lift = " << Fyp+Fyv <<
"\n" << endl;
925 outfile.open(fname.c_str());
926 outfile <<
"% x[m] " <<
" \t"
933 <<
"rho[kg/m^3] " <<
" \t"
934 <<
"rhou[kg/(m^2 s)] " <<
" \t"
935 <<
"rhov[kg/(m^2 s)] " <<
" \t"
939 <<
"dT/dn[k/m] " <<
" \t"
940 <<
"dp/dT[Pa/m] " <<
" \t"
941 <<
"dp/dx[Pa/m] " <<
" \t"
942 <<
"dp/dy[Pa/m] " <<
" \t"
943 <<
"du/dx[s^-1] " <<
" \t"
944 <<
"du/dy[s^-1] " <<
" \t"
945 <<
"dv/dx[s^-1] " <<
" \t"
946 <<
"dv/dy[s^-1] " <<
" \t"
947 <<
"tau_xx[Pa] " <<
" \t"
948 <<
"tau_yy[Pa] " <<
" \t"
949 <<
"tau_xy[Pa] " <<
" \t"
950 <<
"tau_t[Pa] " <<
" \t"
951 <<
"mu[Pa s] " <<
" \t"
955 for (i = 0; i < id1; ++i)
957 outfile << scientific
960 << surfaceX[i] <<
" \t "
961 << surfaceY[i] <<
" \t "
962 << surfaceZ[i] <<
" \t "
963 << surfaceFieldsAdded[0][i] <<
" \t "
964 << surfaceFieldsAdded[1][i] <<
" \t "
965 << surfaceFieldsAdded[2][i] <<
" \t "
966 << surfaceFieldsAdded[3][i] <<
" \t "
967 << surfaceFields[0][i] <<
" \t "
968 << surfaceFields[1][i] <<
" \t "
969 << surfaceFields[2][i] <<
" \t "
970 << surfaceFields[3][i] <<
" \t "
971 << surfaceFieldsAdded[4][i] <<
" \t "
972 << surfaceFieldsAdded[5][i] <<
" \t "
973 << surfaceFieldsAdded[6][i] <<
" \t "
974 << surfaceFieldsAdded[7][i] <<
" \t "
975 << surfaceFieldsAdded[8][i] <<
" \t "
976 << surfaceFieldsAdded[9][i] <<
" \t "
977 << surfaceFieldsAdded[10][i] <<
" \t "
978 << surfaceFieldsAdded[11][i] <<
" \t "
979 << surfaceFieldsAdded[12][i] <<
" \t "
980 << surfaceFieldsAdded[13][i] <<
" \t "
981 << surfaceFieldsAdded[14][i] <<
" \t "
982 << surfaceFieldsAdded[15][i] <<
" \t "
983 << surfaceFieldsAdded[16][i] <<
" \t "
984 << surfaceFieldsAdded[17][i] <<
" \t "
985 << surfaceFieldsAdded[18][i] <<
" \t "
986 << surfaceFieldsAdded[19][i] <<
" \t "
990 outfile << endl << endl;
#define ASSERTL0(condition, msg)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
This class is the abstractio n of a global discontinuous two- dimensional spectral/hp element expansi...
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< StdExpansion1D > StdExpansion1DSharedPtr
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Neg(int n, T *x, const int incx)
Negate x = -x.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
scalarT< T > sqrt(scalarT< T > in)