28 using namespace Nektar;
31 int main(
int argc,
char *argv[])
37 int i, j, numModes, nFields;
40 if((argc != 2) && (argc != 3))
42 fprintf(stderr,
"Usage: ./FldAddFalknerSkanBL sessionFile [SysSolnType]\n");exit(1);
57 string stability_solver;
61 BL_type = vSession->GetSolverInfo(
"BL_type");
62 txt_file = vSession->GetSolverInfo(
"txt_file");
63 stability_solver = vSession->GetSolverInfo(
"stability_solver");
65 if(stability_solver !=
"velocity_correction_scheme" &&
66 stability_solver !=
"coupled_scheme")
68 fprintf(stderr,
"Error: You must specify the stability solver in the session file properly.\n");
69 fprintf(stderr,
"Options: 'velocity_correction_scheme' [output ===> (u,v,p)]; 'coupled_scheme' [output ===>(u,v)]\n");
73 vSession->LoadParameter(
"Re", Re, 1.0);
74 vSession->LoadParameter(
"L", L, 1.0);
75 vSession->LoadParameter(
"U_inf", U_inf, 1.0);
76 vSession->LoadParameter(
"x", x, 1.0);
77 vSession->LoadParameter(
"x_0", x_0, 1.0);
78 vSession->LoadParameter(
"NumberLines_txt", numLines, 1.0);
83 fprintf(stderr,
"Error: x must be positive ===> CHECK the session file\n");
89 fprintf(stderr,
"Error: x_0 must be positive or at least equal to 0 ===> CHECK the session file\n");
92 std::cout<<
"\n=========================================================================\n";
93 std::cout<<
"Falkner-Skan Boundary Layer Generation (version of July 12th 2012)\n";
94 std::cout<<
"=========================================================================\n";
95 std::cout<<
"*************************************************************************\n";
96 std::cout<<
"DATA FROM THE SESSION FILE:\n";
97 std::cout <<
"Reynolds number = " << Re <<
"\t[-]" << std::endl;
98 std::cout <<
"Characteristic length = " << L <<
"\t\t[m]" << std::endl;
99 std::cout <<
"U_infinity = " << U_inf <<
"\t[m/s]" << std::endl;
100 std::cout <<
"Position x (parallel case only) = " << x <<
"\t\t[m]" << std::endl;
101 std::cout <<
"Position x_0 to start the BL [m] = " << x_0 <<
"\t\t[m]" << std::endl;
102 std::cout <<
"Number of lines of the .txt file = " << numLines <<
"\t[-]" << std::endl;
103 std::cout <<
"BL type = " << BL_type << std::endl;
104 std::cout <<
".txt file read = " << txt_file << std::endl;
105 std::cout <<
"Stability solver = " << stability_solver << std::endl;
106 std::cout<<
"*************************************************************************\n";
107 std::cout<<
"-------------------------------------------------------------------------\n";
108 std::cout<<
"MESH and EXPANSION DATA:\n";
123 nElements = Domain->GetExpSize();
124 std::cout <<
"Number of elements = " << nElements << std::endl;
128 nQuadraturePts = Domain->GetTotPoints();
129 std::cout <<
"Number of quadrature points = " << nQuadraturePts << std::endl;
132 Array<OneD,NekDouble> x_QuadraturePts;
133 Array<OneD,NekDouble> y_QuadraturePts;
134 Array<OneD,NekDouble> z_QuadraturePts;
135 x_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
136 y_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
137 z_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
138 Domain->GetCoords(x_QuadraturePts,y_QuadraturePts,z_QuadraturePts);
141 const char *txt_file_char;
143 txt_file_char = txt_file.c_str();
146 ifstream pFile(txt_file_char);
149 cout <<
"Errro: Unable to open the .txt file with the BL data\n";
153 numLines = numLines/3;
155 std::vector<std::vector<NekDouble> > GlobalArray (3);
159 GlobalArray[j].resize(numLines);
160 for (i=0; i<=numLines-1; i++)
163 GlobalArray[j][i] = d;
170 Array<OneD,NekDouble> eta;
171 Array<OneD,NekDouble> f;
172 Array<OneD,NekDouble> df;
174 eta = Array<OneD,NekDouble>(numLines);
175 f = Array<OneD,NekDouble>(numLines);
176 df = Array<OneD,NekDouble>(numLines);
178 for (i=0; i<numLines; i++)
180 eta[i] = GlobalArray[0][i];
181 f[i] = GlobalArray[1][i];
182 df[i] = GlobalArray[2][i];
188 Array<OneD,NekDouble> eta_QuadraturePts;
189 eta_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
191 Array<OneD,NekDouble> f_QuadraturePts;
192 f_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
194 Array<OneD,NekDouble> df_QuadraturePts;
195 df_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
197 Array<OneD,NekDouble> u_QuadraturePts;
198 u_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
200 Array<OneD,NekDouble> v_QuadraturePts;
201 v_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
203 Array<OneD,NekDouble> p_QuadraturePts;
204 p_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
210 if(BL_type ==
"Parallel")
212 for(i=0; i<nQuadraturePts; i++)
214 eta_QuadraturePts[i] = y_QuadraturePts[i] * sqrt(U_inf / (2 * x * nu));
215 for(j=0; j<numLines-1; j++)
217 if(eta_QuadraturePts[i] >= eta[j] && eta_QuadraturePts[i] <= eta[j+1])
219 f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];
220 df_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (df[j+1] - df[j]) / (eta[j+1] - eta[j]) + df[j];
223 else if(eta_QuadraturePts[i] == 1000000)
225 f_QuadraturePts[i] = f[numLines-1];
226 df_QuadraturePts[i] = df[numLines-1];
229 else if(eta_QuadraturePts[i] > eta[numLines-1])
231 f_QuadraturePts[i] = f[numLines-1] + df[numLines-1] * (eta_QuadraturePts[i] - eta[numLines-1]);
232 df_QuadraturePts[i] = df[numLines-1];
237 u_QuadraturePts[i] = U_inf * df_QuadraturePts[i];
238 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]);
239 p_QuadraturePts[i] = 0.0;
247 if(BL_type ==
"nonParallel")
249 for(i=0; i<nQuadraturePts; i++)
251 eta_QuadraturePts[i] = y_QuadraturePts[i] * sqrt(U_inf / (2 * (x_QuadraturePts[i] + x_0) * nu));
253 if((x_QuadraturePts[i] + x_0) == 0)
255 eta_QuadraturePts[i] = 1000000;
258 for(j=0; j<numLines-1; j++)
260 if(eta_QuadraturePts[i] >= eta[j] && eta_QuadraturePts[i] <= eta[j+1])
262 f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];
263 df_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (df[j+1] - df[j]) / (eta[j+1] - eta[j]) + df[j];
266 else if(eta_QuadraturePts[i] == 1000000)
268 f_QuadraturePts[i] = f[numLines-1];
269 df_QuadraturePts[i] = df[numLines-1];
272 else if(eta_QuadraturePts[i] > eta[numLines-1])
274 f_QuadraturePts[i] = f[numLines-1] + df[numLines-1] * (eta_QuadraturePts[i] - eta[numLines-1]);
275 df_QuadraturePts[i] = df[numLines-1];
279 u_QuadraturePts[i] = U_inf * df_QuadraturePts[i];
280 v_QuadraturePts[i] = nu * sqrt(U_inf / (2.0 * nu * (x_QuadraturePts[i] + x_0))) *
281 (y_QuadraturePts[i] * sqrt(U_inf / (2.0 * nu * (x_QuadraturePts[i] + x_0))) *
282 df_QuadraturePts[i] - f_QuadraturePts[i]);
285 if((x_QuadraturePts[i] + x_0) == 0)
287 u_QuadraturePts[i] = U_inf;
288 v_QuadraturePts[i] = 0.0;
292 if((x_QuadraturePts[i] + x_0) == 0 && y_QuadraturePts[i] == 0)
294 u_QuadraturePts[i] = 0.0;
295 v_QuadraturePts[i] = 0.0;
298 p_QuadraturePts[i] = 0.0;
307 etaOriginal = fopen(
"eta.txt",
"w+");
308 for(i=0; i<numLines; i++)
310 fprintf(etaOriginal,
"%f %f %f \n", eta[i], f[i], df[i]);
316 yQ = fopen(
"yQ.txt",
"w+");
317 for(i=0; i<nQuadraturePts; i++)
319 fprintf(yQ,
"%f %f %f %f %f %f %f\n", x_QuadraturePts[i], y_QuadraturePts[i], u_QuadraturePts[i],
320 v_QuadraturePts[i], eta_QuadraturePts[i], f_QuadraturePts[i], df_QuadraturePts[i]);
342 Basis = Domain->GetExp(0)->GetBasis(0);
343 numModes = Basis->GetNumModes();
345 std::cout<<
"Number of modes = " << numModes << std::endl;
348 Vmath::Vcopy(nQuadraturePts, u_QuadraturePts , 1, Exp2D_uk->UpdatePhys(), 1);
349 Vmath::Vcopy(nQuadraturePts, v_QuadraturePts, 1, Exp2D_vk->UpdatePhys(), 1);
350 Vmath::Vcopy(nQuadraturePts, p_QuadraturePts , 1, Exp2D_pk->UpdatePhys(), 1);
353 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(3);
357 if(stability_solver ==
"velocity_correction_scheme")
361 Exp[0]->FwdTrans(Exp2D_uk->GetPhys(),Exp[0]->UpdateCoeffs());
362 Exp[1]->FwdTrans(Exp2D_vk->GetPhys(),Exp[1]->UpdateCoeffs());
364 if(stability_solver ==
"velocity_correction_scheme")
365 Exp[2]->FwdTrans(Exp2D_pk->GetPhys(),Exp[2]->UpdateCoeffs());
372 string FalknerSkan =
"FalknerSkan.fld";
375 if(stability_solver ==
"coupled_scheme")
378 if(stability_solver ==
"velocity_correction_scheme")
383 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef = Exp[0]->GetFieldDefinitions();
384 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
386 for(j = 0; j < nFields; ++j)
388 for(i = 0; i < FieldDef.size(); ++i)
392 FieldDef[i]->m_fields.push_back(
"u");
396 FieldDef[i]->m_fields.push_back(
"v");
398 else if(j == 2 && stability_solver ==
"velocity_correction_scheme")
400 FieldDef[i]->m_fields.push_back(
"p");
402 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
408 std::cout<<
"-------------------------------------------------------------------\n";