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;
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;
551 std::shared_ptr<DriverArnoldi> solverWave =
552 std::dynamic_pointer_cast<SolverUtils::DriverArnoldi>(
557 cout <<
"Executing wave solution " << endl;
558 solverWave->Execute();
561 cout <<
"Executing cp -f session_eig_0 session_eig_0.rst" << endl;
575 m_sessionWave->MatchSolverInfo(
"Driver",
"ModifiedArnoldi", defineshift,
609 string c = std::to_string(cnt);
610 string c_alpha = std::to_string(
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 +
"'");
1125 string savefile = dir +
"/" + file +
"." + std::to_string(n);
1126 string syscall =
"cp -f " + file +
" " +
savefile;
1128 ASSERTL0(system(syscall.c_str()) == 0, syscall.c_str());
1133 static map<string, int> opendir;
1135 if (opendir.find(dir) == opendir.end())
1138 string mkdir =
"mkdir " + dir;
1139 ASSERTL0(system(mkdir.c_str()) == 0,
1140 "Failed to make directory '" + dir +
"'");
1144 string savefile = dir +
"/" + file +
"." + std::to_string(n);
1145 string syscall =
"mv -f " + file +
" " +
savefile;
1147 ASSERTL0(system(syscall.c_str()) == 0, syscall.c_str());
1154 string syscall =
"cp -f " + cpfile1 +
" " + cpfile2;
1156 if (system(syscall.c_str()))
1165 fp = fopen(file.c_str(),
"a");
1166 fprintf(fp,
"%d: %lf %16.12le %16.12le\n", n,
m_alpha[0],
1174 fp = fopen(file.c_str(),
"a");
1175 fprintf(fp,
"%lf %lf %16.12le %16.12le\n", WaveForceMag,
m_alpha[0],
1207 bool skiprollstreak =
false;
1208 if (cnt == 0 &&
m_sessionVWI->GetParameter(
"rollstreakfromit") == 1)
1210 skiprollstreak =
true;
1211 cout <<
"skip roll-streak at the first iteration" << endl;
1214 if (skiprollstreak !=
true)
1235 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1244 string c = std::to_string(cnt);
1248 syscall =
"cp -f " +
m_sessionName +
"-Base.fld" +
" " + oldroll;
1249 cout << syscall.c_str() << endl;
1250 if (system(syscall.c_str()))
1258 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1260 string interpstreak =
m_sessionName +
"_interpstreak_" + c +
".fld";
1261 string interwavepressure =
1263 string c_alpha = std::to_string(
m_alpha[0]);
1264 cout <<
"alpha = " <<
m_alpha[0] << endl;
1266 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") !=
"phase")
1268 cout <<
"zerophase" << endl;
1270 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1271 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1274 cout << syscall.c_str() << endl;
1275 if (system(syscall.c_str()))
1281 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1282 filePost +
" " + filestreak +
" " + filePost +
" " +
1284 cout << syscall.c_str() << endl;
1285 if (system(syscall.c_str()))
1292 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1293 cout << syscall.c_str() << endl;
1294 if (system(syscall.c_str()))
1301 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1305 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1306 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1309 cout << syscall.c_str() << endl;
1310 if (system(syscall.c_str()))
1318 syscall =
"cp -f " + meshfile +
" " + meshold;
1319 cout << syscall.c_str() << endl;
1320 if (system(syscall.c_str()))
1326 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1327 cout << syscall.c_str() << endl;
1328 if (system(syscall.c_str()))
1334 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1335 cout << syscall.c_str() << endl;
1336 if (system(syscall.c_str()))
1346 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1347 cout << syscall.c_str() << endl;
1348 if (system(syscall.c_str()))
1355 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1356 cout << syscall.c_str() << endl;
1357 if (system(syscall.c_str()))
1363 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1364 cout << syscall.c_str() << endl;
1365 if (system(syscall.c_str()))
1370 c = std::to_string(cnt);
1382 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1383 movedmesh +
" " + wavefile +
" " + interpstreak +
1385 cout << syscall.c_str() << endl;
1386 if (system(syscall.c_str()))
1392 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1393 cout << syscall.c_str() << endl;
1394 if (system(syscall.c_str()))
1399 syscall =
"cp -f " + movedmesh +
" " + filePost;
1400 cout << syscall.c_str() << endl;
1401 if (system(syscall.c_str()))
1406 else if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1408 cout <<
"phase" << endl;
1419 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1420 cout << syscall.c_str() << endl;
1421 if (system(syscall.c_str()))
1427 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + filewave;
1428 cout << syscall.c_str() << endl;
1429 if (system(syscall.c_str()))
1436 syscall =
"cp -f " + meshfile +
" " + meshold;
1437 cout << syscall.c_str() << endl;
1438 if (system(syscall.c_str()))
1445 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1446 cout << syscall.c_str() << endl;
1447 if (system(syscall.c_str()))
1454 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1455 cout << syscall.c_str() << endl;
1456 if (system(syscall.c_str()))
1462 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1463 cout << syscall.c_str() << endl;
1464 if (system(syscall.c_str()))
1473 cout <<
"cr=" << cr_str << endl;
1476 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1477 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1478 c_alpha +
" " + cr_str;
1480 cout << syscall.c_str() << endl;
1481 if (system(syscall.c_str()))
1487 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1488 filePost +
" " + filestreak +
" " + filePost +
" " +
1489 c_alpha +
" " + cr_str;
1490 cout << syscall.c_str() << endl;
1491 if (system(syscall.c_str()))
1497 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1498 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1501 cout << syscall.c_str() << endl;
1502 if (system(syscall.c_str()))
1508 syscall =
"../../utilities/PostProcessing/Extras/SplitFld " +
1509 filePost +
" " + filewave;
1511 cout << syscall.c_str() << endl;
1512 if (system(syscall.c_str()))
1517 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1518 filePost +
" " + filewavepressure +
" " + movedmesh +
1519 " " + interwavepressure;
1521 cout << syscall.c_str() << endl;
1522 if (system(syscall.c_str()))
1539 "cp -f " + interwavepressure +
" " +
m_sessionName +
".fld";
1540 cout << syscall.c_str() << endl;
1541 if (system(syscall.c_str()))
1548 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1550 interpstreak +
"> data" + c;
1551 cout << syscall.c_str() << endl;
1552 if (system(syscall.c_str()))
1558 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1559 cout << syscall.c_str() << endl;
1560 if (system(syscall.c_str()))
1566 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1567 cout << syscall.c_str() << endl;
1568 if (system(syscall.c_str()))
1573 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1574 cout << syscall.c_str() << endl;
1575 if (system(syscall.c_str()))
1580 syscall =
"cp -f " + movedmesh +
" " + filePost;
1581 cout << syscall.c_str() << endl;
1582 if (system(syscall.c_str()))
1609 char alpchar[16] =
"";
1610 snprintf(alpchar, 16,
"%f",
m_alpha[0]);
1615 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1618 string interwavepressure =
1620 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1621 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1624 cout << syscall.c_str() << endl;
1625 if (system(syscall.c_str()))
1631 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1632 filePost +
" " + filestreak +
" " + filePost +
" " +
1634 cout << syscall.c_str() << endl;
1635 if (system(syscall.c_str()))
1642 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1643 cout << syscall.c_str() << endl;
1644 if (system(syscall.c_str()))
1651 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1655 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1656 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1659 cout << syscall.c_str() << endl;
1660 if (system(syscall.c_str()))
1668 syscall =
"cp -f " + meshfile +
" " + meshold;
1669 cout << syscall.c_str() << endl;
1670 if (system(syscall.c_str()))
1676 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1677 cout << syscall.c_str() << endl;
1678 if (system(syscall.c_str()))
1684 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1685 cout << syscall.c_str() << endl;
1686 if (system(syscall.c_str()))
1703 static NekDouble previous_real_evl = -1.0;
1704 static NekDouble previous_imag_evl = -1.0;
1705 static int min_iter = 0;
1709 previous_real_evl = -1.0;
1721 cout <<
"Growth tolerance: "
1725 cout <<
"Phase tolerance: "
1748 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2"
1762 bool returnval =
false;
1765 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1792 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2" << endl;
1830 for (i = 0; i < nstore; ++i)
1834 store = WaveForce[i];
1835 WaveForce[i] = WaveForce[i + k];
1836 WaveForce[i + k] = store;
1839 Growth[i] = Growth[i + k];
1840 Growth[i + k] = store;
1844 for (i = 0; i < nstore - 1; ++i)
1846 if (Growth[i] * Growth[i + 1] < 0.0)
1852 if (i != nstore - 1)
1857 (WaveForce[0] * Growth[1] - WaveForce[1] * Growth[0]) /
1858 (Growth[1] - Growth[0]);
1866 int idx = (i == 0) ? 1 : i;
1867 NekDouble da = WaveForce[idx + 1] - WaveForce[idx - 1];
1868 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1870 (WaveForce[idx - 1] - WaveForce[idx]) /
1871 (WaveForce[idx - 1] - WaveForce[idx + 1]);
1873 (WaveForce[idx] - WaveForce[idx - 1]) /
1874 (WaveForce[idx] - WaveForce[idx + 1]);
1876 (WaveForce[idx + 1] - WaveForce[idx - 1]) /
1877 (WaveForce[idx + 1] - WaveForce[idx]);
1879 for (j = 1; j < nsteps + 1; ++j)
1881 a = WaveForce[i] + j * da / (
NekDouble)nsteps;
1883 c1 * (a - WaveForce[idx]) * (a - WaveForce[idx + 1]) +
1884 c2 * (a - WaveForce[idx - 1]) *
1885 (a - WaveForce[idx + 1]) +
1886 c3 * (a - WaveForce[idx - 1]) * (a - WaveForce[idx]);
1888 if (gval * gval_m1 < 0.0)
1890 wavef_new = ((a + da / (
NekDouble)nsteps) * gval -
1900 if (Growth[i] > 0.0)
1945 int nstore = (
m_alpha.size() < outeriter) ?
m_alpha.size() : outeriter;
1955 for (i = 0; i < nstore; ++i)
1960 Alpha[i] = Alpha[i + k];
1961 Alpha[i + k] = store;
1964 Growth[i] = Growth[i + k];
1965 Growth[i + k] = store;
1969 for (i = 0; i < nstore - 1; ++i)
1971 if (Growth[i] * Growth[i + 1] < 0.0)
1977 if (i != nstore - 1)
1981 alp_new = (Alpha[0] * Growth[1] - Alpha[1] * Growth[0]) /
1982 (Growth[1] - Growth[0]);
1990 int idx = (i == 0) ? 1 : i;
1991 NekDouble da = Alpha[idx + 1] - Alpha[idx - 1];
1992 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1993 NekDouble c1 = Growth[idx - 1] / (Alpha[idx - 1] - Alpha[idx]) /
1994 (Alpha[idx - 1] - Alpha[idx + 1]);
1995 NekDouble c2 = Growth[idx] / (Alpha[idx] - Alpha[idx - 1]) /
1996 (Alpha[idx] - Alpha[idx + 1]);
1998 (Alpha[idx + 1] - Alpha[idx - 1]) /
1999 (Alpha[idx + 1] - Alpha[idx]);
2001 for (j = 1; j < nsteps + 1; ++j)
2003 a = Alpha[i] + j * da / (
NekDouble)nsteps;
2004 gval = c1 * (a - Alpha[idx]) * (a - Alpha[idx + 1]) +
2005 c2 * (a - Alpha[idx - 1]) * (a - Alpha[idx + 1]) +
2006 c3 * (a - Alpha[idx - 1]) * (a - Alpha[idx]);
2008 if (gval * gval_m1 < 0.0)
2010 alp_new = ((a + da / (
NekDouble)nsteps) * gval -
2020 if (Growth[i] > 0.0)
2031 for (
int i =
m_alpha.size() - 1; i > 0; --i)
2058 int start = npts - 1;
2061 bool useOnlyQuads =
false;
2062 if (
m_sessionVWI->DefinesSolverInfo(
"SymmetriseOnlyQuads"))
2064 useOnlyQuads =
true;
2068 for (
int e = 0; e < nel; ++e)
2078 for (i = 0; i < e_npts; ++i)
2080 index[cnt + i] = -1;
2086 for (i = cnt; i < cnt + e_npts; ++i)
2088 xnew = -coord_x[i] + xmax;
2091 for (j = start; j >= 0; --j)
2093 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2094 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2106 for (j = npts - 1; j > start; --j)
2109 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2110 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2117 ASSERTL0(j != start,
"Failed to find matching point");
2126 cout <<
"relaxation..." << endl;
2133 *std::static_pointer_cast<MultiRegions::ExpList>(Iexp[reg]));
2134 int nq = Ilayer->GetTotPoints();
2139 for (
int i = 1; i < 4; ++i)
2147 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_u;
2148 std::vector<std::vector<NekDouble>> FieldData_u;
2154 fld->Import(file, FieldDef_u, FieldData_u);
2155 Ilayer->ExtractDataToCoeffs(FieldDef_u[0], FieldData_u[0],
2156 FieldDef_u[0]->m_fields[0],
2157 Ilayer->UpdateCoeffs());
2158 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2178 1, Ilayer->UpdatePhys(), 1);
2182 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2183 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2184 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef1 =
2185 Ilayer->GetFieldDefinitions();
2186 std::vector<std::vector<NekDouble>> FieldData_1(FieldDef1.size());
2188 FieldDef1[0]->m_fields.push_back(
"u");
2189 Ilayer->AppendFieldData(FieldDef1[0], FieldData_1[0]);
2190 fld->Write(file, FieldDef1, FieldData_1);
2206 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_v;
2207 std::vector<std::vector<NekDouble>> FieldData_v;
2208 fld->Import(file, FieldDef_v, FieldData_v);
2209 Ilayer->ExtractDataToCoeffs(FieldDef_v[0], FieldData_v[0],
2210 FieldDef_v[0]->m_fields[0],
2211 Ilayer->UpdateCoeffs());
2212 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2227 1, Ilayer->UpdatePhys(), 1);
2230 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2231 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2232 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef2 =
2233 Ilayer->GetFieldDefinitions();
2234 std::vector<std::vector<NekDouble>> FieldData_2(FieldDef2.size());
2236 FieldDef2[0]->m_fields.push_back(
"v");
2237 Ilayer->AppendFieldData(FieldDef2[0], FieldData_2[0]);
2238 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)