32 int main(
int argc,
char *argv[])
38 int i, j, numModes, nFields;
41 if((argc != 2) && (argc != 3))
43 fprintf(stderr,
"Usage: ./FldAddFalknerSkanBL sessionFile [SysSolnType]\n");exit(1);
58 string stability_solver;
62 BL_type = vSession->GetSolverInfo(
"BL_type");
63 txt_file = vSession->GetSolverInfo(
"txt_file");
64 stability_solver = vSession->GetSolverInfo(
"stability_solver");
66 if(stability_solver !=
"velocity_correction_scheme" &&
67 stability_solver !=
"coupled_scheme")
69 fprintf(stderr,
"Error: You must specify the stability solver in the session file properly.\n");
70 fprintf(stderr,
"Options: 'velocity_correction_scheme' [output ===> (u,v,p)]; 'coupled_scheme' [output ===>(u,v)]\n");
74 vSession->LoadParameter(
"Re", Re, 1.0);
75 vSession->LoadParameter(
"L",
L, 1.0);
76 vSession->LoadParameter(
"U_inf", U_inf, 1.0);
77 vSession->LoadParameter(
"x", x, 1.0);
78 vSession->LoadParameter(
"x_0", x_0, 1.0);
79 vSession->LoadParameter(
"NumberLines_txt", numLines, 1.0);
84 fprintf(stderr,
"Error: x must be positive ===> CHECK the session file\n");
90 fprintf(stderr,
"Error: x_0 must be positive or at least equal to 0 ===> CHECK the session file\n");
93 std::cout<<
"\n=========================================================================\n";
94 std::cout<<
"Falkner-Skan Boundary Layer Generation (version of July 12th 2012)\n";
95 std::cout<<
"=========================================================================\n";
96 std::cout<<
"*************************************************************************\n";
97 std::cout<<
"DATA FROM THE SESSION FILE:\n";
98 std::cout <<
"Reynolds number = " << Re <<
"\t[-]" << std::endl;
99 std::cout <<
"Characteristic length = " <<
L <<
"\t\t[m]" << std::endl;
100 std::cout <<
"U_infinity = " << U_inf <<
"\t[m/s]" << std::endl;
101 std::cout <<
"Position x (parallel case only) = " << x <<
"\t\t[m]" << std::endl;
102 std::cout <<
"Position x_0 to start the BL [m] = " << x_0 <<
"\t\t[m]" << std::endl;
103 std::cout <<
"Number of lines of the .txt file = " << numLines <<
"\t[-]" << std::endl;
104 std::cout <<
"BL type = " << BL_type << std::endl;
105 std::cout <<
".txt file read = " << txt_file << std::endl;
106 std::cout <<
"Stability solver = " << stability_solver << std::endl;
107 std::cout<<
"*************************************************************************\n";
108 std::cout<<
"-------------------------------------------------------------------------\n";
109 std::cout<<
"MESH and EXPANSION DATA:\n";
116 graphShPt = SpatialDomains::MeshGraph::Read(vSession);
124 nElements = Domain->GetExpSize();
125 std::cout <<
"Number of elements = " << nElements << std::endl;
129 nQuadraturePts = Domain->GetTotPoints();
130 std::cout <<
"Number of quadrature points = " << nQuadraturePts << std::endl;
139 Domain->GetCoords(x_QuadraturePts,y_QuadraturePts,z_QuadraturePts);
142 const char *txt_file_char;
144 txt_file_char = txt_file.c_str();
147 ifstream pFile(txt_file_char);
150 cout <<
"Errro: Unable to open the .txt file with the BL data\n";
154 numLines = numLines/3;
156 std::vector<std::vector<NekDouble> > GlobalArray (3);
160 GlobalArray[j].resize(numLines);
161 for (i=0; i<=numLines-1; i++)
164 GlobalArray[j][i] = d;
179 for (i=0; i<numLines; i++)
181 eta[i] = GlobalArray[0][i];
182 f[i] = GlobalArray[1][i];
183 df[i] = GlobalArray[2][i];
211 if(BL_type ==
"Parallel")
213 for(i=0; i<nQuadraturePts; i++)
215 eta_QuadraturePts[i] = y_QuadraturePts[i] *
sqrt(U_inf / (2 * x * nu));
216 for(j=0; j<numLines-1; j++)
218 if(eta_QuadraturePts[i] >= eta[j] && eta_QuadraturePts[i] <= eta[j+1])
220 f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];
221 df_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (df[j+1] - df[j]) / (eta[j+1] - eta[j]) + df[j];
224 else if(eta_QuadraturePts[i] == 1000000)
226 f_QuadraturePts[i] = f[numLines-1];
227 df_QuadraturePts[i] = df[numLines-1];
230 else if(eta_QuadraturePts[i] > eta[numLines-1])
232 f_QuadraturePts[i] = f[numLines-1] + df[numLines-1] * (eta_QuadraturePts[i] - eta[numLines-1]);
233 df_QuadraturePts[i] = df[numLines-1];
238 u_QuadraturePts[i] = U_inf * df_QuadraturePts[i];
239 v_QuadraturePts[i] = nu *
sqrt(U_inf / (2.0 * nu * x)) * (y_QuadraturePts[i] *
sqrt(U_inf / (2.0 * nu * x)) * df_QuadraturePts[i] - f_QuadraturePts[i]);
240 p_QuadraturePts[i] = 0.0;
248 if(BL_type ==
"nonParallel")
250 for(i=0; i<nQuadraturePts; i++)
252 eta_QuadraturePts[i] = y_QuadraturePts[i] *
sqrt(U_inf / (2 * (x_QuadraturePts[i] + x_0) * nu));
254 if((x_QuadraturePts[i] + x_0) == 0)
256 eta_QuadraturePts[i] = 1000000;
259 for(j=0; j<numLines-1; j++)
261 if(eta_QuadraturePts[i] >= eta[j] && eta_QuadraturePts[i] <= eta[j+1])
263 f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];
264 df_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (df[j+1] - df[j]) / (eta[j+1] - eta[j]) + df[j];
267 else if(eta_QuadraturePts[i] == 1000000)
269 f_QuadraturePts[i] = f[numLines-1];
270 df_QuadraturePts[i] = df[numLines-1];
273 else if(eta_QuadraturePts[i] > eta[numLines-1])
275 f_QuadraturePts[i] = f[numLines-1] + df[numLines-1] * (eta_QuadraturePts[i] - eta[numLines-1]);
276 df_QuadraturePts[i] = df[numLines-1];
280 u_QuadraturePts[i] = U_inf * df_QuadraturePts[i];
281 v_QuadraturePts[i] = nu *
sqrt(U_inf / (2.0 * nu * (x_QuadraturePts[i] + x_0))) *
282 (y_QuadraturePts[i] *
sqrt(U_inf / (2.0 * nu * (x_QuadraturePts[i] + x_0))) *
283 df_QuadraturePts[i] - f_QuadraturePts[i]);
286 if((x_QuadraturePts[i] + x_0) == 0)
288 u_QuadraturePts[i] = U_inf;
289 v_QuadraturePts[i] = 0.0;
293 if((x_QuadraturePts[i] + x_0) == 0 && y_QuadraturePts[i] == 0)
295 u_QuadraturePts[i] = 0.0;
296 v_QuadraturePts[i] = 0.0;
299 p_QuadraturePts[i] = 0.0;
308 etaOriginal = fopen(
"eta.txt",
"w+");
309 for(i=0; i<numLines; i++)
311 fprintf(etaOriginal,
"%f %f %f \n", eta[i], f[i], df[i]);
317 yQ = fopen(
"yQ.txt",
"w+");
318 for(i=0; i<nQuadraturePts; i++)
320 fprintf(yQ,
"%f %f %f %f %f %f %f\n", x_QuadraturePts[i], y_QuadraturePts[i], u_QuadraturePts[i],
321 v_QuadraturePts[i], eta_QuadraturePts[i], f_QuadraturePts[i], df_QuadraturePts[i]);
343 Basis = Domain->GetExp(0)->GetBasis(0);
346 std::cout<<
"Number of modes = " << numModes << std::endl;
349 Vmath::Vcopy(nQuadraturePts, u_QuadraturePts , 1, Exp2D_uk->UpdatePhys(), 1);
350 Vmath::Vcopy(nQuadraturePts, v_QuadraturePts, 1, Exp2D_vk->UpdatePhys(), 1);
351 Vmath::Vcopy(nQuadraturePts, p_QuadraturePts , 1, Exp2D_pk->UpdatePhys(), 1);
358 if(stability_solver ==
"velocity_correction_scheme")
362 Exp[0]->FwdTrans(Exp2D_uk->GetPhys(),Exp[0]->UpdateCoeffs());
363 Exp[1]->FwdTrans(Exp2D_vk->GetPhys(),Exp[1]->UpdateCoeffs());
365 if(stability_solver ==
"velocity_correction_scheme")
366 Exp[2]->FwdTrans(Exp2D_pk->GetPhys(),Exp[2]->UpdateCoeffs());
373 string FalknerSkan =
"FalknerSkan.fld";
376 if(stability_solver ==
"coupled_scheme")
379 if(stability_solver ==
"velocity_correction_scheme")
384 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef = Exp[0]->GetFieldDefinitions();
385 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
387 for(j = 0; j < nFields; ++j)
389 for(i = 0; i < FieldDef.size(); ++i)
393 FieldDef[i]->m_fields.push_back(
"u");
397 FieldDef[i]->m_fields.push_back(
"v");
399 else if(j == 2 && stability_solver ==
"velocity_correction_scheme")
401 FieldDef[i]->m_fields.push_back(
"p");
403 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
409 std::cout<<
"-------------------------------------------------------------------\n";
int main(int argc, char *argv[])
Main.
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
The above copyright notice and this permission notice shall be included.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)