48 : m_nOuterIterations(0)
58 std::string VWICondFile(argv[argc - 1]);
59 VWICondFile +=
"_VWI.xml";
60 std::vector<std::string> VWIFilenames;
61 VWIFilenames.push_back(meshfile);
62 VWIFilenames.push_back(VWICondFile);
70 m_sessionVWI->LoadParameter(
"OuterIterationStoreSize", storesize, 10);
102 if (
m_sessionVWI->DefinesSolverInfo(
"LinfPressureNorm"))
120 if (
m_sessionVWI->DefinesSolverInfo(
"MoveMeshToCriticalLayer"))
152 std::string IncCondFile(argv[argc - 1]);
153 IncCondFile +=
"_IncNSCond.xml";
154 std::vector<std::string> IncNSFilenames;
155 IncNSFilenames.push_back(meshfile);
156 IncNSFilenames.push_back(IncCondFile);
162 std::string vEquation =
m_sessionRoll->GetSolverInfo(
"SolverType");
172 int ncoeffs =
m_solverRoll->UpdateFields()[0]->GetNcoeffs();
175 for (
int i = 1; i < 4; ++i)
186 std::string AdvDiffCondFile(argv[argc - 1]);
187 AdvDiffCondFile +=
"_AdvDiffCond.xml";
188 std::vector<std::string> AdvDiffFilenames;
189 AdvDiffFilenames.push_back(meshfile);
190 AdvDiffFilenames.push_back(AdvDiffCondFile);
198 std::string LinNSCondFile(argv[argc - 1]);
199 LinNSCondFile +=
"_LinNSCond.xml";
200 std::vector<std::string> LinNSFilenames;
201 LinNSFilenames.push_back(meshfile);
202 LinNSFilenames.push_back(LinNSCondFile);
210 std::string LZstr(
"LZ");
212 cout <<
"Setting LZ in Linearised solver to " << LZ << endl;
216 if (
m_sessionVWI->DefinesSolverInfo(
"VWIIterationType"))
218 std::string IterationTypeStr =
236 m_sessionVWI->MatchSolverInfo(
"RestartIteration",
"True", restart,
false);
247 if ((fp = fopen(
"OuterIter.his",
"r")))
250 std::vector<NekDouble> Alpha, Growth, Phase;
252 while (fgets(buf, BUFSIZ, fp))
254 sscanf(buf,
"%*d:%lf%lf%lf", &alpha, &growth, &phase);
255 Alpha.push_back(alpha);
256 Growth.push_back(growth);
257 Phase.push_back(phase);
265 for (
int i = 0; i < nvals; ++i)
279 cout <<
" No File OuterIter.his to restart from" << endl;
286 cout <<
"Restarting from iteration " <<
m_iterStart << endl;
287 std::string rstfile =
"cp -f Save/" +
m_sessionName +
".rst." +
289 cout <<
" " << rstfile << endl;
290 if (system(rstfile.c_str()))
294 std::string vwifile =
"cp -f Save/" +
m_sessionName +
".vwi." +
296 cout <<
" " << vwifile << endl;
297 if (system(vwifile.c_str()))
304 ASSERTL0(
false,
"Unknown VWIITerationType in restart");
311 if ((fp = fopen(
"ConvergedSolns",
"r")))
314 std::vector<NekDouble> WaveForce, Alpha;
316 while (fgets(buf, BUFSIZ, fp))
318 sscanf(buf,
"%*d:%lf%lf", &waveforce, &alpha);
319 WaveForce.push_back(waveforce);
320 Alpha.push_back(alpha);
323 if (Alpha.size() > 1)
328 for (
int i = 1; i < Alpha.size(); ++i)
330 if (fabs(
m_alpha[0] - Alpha[min_i]) < min_alph)
333 min_alph = fabs(
m_alpha[0] - Alpha[min_i]);
338 int min_j = (min_i == 0) ? 1 : 0;
339 min_alph = fabs(
m_alpha[0] - Alpha[min_j]);
340 for (
int i = 0; i < Alpha.size(); ++i)
344 if (fabs(
m_alpha[0] - Alpha[min_j]) < min_alph)
347 min_alph = fabs(
m_alpha[0] - Alpha[min_j]);
352 if (fabs(Alpha[min_i] - Alpha[min_j]) > 1e-4)
355 (Alpha[min_i] - Alpha[min_j]) /
356 (WaveForce[min_i] - WaveForce[min_j]);
373 string vEquation =
m_sessionRoll->GetSolverInfo(
"solvertype");
379 cout <<
"Executing Roll solver" << endl;
380 solverRoll->DoInitialise();
381 solverRoll->DoSolve();
382 solverRoll->Output();
384 for (
int g = 0; g < solverRoll->GetNvariables(); ++g)
386 NekDouble vL2Error = solverRoll->L2Error(g,
false);
387 NekDouble vLinfError = solverRoll->LinfError(g);
388 cout <<
"L 2 error (variable " << solverRoll->GetVariable(g)
389 <<
") : " << vL2Error << endl;
390 cout <<
"L inf error (variable " << solverRoll->GetVariable(g)
391 <<
") : " << vLinfError << endl;
398 string vEquation =
m_sessionRoll->GetSolverInfo(
"solvertype");
413 std::dynamic_pointer_cast<SolverUtils::ForcingProgrammatic>(
419 std::vector<std::string> vFieldNames =
421 vFieldNames.erase(vFieldNames.end() - 1);
462 cout <<
"Executing Roll solver" << endl;
470 cout <<
"L 2 error (variable " <<
m_solverRoll->GetVariable(g)
471 <<
") : " << vL2Error << endl;
472 cout <<
"L inf error (variable " <<
m_solverRoll->GetVariable(g)
473 <<
") : " << vLinfError << endl;
478 cout <<
"Executing cp -f session.fld session.rst" << endl;
482 cout <<
"Writing data to session-Base.fld" << endl;
484 std::vector<std::string> variables(2);
487 std::vector<Array<OneD, NekDouble>> outfield(2);
488 outfield[0] =
m_solverRoll->UpdateFields()[0]->UpdateCoeffs();
489 outfield[1] =
m_solverRoll->UpdateFields()[1]->UpdateCoeffs();
499 std::string vDriverModule;
504 solverStreak->Execute();
514 cout <<
"Executing Streak Solver" << endl;
515 solverStreak->DoInitialise();
516 solverStreak->DoSolve();
517 solverStreak->Output();
523 for (
int g = 0; g < solverStreak->GetNvariables(); ++g)
525 NekDouble vL2Error = solverStreak->L2Error(g,
false);
526 NekDouble vLinfError = solverStreak->LinfError(g);
527 cout <<
"L 2 error (variable " << solverStreak->GetVariable(g)
528 <<
") : " << vL2Error << endl;
529 cout <<
"L inf error (variable " << solverStreak->GetVariable(g)
530 <<
") : " << vLinfError << endl;
535 cout <<
"Executing cp -f session.fld session_streak.fld" << endl;
543 std::string LZstr(
"LZ");
545 cout <<
"Setting LZ in Linearised solver to " << LZ << endl;
549 std::string vDriverModule;
550 m_sessionWave->LoadSolverInfo(
"Driver", vDriverModule,
"ModifiedArnoldi");
551 cout <<
"Setting up linearised NS Solver" << endl;
552 std::shared_ptr<DriverArnoldi> solverWave =
553 std::dynamic_pointer_cast<SolverUtils::DriverArnoldi>(
558 cout <<
"Executing wave solution " << endl;
559 solverWave->Execute();
562 cout <<
"Executing cp -f session_eig_0 session_eig_0.rst" << endl;
576 m_sessionWave->MatchSolverInfo(
"Driver",
"ModifiedArnoldi", defineshift,
610 string c = std::to_string(cnt);
611 string c_alpha = std::to_string(
m_alpha[0]);
612 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
615 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
617 "meshhalf_pos_Spen_stability_moved.fld "
618 "meshhalf_pos_Spen_advPost_moved.fld " +
619 c_alpha +
" > data_alpha0";
620 cout << syscall.c_str() << endl;
621 if (system(syscall.c_str()))
626 syscall =
"cp -f meshhalf_pos_Spen_stability_moved_u_5.bc " +
628 cout << syscall.c_str() << endl;
629 if (system(syscall.c_str()))
633 syscall =
"cp -f meshhalf_pos_Spen_stability_moved_v_5.bc " +
635 cout << syscall.c_str() << endl;
636 if (system(syscall.c_str()))
643 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
644 movedmesh +
" " + wavefile +
" " + filestreak +
" " +
645 c_alpha +
" > datasub_" + c;
646 cout << syscall.c_str() << endl;
647 if (system(syscall.c_str()))
656 string wave_subalp =
m_sessionName +
"_wave_subalp_" + c +
".fld";
657 syscall =
"cp -f " + wavefile +
" " + wave_subalp;
658 cout << syscall.c_str() << endl;
659 if (system(syscall.c_str()))
673 static int projectfield = -1;
684 if (projectfield == -1)
691 for (
int j = 0; j < BndConds.size(); ++j)
693 if (BndConds[j]->GetBoundaryConditionType() ==
700 if (projectfield != -1)
705 if (projectfield == -1)
707 cout <<
"using first field to project non-linear forcing which "
708 "imposes a Dirichlet condition"
738 invnorm = 1.0 / Linf;
752 cout <<
"Area: " << area << endl;
753 invnorm =
sqrt(area / invnorm);
792 std::vector<std::string> variables(3);
793 std::vector<Array<OneD, NekDouble>> outfield(3);
794 variables[0] =
"u_w";
795 variables[1] =
"v_w";
796 variables[2] =
"w_w";
836 Vmath::Vvtvp(npts, u_imag, 1, u_imag, 1, val, 1, val, 1);
842 Vmath::Vvtvp(npts, u_imag, 1, v_imag, 1, val, 1, val, 1);
862 Vmath::Vvtvp(npts, v_imag, 1, v_imag, 1, val, 1, val, 1);
881 m_sessionVWI->MatchSolverInfo(
"Symmetrization",
"True", symm,
true);
904 for(i = 0; i < npts; ++i)
906 coord[0] = coord_x[i];
907 coord[1] = coord_y[i];
915 for(i = 0; i < npts; ++i)
918 coord[0] = coord_x[i];
919 coord[1] = coord_y[i];
920 der2 [i] =
m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
933 for(i = 0; i < npts; ++i)
936 coord[0] = coord_x[i];
937 coord[1] = coord_y[i];
938 der2[i] =
m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
947 m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der2, m_vwiForceing[1]);
954 cout <<
"symmetrization is active" << endl;
959 for (i = 0; i < npts; ++i)
963 val[i] = 0.5 * (der1[i] - der1[index[i]]);
975 for (i = 0; i < npts; ++i)
979 val[i] = 0.5 * (der2[i] - der2[index[i]]);
994 cout <<
"F_Linf: " <<
Vmath::Vmax(npts, val, 1) << endl;
1013 for (
int j = 0; j < 2; ++j)
1018 for (
int i = 0; i < npts; ++i)
1028 std::vector<std::string> variables(4);
1029 std::vector<Array<OneD, NekDouble>> outfield(4);
1032 variables[2] =
"pr";
1033 variables[3] =
"pi";
1052 cout <<
"int P^2: " <<
m_wavePressure->GetPlane(0)->Integral(val)
1055 cout <<
"PLinf: " <<
Vmath::Vmax(npts, val, 1) << endl;
1064 outfield, variables);
1088 cout <<
"int P^2 " <<
m_wavePressure->GetPlane(0)->Integral(val) << endl;
1092 cout <<
"Linf: " << Linf << endl;
1105 l2 =
sqrt(norm / area);
1107 cout <<
"L2: " << l2 << endl;
1109 cout <<
"Ratio Linf/L2: " << Linf / l2 << endl;
1114 static map<string, int> opendir;
1116 if (opendir.find(dir) == opendir.end())
1119 string mkdir =
"mkdir " + dir;
1120 ASSERTL0(system(mkdir.c_str()) == 0,
1121 "Failed to make directory '" + dir +
"'");
1126 string savefile = dir +
"/" + file +
"." + std::to_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 +
"'");
1145 string savefile = dir +
"/" + file +
"." + std::to_string(n);
1146 string syscall =
"mv -f " + file +
" " +
savefile;
1148 ASSERTL0(system(syscall.c_str()) == 0, syscall.c_str());
1155 string syscall =
"cp -f " + cpfile1 +
" " + cpfile2;
1157 if (system(syscall.c_str()))
1166 fp = fopen(file.c_str(),
"a");
1167 fprintf(fp,
"%d: %lf %16.12le %16.12le\n", n,
m_alpha[0],
1175 fp = fopen(file.c_str(),
"a");
1176 fprintf(fp,
"%lf %lf %16.12le %16.12le\n", WaveForceMag,
m_alpha[0],
1208 bool skiprollstreak =
false;
1209 if (cnt == 0 &&
m_sessionVWI->GetParameter(
"rollstreakfromit") == 1)
1211 skiprollstreak =
true;
1212 cout <<
"skip roll-streak at the first iteration" << endl;
1215 if (skiprollstreak !=
true)
1236 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1245 string c = std::to_string(cnt);
1249 syscall =
"cp -f " +
m_sessionName +
"-Base.fld" +
" " + oldroll;
1250 cout << syscall.c_str() << endl;
1251 if (system(syscall.c_str()))
1259 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1261 string interpstreak =
m_sessionName +
"_interpstreak_" + c +
".fld";
1262 string interwavepressure =
1264 string c_alpha = std::to_string(
m_alpha[0]);
1265 cout <<
"alpha = " <<
m_alpha[0] << endl;
1267 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") !=
"phase")
1269 cout <<
"zerophase" << endl;
1271 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1272 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1275 cout << syscall.c_str() << endl;
1276 if (system(syscall.c_str()))
1282 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1283 filePost +
" " + filestreak +
" " + filePost +
" " +
1285 cout << syscall.c_str() << endl;
1286 if (system(syscall.c_str()))
1293 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1294 cout << syscall.c_str() << endl;
1295 if (system(syscall.c_str()))
1302 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1306 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1307 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1310 cout << syscall.c_str() << endl;
1311 if (system(syscall.c_str()))
1319 syscall =
"cp -f " + meshfile +
" " + meshold;
1320 cout << syscall.c_str() << endl;
1321 if (system(syscall.c_str()))
1327 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1328 cout << syscall.c_str() << endl;
1329 if (system(syscall.c_str()))
1335 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1336 cout << syscall.c_str() << endl;
1337 if (system(syscall.c_str()))
1347 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1348 cout << syscall.c_str() << endl;
1349 if (system(syscall.c_str()))
1356 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1357 cout << syscall.c_str() << endl;
1358 if (system(syscall.c_str()))
1364 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1365 cout << syscall.c_str() << endl;
1366 if (system(syscall.c_str()))
1371 c = std::to_string(cnt);
1383 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1384 movedmesh +
" " + wavefile +
" " + interpstreak +
1386 cout << syscall.c_str() << endl;
1387 if (system(syscall.c_str()))
1393 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1394 cout << syscall.c_str() << endl;
1395 if (system(syscall.c_str()))
1400 syscall =
"cp -f " + movedmesh +
" " + filePost;
1401 cout << syscall.c_str() << endl;
1402 if (system(syscall.c_str()))
1407 else if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1409 cout <<
"phase" << endl;
1420 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1421 cout << syscall.c_str() << endl;
1422 if (system(syscall.c_str()))
1428 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + filewave;
1429 cout << syscall.c_str() << endl;
1430 if (system(syscall.c_str()))
1437 syscall =
"cp -f " + meshfile +
" " + meshold;
1438 cout << syscall.c_str() << endl;
1439 if (system(syscall.c_str()))
1446 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1447 cout << syscall.c_str() << endl;
1448 if (system(syscall.c_str()))
1455 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1456 cout << syscall.c_str() << endl;
1457 if (system(syscall.c_str()))
1463 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1464 cout << syscall.c_str() << endl;
1465 if (system(syscall.c_str()))
1474 cout <<
"cr=" << cr_str << endl;
1477 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1478 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1479 c_alpha +
" " + cr_str;
1481 cout << syscall.c_str() << endl;
1482 if (system(syscall.c_str()))
1488 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1489 filePost +
" " + filestreak +
" " + filePost +
" " +
1490 c_alpha +
" " + cr_str;
1491 cout << syscall.c_str() << endl;
1492 if (system(syscall.c_str()))
1498 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1499 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1502 cout << syscall.c_str() << endl;
1503 if (system(syscall.c_str()))
1509 syscall =
"../../utilities/PostProcessing/Extras/SplitFld " +
1510 filePost +
" " + filewave;
1512 cout << syscall.c_str() << endl;
1513 if (system(syscall.c_str()))
1518 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1519 filePost +
" " + filewavepressure +
" " + movedmesh +
1520 " " + interwavepressure;
1522 cout << syscall.c_str() << endl;
1523 if (system(syscall.c_str()))
1540 "cp -f " + interwavepressure +
" " +
m_sessionName +
".fld";
1541 cout << syscall.c_str() << endl;
1542 if (system(syscall.c_str()))
1549 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1551 interpstreak +
"> data" + c;
1552 cout << syscall.c_str() << endl;
1553 if (system(syscall.c_str()))
1559 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1560 cout << syscall.c_str() << endl;
1561 if (system(syscall.c_str()))
1567 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1568 cout << syscall.c_str() << endl;
1569 if (system(syscall.c_str()))
1574 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1575 cout << syscall.c_str() << endl;
1576 if (system(syscall.c_str()))
1581 syscall =
"cp -f " + movedmesh +
" " + filePost;
1582 cout << syscall.c_str() << endl;
1583 if (system(syscall.c_str()))
1610 char alpchar[16] =
"";
1611 snprintf(alpchar, 16,
"%f",
m_alpha[0]);
1616 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1619 string interwavepressure =
1621 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1622 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1625 cout << syscall.c_str() << endl;
1626 if (system(syscall.c_str()))
1632 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1633 filePost +
" " + filestreak +
" " + filePost +
" " +
1635 cout << syscall.c_str() << endl;
1636 if (system(syscall.c_str()))
1643 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1644 cout << syscall.c_str() << endl;
1645 if (system(syscall.c_str()))
1652 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1656 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1657 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1660 cout << syscall.c_str() << endl;
1661 if (system(syscall.c_str()))
1669 syscall =
"cp -f " + meshfile +
" " + meshold;
1670 cout << syscall.c_str() << endl;
1671 if (system(syscall.c_str()))
1677 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1678 cout << syscall.c_str() << endl;
1679 if (system(syscall.c_str()))
1685 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1686 cout << syscall.c_str() << endl;
1687 if (system(syscall.c_str()))
1704 static NekDouble previous_real_evl = -1.0;
1705 static NekDouble previous_imag_evl = -1.0;
1706 static int min_iter = 0;
1710 previous_real_evl = -1.0;
1722 cout <<
"Growth tolerance: "
1726 cout <<
"Phase tolerance: "
1749 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2"
1763 bool returnval =
false;
1766 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1793 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2" << endl;
1831 for (i = 0; i < nstore; ++i)
1835 store = WaveForce[i];
1836 WaveForce[i] = WaveForce[i + k];
1837 WaveForce[i + k] = store;
1840 Growth[i] = Growth[i + k];
1841 Growth[i + k] = store;
1845 for (i = 0; i < nstore - 1; ++i)
1847 if (Growth[i] * Growth[i + 1] < 0.0)
1853 if (i != nstore - 1)
1858 (WaveForce[0] * Growth[1] - WaveForce[1] * Growth[0]) /
1859 (Growth[1] - Growth[0]);
1867 int idx = (i == 0) ? 1 : i;
1868 NekDouble da = WaveForce[idx + 1] - WaveForce[idx - 1];
1869 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1871 (WaveForce[idx - 1] - WaveForce[idx]) /
1872 (WaveForce[idx - 1] - WaveForce[idx + 1]);
1874 (WaveForce[idx] - WaveForce[idx - 1]) /
1875 (WaveForce[idx] - WaveForce[idx + 1]);
1877 (WaveForce[idx + 1] - WaveForce[idx - 1]) /
1878 (WaveForce[idx + 1] - WaveForce[idx]);
1880 for (j = 1; j < nsteps + 1; ++j)
1882 a = WaveForce[i] + j * da / (
NekDouble)nsteps;
1884 c1 * (a - WaveForce[idx]) * (a - WaveForce[idx + 1]) +
1885 c2 * (a - WaveForce[idx - 1]) *
1886 (a - WaveForce[idx + 1]) +
1887 c3 * (a - WaveForce[idx - 1]) * (a - WaveForce[idx]);
1889 if (gval * gval_m1 < 0.0)
1891 wavef_new = ((a + da / (
NekDouble)nsteps) * gval -
1901 if (Growth[i] > 0.0)
1946 int nstore = (
m_alpha.size() < outeriter) ?
m_alpha.size() : outeriter;
1956 for (i = 0; i < nstore; ++i)
1961 Alpha[i] = Alpha[i + k];
1962 Alpha[i + k] = store;
1965 Growth[i] = Growth[i + k];
1966 Growth[i + k] = store;
1970 for (i = 0; i < nstore - 1; ++i)
1972 if (Growth[i] * Growth[i + 1] < 0.0)
1978 if (i != nstore - 1)
1982 alp_new = (Alpha[0] * Growth[1] - Alpha[1] * Growth[0]) /
1983 (Growth[1] - Growth[0]);
1991 int idx = (i == 0) ? 1 : i;
1992 NekDouble da = Alpha[idx + 1] - Alpha[idx - 1];
1993 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1994 NekDouble c1 = Growth[idx - 1] / (Alpha[idx - 1] - Alpha[idx]) /
1995 (Alpha[idx - 1] - Alpha[idx + 1]);
1996 NekDouble c2 = Growth[idx] / (Alpha[idx] - Alpha[idx - 1]) /
1997 (Alpha[idx] - Alpha[idx + 1]);
1999 (Alpha[idx + 1] - Alpha[idx - 1]) /
2000 (Alpha[idx + 1] - Alpha[idx]);
2002 for (j = 1; j < nsteps + 1; ++j)
2004 a = Alpha[i] + j * da / (
NekDouble)nsteps;
2005 gval = c1 * (a - Alpha[idx]) * (a - Alpha[idx + 1]) +
2006 c2 * (a - Alpha[idx - 1]) * (a - Alpha[idx + 1]) +
2007 c3 * (a - Alpha[idx - 1]) * (a - Alpha[idx]);
2009 if (gval * gval_m1 < 0.0)
2011 alp_new = ((a + da / (
NekDouble)nsteps) * gval -
2021 if (Growth[i] > 0.0)
2032 for (
int i =
m_alpha.size() - 1; i > 0; --i)
2059 int start = npts - 1;
2062 bool useOnlyQuads =
false;
2063 if (
m_sessionVWI->DefinesSolverInfo(
"SymmetriseOnlyQuads"))
2065 useOnlyQuads =
true;
2069 for (
int e = 0; e < nel; ++e)
2079 for (i = 0; i < e_npts; ++i)
2081 index[cnt + i] = -1;
2087 for (i = cnt; i < cnt + e_npts; ++i)
2089 xnew = -coord_x[i] + xmax;
2092 for (j = start; j >= 0; --j)
2094 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2095 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2107 for (j = npts - 1; j > start; --j)
2110 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2111 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2118 ASSERTL0(j != start,
"Failed to find matching point");
2127 cout <<
"relaxation..." << endl;
2134 *std::static_pointer_cast<MultiRegions::ExpList>(Iexp[reg]));
2135 int nq = Ilayer->GetTotPoints();
2140 for (
int i = 1; i < 4; ++i)
2148 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_u;
2149 std::vector<std::vector<NekDouble>> FieldData_u;
2155 fld->Import(file, FieldDef_u, FieldData_u);
2156 Ilayer->ExtractDataToCoeffs(FieldDef_u[0], FieldData_u[0],
2157 FieldDef_u[0]->m_fields[0],
2158 Ilayer->UpdateCoeffs());
2159 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2179 1, Ilayer->UpdatePhys(), 1);
2183 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2184 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2185 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef1 =
2186 Ilayer->GetFieldDefinitions();
2187 std::vector<std::vector<NekDouble>> FieldData_1(FieldDef1.size());
2189 FieldDef1[0]->m_fields.push_back(
"u");
2190 Ilayer->AppendFieldData(FieldDef1[0], FieldData_1[0]);
2191 fld->Write(file, FieldDef1, FieldData_1);
2207 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_v;
2208 std::vector<std::vector<NekDouble>> FieldData_v;
2209 fld->Import(file, FieldDef_v, FieldData_v);
2210 Ilayer->ExtractDataToCoeffs(FieldDef_v[0], FieldData_v[0],
2211 FieldDef_v[0]->m_fields[0],
2212 Ilayer->UpdateCoeffs());
2213 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2228 1, Ilayer->UpdatePhys(), 1);
2231 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2232 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2233 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef2 =
2234 Ilayer->GetFieldDefinitions();
2235 std::vector<std::vector<NekDouble>> FieldData_2(FieldDef2.size());
2237 FieldDef2[0]->m_fields.push_back(
"v");
2238 Ilayer->AppendFieldData(FieldDef2[0], FieldData_2[0]);
2239 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, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
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
VortexWaveInteraction(int argc, char *argv[])
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.
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 > abs(scalarT< T > in)
scalarT< T > log(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)