46 VortexWaveInteraction::VortexWaveInteraction(
int argc,
char *argv[])
47 : m_nOuterIterations(0)
57 std::string VWICondFile(argv[argc - 1]);
58 VWICondFile +=
"_VWI.xml";
59 std::vector<std::string> VWIFilenames;
60 VWIFilenames.push_back(meshfile);
61 VWIFilenames.push_back(VWICondFile);
69 m_sessionVWI->LoadParameter(
"OuterIterationStoreSize", storesize, 10);
101 if (
m_sessionVWI->DefinesSolverInfo(
"LinfPressureNorm"))
119 if (
m_sessionVWI->DefinesSolverInfo(
"MoveMeshToCriticalLayer"))
151 std::string IncCondFile(argv[argc - 1]);
152 IncCondFile +=
"_IncNSCond.xml";
153 std::vector<std::string> IncNSFilenames;
154 IncNSFilenames.push_back(meshfile);
155 IncNSFilenames.push_back(IncCondFile);
161 std::string vEquation =
m_sessionRoll->GetSolverInfo(
"SolverType");
171 int ncoeffs =
m_solverRoll->UpdateFields()[0]->GetNcoeffs();
174 for (
int i = 1; i < 4; ++i)
185 std::string AdvDiffCondFile(argv[argc - 1]);
186 AdvDiffCondFile +=
"_AdvDiffCond.xml";
187 std::vector<std::string> AdvDiffFilenames;
188 AdvDiffFilenames.push_back(meshfile);
189 AdvDiffFilenames.push_back(AdvDiffCondFile);
197 std::string LinNSCondFile(argv[argc - 1]);
198 LinNSCondFile +=
"_LinNSCond.xml";
199 std::vector<std::string> LinNSFilenames;
200 LinNSFilenames.push_back(meshfile);
201 LinNSFilenames.push_back(LinNSCondFile);
209 std::string LZstr(
"LZ");
211 cout <<
"Setting LZ in Linearised solver to " << LZ << endl;
215 if (
m_sessionVWI->DefinesSolverInfo(
"VWIIterationType"))
217 std::string IterationTypeStr =
235 m_sessionVWI->MatchSolverInfo(
"RestartIteration",
"True", restart,
false);
246 if ((fp = fopen(
"OuterIter.his",
"r")))
249 std::vector<NekDouble> Alpha, Growth, Phase;
251 while (fgets(buf, BUFSIZ, fp))
253 sscanf(buf,
"%*d:%lf%lf%lf", &alpha, &growth, &phase);
254 Alpha.push_back(alpha);
255 Growth.push_back(growth);
256 Phase.push_back(phase);
264 for (
int i = 0; i < nvals; ++i)
278 cout <<
" No File OuterIter.his to restart from" << endl;
284 string nstr = boost::lexical_cast<std::string>(
m_iterStart);
285 cout <<
"Restarting from iteration " <<
m_iterStart << endl;
286 std::string rstfile =
"cp -f Save/" +
m_sessionName +
".rst." +
288 cout <<
" " << rstfile << endl;
289 if (system(rstfile.c_str()))
293 std::string vwifile =
"cp -f Save/" +
m_sessionName +
".vwi." +
295 cout <<
" " << vwifile << endl;
296 if (system(vwifile.c_str()))
303 ASSERTL0(
false,
"Unknown VWIITerationType in restart");
310 if ((fp = fopen(
"ConvergedSolns",
"r")))
313 std::vector<NekDouble> WaveForce, Alpha;
315 while (fgets(buf, BUFSIZ, fp))
317 sscanf(buf,
"%*d:%lf%lf", &waveforce, &alpha);
318 WaveForce.push_back(waveforce);
319 Alpha.push_back(alpha);
322 if (Alpha.size() > 1)
327 for (
int i = 1; i < Alpha.size(); ++i)
329 if (fabs(
m_alpha[0] - Alpha[min_i]) < min_alph)
332 min_alph = fabs(
m_alpha[0] - Alpha[min_i]);
337 int min_j = (min_i == 0) ? 1 : 0;
338 min_alph = fabs(
m_alpha[0] - Alpha[min_j]);
339 for (
int i = 0; i < Alpha.size(); ++i)
343 if (fabs(
m_alpha[0] - Alpha[min_j]) < min_alph)
346 min_alph = fabs(
m_alpha[0] - Alpha[min_j]);
351 if (fabs(Alpha[min_i] - Alpha[min_j]) > 1e-4)
354 (Alpha[min_i] - Alpha[min_j]) /
355 (WaveForce[min_i] - WaveForce[min_j]);
372 string vEquation =
m_sessionRoll->GetSolverInfo(
"solvertype");
378 cout <<
"Executing Roll solver" << endl;
379 solverRoll->DoInitialise();
380 solverRoll->DoSolve();
381 solverRoll->Output();
383 for (
int g = 0; g < solverRoll->GetNvariables(); ++g)
385 NekDouble vL2Error = solverRoll->L2Error(g,
false);
386 NekDouble vLinfError = solverRoll->LinfError(g);
387 cout <<
"L 2 error (variable " << solverRoll->GetVariable(g)
388 <<
") : " << vL2Error << endl;
389 cout <<
"L inf error (variable " << solverRoll->GetVariable(g)
390 <<
") : " << vLinfError << endl;
397 string vEquation =
m_sessionRoll->GetSolverInfo(
"solvertype");
412 std::dynamic_pointer_cast<SolverUtils::ForcingProgrammatic>(
418 std::vector<std::string> vFieldNames =
420 vFieldNames.erase(vFieldNames.end() - 1);
461 cout <<
"Executing Roll solver" << endl;
469 cout <<
"L 2 error (variable " <<
m_solverRoll->GetVariable(g)
470 <<
") : " << vL2Error << endl;
471 cout <<
"L inf error (variable " <<
m_solverRoll->GetVariable(g)
472 <<
") : " << vLinfError << endl;
477 cout <<
"Executing cp -f session.fld session.rst" << endl;
481 cout <<
"Writing data to session-Base.fld" << endl;
483 std::vector<std::string> variables(2);
486 std::vector<Array<OneD, NekDouble>> outfield(2);
487 outfield[0] =
m_solverRoll->UpdateFields()[0]->UpdateCoeffs();
488 outfield[1] =
m_solverRoll->UpdateFields()[1]->UpdateCoeffs();
498 std::string vDriverModule;
503 solverStreak->Execute();
513 cout <<
"Executing Streak Solver" << endl;
514 solverStreak->DoInitialise();
515 solverStreak->DoSolve();
516 solverStreak->Output();
522 for (
int g = 0; g < solverStreak->GetNvariables(); ++g)
524 NekDouble vL2Error = solverStreak->L2Error(g,
false);
525 NekDouble vLinfError = solverStreak->LinfError(g);
526 cout <<
"L 2 error (variable " << solverStreak->GetVariable(g)
527 <<
") : " << vL2Error << endl;
528 cout <<
"L inf error (variable " << solverStreak->GetVariable(g)
529 <<
") : " << vLinfError << endl;
534 cout <<
"Executing cp -f session.fld session_streak.fld" << endl;
542 std::string LZstr(
"LZ");
544 cout <<
"Setting LZ in Linearised solver to " << LZ << endl;
548 std::string vDriverModule;
549 m_sessionWave->LoadSolverInfo(
"Driver", vDriverModule,
"ModifiedArnoldi");
550 cout <<
"Setting up linearised NS Solver" << endl;
555 cout <<
"Executing wave solution " << endl;
556 solverWave->Execute();
559 cout <<
"Executing cp -f session_eig_0 session_eig_0.rst" << endl;
573 m_sessionWave->MatchSolverInfo(
"Driver",
"ModifiedArnoldi", defineshift,
607 sprintf(c,
"%d", cnt);
608 char c_alpha[16] =
"";
609 sprintf(c_alpha,
"%f",
m_alpha[0]);
611 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
614 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
616 "meshhalf_pos_Spen_stability_moved.fld "
617 "meshhalf_pos_Spen_advPost_moved.fld " +
618 c_alpha +
" > data_alpha0";
619 cout << syscall.c_str() << endl;
620 if (system(syscall.c_str()))
625 syscall =
"cp -f meshhalf_pos_Spen_stability_moved_u_5.bc " +
627 cout << syscall.c_str() << endl;
628 if (system(syscall.c_str()))
632 syscall =
"cp -f meshhalf_pos_Spen_stability_moved_v_5.bc " +
634 cout << syscall.c_str() << endl;
635 if (system(syscall.c_str()))
642 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
643 movedmesh +
" " + wavefile +
" " + filestreak +
" " +
644 c_alpha +
" > datasub_" + c;
645 cout << syscall.c_str() << endl;
646 if (system(syscall.c_str()))
655 string wave_subalp =
m_sessionName +
"_wave_subalp_" + c +
".fld";
656 syscall =
"cp -f " + wavefile +
" " + wave_subalp;
657 cout << syscall.c_str() << endl;
658 if (system(syscall.c_str()))
672 static int projectfield = -1;
683 if (projectfield == -1)
690 for (
int j = 0; j < BndConds.size(); ++j)
692 if (BndConds[j]->GetBoundaryConditionType() ==
699 if (projectfield != -1)
704 if (projectfield == -1)
706 cout <<
"using first field to project non-linear forcing which "
707 "imposes a Dirichlet condition"
737 invnorm = 1.0 / Linf;
751 cout <<
"Area: " << area << endl;
752 invnorm =
sqrt(area / invnorm);
791 std::vector<std::string> variables(3);
792 std::vector<Array<OneD, NekDouble>> outfield(3);
793 variables[0] =
"u_w";
794 variables[1] =
"v_w";
795 variables[2] =
"w_w";
835 Vmath::Vvtvp(npts, u_imag, 1, u_imag, 1, val, 1, val, 1);
841 Vmath::Vvtvp(npts, u_imag, 1, v_imag, 1, val, 1, val, 1);
861 Vmath::Vvtvp(npts, v_imag, 1, v_imag, 1, val, 1, val, 1);
880 m_sessionVWI->MatchSolverInfo(
"Symmetrization",
"True", symm,
true);
903 for(i = 0; i < npts; ++i)
905 coord[0] = coord_x[i];
906 coord[1] = coord_y[i];
914 for(i = 0; i < npts; ++i)
917 coord[0] = coord_x[i];
918 coord[1] = coord_y[i];
919 der2 [i] =
m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
932 for(i = 0; i < npts; ++i)
935 coord[0] = coord_x[i];
936 coord[1] = coord_y[i];
937 der2[i] =
m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
946 m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der2, m_vwiForceing[1]);
953 cout <<
"symmetrization is active" << endl;
958 for (i = 0; i < npts; ++i)
962 val[i] = 0.5 * (der1[i] - der1[index[i]]);
974 for (i = 0; i < npts; ++i)
978 val[i] = 0.5 * (der2[i] - der2[index[i]]);
993 cout <<
"F_Linf: " <<
Vmath::Vmax(npts, val, 1) << endl;
1012 for (
int j = 0; j < 2; ++j)
1017 for (
int i = 0; i < npts; ++i)
1027 std::vector<std::string> variables(4);
1028 std::vector<Array<OneD, NekDouble>> outfield(4);
1031 variables[2] =
"pr";
1032 variables[3] =
"pi";
1051 cout <<
"int P^2: " <<
m_wavePressure->GetPlane(0)->Integral(val)
1054 cout <<
"PLinf: " <<
Vmath::Vmax(npts, val, 1) << endl;
1063 outfield, variables);
1087 cout <<
"int P^2 " <<
m_wavePressure->GetPlane(0)->Integral(val) << endl;
1091 cout <<
"Linf: " << Linf << endl;
1104 l2 =
sqrt(norm / area);
1106 cout <<
"L2: " << l2 << endl;
1108 cout <<
"Ratio Linf/L2: " << Linf / l2 << endl;
1113 static map<string, int> opendir;
1115 if (opendir.find(dir) == opendir.end())
1118 string mkdir =
"mkdir " + dir;
1119 ASSERTL0(system(mkdir.c_str()) == 0,
1120 "Failed to make directory '" + dir +
"'");
1126 dir +
"/" + file +
"." + boost::lexical_cast<std::string>(n);
1127 string syscall =
"cp -f " + file +
" " +
savefile;
1129 ASSERTL0(system(syscall.c_str()) == 0, syscall.c_str());
1134 static map<string, int> opendir;
1136 if (opendir.find(dir) == opendir.end())
1139 string mkdir =
"mkdir " + dir;
1140 ASSERTL0(system(mkdir.c_str()) == 0,
1141 "Failed to make directory '" + dir +
"'");
1146 dir +
"/" + file +
"." + boost::lexical_cast<std::string>(n);
1147 string syscall =
"mv -f " + file +
" " +
savefile;
1149 ASSERTL0(system(syscall.c_str()) == 0, syscall.c_str());
1156 string syscall =
"cp -f " + cpfile1 +
" " + cpfile2;
1158 if (system(syscall.c_str()))
1167 fp = fopen(file.c_str(),
"a");
1168 fprintf(fp,
"%d: %lf %16.12le %16.12le\n", n,
m_alpha[0],
1176 fp = fopen(file.c_str(),
"a");
1177 fprintf(fp,
"%lf %lf %16.12le %16.12le\n", WaveForceMag,
m_alpha[0],
1209 bool skiprollstreak =
false;
1210 if (cnt == 0 &&
m_sessionVWI->GetParameter(
"rollstreakfromit") == 1)
1212 skiprollstreak =
true;
1213 cout <<
"skip roll-streak at the first iteration" << endl;
1216 if (skiprollstreak !=
true)
1238 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1247 sprintf(c,
"%d", cnt);
1250 syscall =
"cp -f " +
m_sessionName +
"-Base.fld" +
" " + oldroll;
1251 cout << syscall.c_str() << endl;
1252 if (system(syscall.c_str()))
1260 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1262 string interpstreak =
m_sessionName +
"_interpstreak_" + c +
".fld";
1263 string interwavepressure =
1265 char alpchar[16] =
"";
1266 cout <<
"alpha = " <<
m_alpha[0] << endl;
1267 sprintf(alpchar,
"%f",
m_alpha[0]);
1269 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") !=
"phase")
1271 cout <<
"zerophase" << endl;
1273 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1274 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1277 cout << syscall.c_str() << endl;
1278 if (system(syscall.c_str()))
1284 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1285 filePost +
" " + filestreak +
" " + filePost +
" " +
1287 cout << syscall.c_str() << endl;
1288 if (system(syscall.c_str()))
1295 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1296 cout << syscall.c_str() << endl;
1297 if (system(syscall.c_str()))
1304 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1308 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1309 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1312 cout << syscall.c_str() << endl;
1313 if (system(syscall.c_str()))
1321 syscall =
"cp -f " + meshfile +
" " + meshold;
1322 cout << syscall.c_str() << endl;
1323 if (system(syscall.c_str()))
1329 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1330 cout << syscall.c_str() << endl;
1331 if (system(syscall.c_str()))
1337 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1338 cout << syscall.c_str() << endl;
1339 if (system(syscall.c_str()))
1349 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1350 cout << syscall.c_str() << endl;
1351 if (system(syscall.c_str()))
1358 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1359 cout << syscall.c_str() << endl;
1360 if (system(syscall.c_str()))
1366 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1367 cout << syscall.c_str() << endl;
1368 if (system(syscall.c_str()))
1383 sprintf(c1,
"%d", cnt);
1386 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1387 movedmesh +
" " + wavefile +
" " + interpstreak +
1389 cout << syscall.c_str() << endl;
1390 if (system(syscall.c_str()))
1396 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1397 cout << syscall.c_str() << endl;
1398 if (system(syscall.c_str()))
1403 syscall =
"cp -f " + movedmesh +
" " + filePost;
1404 cout << syscall.c_str() << endl;
1405 if (system(syscall.c_str()))
1410 else if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1412 cout <<
"phase" << endl;
1423 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1424 cout << syscall.c_str() << endl;
1425 if (system(syscall.c_str()))
1431 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + filewave;
1432 cout << syscall.c_str() << endl;
1433 if (system(syscall.c_str()))
1440 syscall =
"cp -f " + meshfile +
" " + meshold;
1441 cout << syscall.c_str() << endl;
1442 if (system(syscall.c_str()))
1449 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1450 cout << syscall.c_str() << endl;
1451 if (system(syscall.c_str()))
1458 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1459 cout << syscall.c_str() << endl;
1460 if (system(syscall.c_str()))
1466 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1467 cout << syscall.c_str() << endl;
1468 if (system(syscall.c_str()))
1477 cout <<
"cr=" << cr_str << endl;
1480 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1481 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1482 alpchar +
" " + cr_str;
1484 cout << syscall.c_str() << endl;
1485 if (system(syscall.c_str()))
1491 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1492 filePost +
" " + filestreak +
" " + filePost +
" " +
1493 alpchar +
" " + cr_str;
1494 cout << syscall.c_str() << endl;
1495 if (system(syscall.c_str()))
1501 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1502 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1505 cout << syscall.c_str() << endl;
1506 if (system(syscall.c_str()))
1512 syscall =
"../../utilities/PostProcessing/Extras/SplitFld " +
1513 filePost +
" " + filewave;
1515 cout << syscall.c_str() << endl;
1516 if (system(syscall.c_str()))
1521 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1522 filePost +
" " + filewavepressure +
" " + movedmesh +
1523 " " + interwavepressure;
1525 cout << syscall.c_str() << endl;
1526 if (system(syscall.c_str()))
1540 sprintf(c1,
"%d", cnt);
1545 "cp -f " + interwavepressure +
" " +
m_sessionName +
".fld";
1546 cout << syscall.c_str() << endl;
1547 if (system(syscall.c_str()))
1554 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1556 interpstreak +
"> data" + c1;
1557 cout << syscall.c_str() << endl;
1558 if (system(syscall.c_str()))
1564 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1565 cout << syscall.c_str() << endl;
1566 if (system(syscall.c_str()))
1572 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1573 cout << syscall.c_str() << endl;
1574 if (system(syscall.c_str()))
1579 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1580 cout << syscall.c_str() << endl;
1581 if (system(syscall.c_str()))
1586 syscall =
"cp -f " + movedmesh +
" " + filePost;
1587 cout << syscall.c_str() << endl;
1588 if (system(syscall.c_str()))
1615 char alpchar[16] =
"";
1616 sprintf(alpchar,
"%f",
m_alpha[0]);
1621 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1624 string interwavepressure =
1626 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1627 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1630 cout << syscall.c_str() << endl;
1631 if (system(syscall.c_str()))
1637 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1638 filePost +
" " + filestreak +
" " + filePost +
" " +
1640 cout << syscall.c_str() << endl;
1641 if (system(syscall.c_str()))
1648 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1649 cout << syscall.c_str() << endl;
1650 if (system(syscall.c_str()))
1657 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1661 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1662 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1665 cout << syscall.c_str() << endl;
1666 if (system(syscall.c_str()))
1674 syscall =
"cp -f " + meshfile +
" " + meshold;
1675 cout << syscall.c_str() << endl;
1676 if (system(syscall.c_str()))
1682 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1683 cout << syscall.c_str() << endl;
1684 if (system(syscall.c_str()))
1690 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1691 cout << syscall.c_str() << endl;
1692 if (system(syscall.c_str()))
1709 static NekDouble previous_real_evl = -1.0;
1710 static NekDouble previous_imag_evl = -1.0;
1711 static int min_iter = 0;
1715 previous_real_evl = -1.0;
1727 cout <<
"Growth tolerance: "
1731 cout <<
"Phase tolerance: "
1754 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2"
1768 bool returnval =
false;
1771 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1798 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2" << endl;
1836 for (i = 0; i < nstore; ++i)
1840 store = WaveForce[i];
1841 WaveForce[i] = WaveForce[i + k];
1842 WaveForce[i + k] = store;
1845 Growth[i] = Growth[i + k];
1846 Growth[i + k] = store;
1850 for (i = 0; i < nstore - 1; ++i)
1852 if (Growth[i] * Growth[i + 1] < 0.0)
1858 if (i != nstore - 1)
1863 (WaveForce[0] * Growth[1] - WaveForce[1] * Growth[0]) /
1864 (Growth[1] - Growth[0]);
1872 int idx = (i == 0) ? 1 : i;
1873 NekDouble da = WaveForce[idx + 1] - WaveForce[idx - 1];
1874 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1876 (WaveForce[idx - 1] - WaveForce[idx]) /
1877 (WaveForce[idx - 1] - WaveForce[idx + 1]);
1879 (WaveForce[idx] - WaveForce[idx - 1]) /
1880 (WaveForce[idx] - WaveForce[idx + 1]);
1882 (WaveForce[idx + 1] - WaveForce[idx - 1]) /
1883 (WaveForce[idx + 1] - WaveForce[idx]);
1885 for (j = 1; j < nsteps + 1; ++j)
1887 a = WaveForce[i] + j * da / (
NekDouble)nsteps;
1889 c1 * (a - WaveForce[idx]) * (a - WaveForce[idx + 1]) +
1890 c2 * (a - WaveForce[idx - 1]) *
1891 (a - WaveForce[idx + 1]) +
1892 c3 * (a - WaveForce[idx - 1]) * (a - WaveForce[idx]);
1894 if (gval * gval_m1 < 0.0)
1896 wavef_new = ((a + da / (
NekDouble)nsteps) * gval -
1906 if (Growth[i] > 0.0)
1951 int nstore = (
m_alpha.size() < outeriter) ?
m_alpha.size() : outeriter;
1961 for (i = 0; i < nstore; ++i)
1966 Alpha[i] = Alpha[i + k];
1967 Alpha[i + k] = store;
1970 Growth[i] = Growth[i + k];
1971 Growth[i + k] = store;
1975 for (i = 0; i < nstore - 1; ++i)
1977 if (Growth[i] * Growth[i + 1] < 0.0)
1983 if (i != nstore - 1)
1987 alp_new = (Alpha[0] * Growth[1] - Alpha[1] * Growth[0]) /
1988 (Growth[1] - Growth[0]);
1996 int idx = (i == 0) ? 1 : i;
1997 NekDouble da = Alpha[idx + 1] - Alpha[idx - 1];
1998 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1999 NekDouble c1 = Growth[idx - 1] / (Alpha[idx - 1] - Alpha[idx]) /
2000 (Alpha[idx - 1] - Alpha[idx + 1]);
2001 NekDouble c2 = Growth[idx] / (Alpha[idx] - Alpha[idx - 1]) /
2002 (Alpha[idx] - Alpha[idx + 1]);
2004 (Alpha[idx + 1] - Alpha[idx - 1]) /
2005 (Alpha[idx + 1] - Alpha[idx]);
2007 for (j = 1; j < nsteps + 1; ++j)
2009 a = Alpha[i] + j * da / (
NekDouble)nsteps;
2010 gval = c1 * (a - Alpha[idx]) * (a - Alpha[idx + 1]) +
2011 c2 * (a - Alpha[idx - 1]) * (a - Alpha[idx + 1]) +
2012 c3 * (a - Alpha[idx - 1]) * (a - Alpha[idx]);
2014 if (gval * gval_m1 < 0.0)
2016 alp_new = ((a + da / (
NekDouble)nsteps) * gval -
2026 if (Growth[i] > 0.0)
2037 for (
int i =
m_alpha.size() - 1; i > 0; --i)
2066 int start = npts - 1;
2069 bool useOnlyQuads =
false;
2070 if (
m_sessionVWI->DefinesSolverInfo(
"SymmetriseOnlyQuads"))
2072 useOnlyQuads =
true;
2076 for (
int e = 0; e < nel; ++e)
2086 for (i = 0; i < e_npts; ++i)
2088 index[cnt + i] = -1;
2094 for (i = cnt; i < cnt + e_npts; ++i)
2096 xnew = -coord_x[i] + xmax;
2099 for (j = start; j >= 0; --j)
2101 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2102 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2114 for (j = npts - 1; j > start; --j)
2117 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2118 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2125 ASSERTL0(j != start,
"Failed to find matching point");
2134 cout <<
"relaxation..." << endl;
2141 *std::static_pointer_cast<MultiRegions::ExpList>(Iexp[reg]));
2142 int nq = Ilayer->GetTotPoints();
2147 for (
int i = 1; i < 4; ++i)
2155 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_u;
2156 std::vector<std::vector<NekDouble>> FieldData_u;
2162 fld->Import(file, FieldDef_u, FieldData_u);
2163 Ilayer->ExtractDataToCoeffs(FieldDef_u[0], FieldData_u[0],
2164 FieldDef_u[0]->m_fields[0],
2165 Ilayer->UpdateCoeffs());
2166 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2186 1, Ilayer->UpdatePhys(), 1);
2190 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2191 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2192 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef1 =
2193 Ilayer->GetFieldDefinitions();
2194 std::vector<std::vector<NekDouble>> FieldData_1(FieldDef1.size());
2196 FieldDef1[0]->m_fields.push_back(
"u");
2197 Ilayer->AppendFieldData(FieldDef1[0], FieldData_1[0]);
2198 fld->Write(file, FieldDef1, FieldData_1);
2214 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_v;
2215 std::vector<std::vector<NekDouble>> FieldData_v;
2216 fld->Import(file, FieldDef_v, FieldData_v);
2217 Ilayer->ExtractDataToCoeffs(FieldDef_v[0], FieldData_v[0],
2218 FieldDef_v[0]->m_fields[0],
2219 Ilayer->UpdateCoeffs());
2220 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2235 1, Ilayer->UpdatePhys(), 1);
2238 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2239 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2240 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef2 =
2241 Ilayer->GetFieldDefinitions();
2242 std::vector<std::vector<NekDouble>> FieldData_2(FieldDef2.size());
2244 FieldDef2[0]->m_fields.push_back(
"v");
2245 Ilayer->AppendFieldData(FieldDef2[0], FieldData_2[0]);
2246 fld->Write(file, FieldDef2, FieldData_2);
#define ASSERTL0(condition, msg)
This class is the base class for Navier Stokes problems.
void AddForcing(const SolverUtils::ForcingSharedPtr &pForce)
static std::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Describe a linear system.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true)
Array< OneD, MultiRegions::ExpListSharedPtr > m_streakField
bool m_useLinfPressureNorm
bool m_moveMeshToCriticalLayer
~VortexWaveInteraction(void)
Array< OneD, Array< OneD, NekDouble > > m_vwiForcing
bool CheckEigIsStationary(bool reset=false)
void FileRelaxation(int reg)
LibUtilities::SessionReaderSharedPtr m_sessionVWI
NekDouble m_dAlphaDWaveForceMag
LibUtilities::SessionReaderSharedPtr m_sessionRoll
NekDouble m_waveForceMagStep
Array< OneD, NekDouble > m_alpha
< Leading imaginary eigenvalue
LibUtilities::SessionReaderSharedPtr m_sessionStreak
void SaveFile(std::string fileend, std::string dir, int n)
void CopyFile(std::string file1end, std::string file2end)
NekDouble m_rollForceScale
Array< OneD, int > GetReflectionIndex(void)
NekDouble m_deltaFcnDecay
int m_maxWaveForceMagIter
void SaveLoopDetails(std::string dir, int i)
NekDouble m_vwiRelaxation
VWIIterationType m_VWIIterationType
bool CheckIfAtNeutralPoint(void)
SolverUtils::ForcingProgrammaticSharedPtr m_vwiForcingObj
Array< OneD, MultiRegions::ExpListSharedPtr > m_waveVelocities
void CalcL2ToLinfPressure(void)
void ExecuteLoop(bool CalcWaveForce=true)
SpatialDomains::MeshGraphSharedPtr m_graphStreak
void CalcNonLinearWaveForce(void)
Array< OneD, Array< OneD, NekDouble > > m_bcsForcing
SpatialDomains::MeshGraphSharedPtr m_graphRoll
Array< OneD, MultiRegions::ExpListSharedPtr > m_rollField
void MoveFile(std::string fileend, std::string dir, int n)
SpatialDomains::MeshGraphSharedPtr m_graphWave
Array< OneD, NekDouble > m_waveForceMag
void AppendEvlToFile(std::string file, int n)
LibUtilities::SessionReaderSharedPtr m_sessionWave
void UpdateDAlphaDWaveForceMag(NekDouble alphainit)
MultiRegions::ExpListSharedPtr m_wavePressure
NekDouble m_neutralPointTol
Array< OneD, NekDouble > m_leading_real_evl
std::string m_sessionName
void UpdateWaveForceMag(int n)
Array< OneD, NekDouble > m_leading_imag_evl
< Leading real eigenvalue
VWIIterationType GetVWIIterationType(void)
EquationSystemSharedPtr m_solverRoll
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
DriverFactory & GetDriverFactory()
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
EquationSystemFactory & GetEquationSystemFactory()
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
The above copyright notice and this permission notice shall be included.
std::shared_ptr< IncNavierStokes > IncNavierStokesSharedPtr
const std::string VWIIterationTypeMap[]
@ eFixedWaveForcingWithSubIterationOnAlpha
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 Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*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.
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha - x.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
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 > log(scalarT< T > in)
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)