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;
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 +
"'");
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)
1237 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1246 string c = std::to_string(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 string c_alpha = std::to_string(
m_alpha[0]);
1266 cout <<
"alpha = " <<
m_alpha[0] << endl;
1268 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") !=
"phase")
1270 cout <<
"zerophase" << endl;
1272 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1273 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1276 cout << syscall.c_str() << endl;
1277 if (system(syscall.c_str()))
1283 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1284 filePost +
" " + filestreak +
" " + filePost +
" " +
1286 cout << syscall.c_str() << endl;
1287 if (system(syscall.c_str()))
1294 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1295 cout << syscall.c_str() << endl;
1296 if (system(syscall.c_str()))
1303 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1307 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1308 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1311 cout << syscall.c_str() << endl;
1312 if (system(syscall.c_str()))
1320 syscall =
"cp -f " + meshfile +
" " + meshold;
1321 cout << syscall.c_str() << endl;
1322 if (system(syscall.c_str()))
1328 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1329 cout << syscall.c_str() << endl;
1330 if (system(syscall.c_str()))
1336 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1337 cout << syscall.c_str() << endl;
1338 if (system(syscall.c_str()))
1348 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1349 cout << syscall.c_str() << endl;
1350 if (system(syscall.c_str()))
1357 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1358 cout << syscall.c_str() << endl;
1359 if (system(syscall.c_str()))
1365 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1366 cout << syscall.c_str() << endl;
1367 if (system(syscall.c_str()))
1372 c = std::to_string(cnt);
1384 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1385 movedmesh +
" " + wavefile +
" " + interpstreak +
1387 cout << syscall.c_str() << endl;
1388 if (system(syscall.c_str()))
1394 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1395 cout << syscall.c_str() << endl;
1396 if (system(syscall.c_str()))
1401 syscall =
"cp -f " + movedmesh +
" " + filePost;
1402 cout << syscall.c_str() << endl;
1403 if (system(syscall.c_str()))
1408 else if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1410 cout <<
"phase" << endl;
1421 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1422 cout << syscall.c_str() << endl;
1423 if (system(syscall.c_str()))
1429 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + filewave;
1430 cout << syscall.c_str() << endl;
1431 if (system(syscall.c_str()))
1438 syscall =
"cp -f " + meshfile +
" " + meshold;
1439 cout << syscall.c_str() << endl;
1440 if (system(syscall.c_str()))
1447 syscall =
"cp -f " +
m_sessionName +
".fld" +
" " + oldwave;
1448 cout << syscall.c_str() << endl;
1449 if (system(syscall.c_str()))
1456 syscall =
"cp -f " + ujump +
" " +
m_sessionName +
"_u_5.bc_" + c;
1457 cout << syscall.c_str() << endl;
1458 if (system(syscall.c_str()))
1464 syscall =
"cp -f " + vjump +
" " +
m_sessionName +
"_v_5.bc_" + c;
1465 cout << syscall.c_str() << endl;
1466 if (system(syscall.c_str()))
1475 cout <<
"cr=" << cr_str << endl;
1478 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1479 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1480 c_alpha +
" " + cr_str;
1482 cout << syscall.c_str() << endl;
1483 if (system(syscall.c_str()))
1489 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1490 filePost +
" " + filestreak +
" " + filePost +
" " +
1491 c_alpha +
" " + cr_str;
1492 cout << syscall.c_str() << endl;
1493 if (system(syscall.c_str()))
1499 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1500 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1503 cout << syscall.c_str() << endl;
1504 if (system(syscall.c_str()))
1510 syscall =
"../../utilities/PostProcessing/Extras/SplitFld " +
1511 filePost +
" " + filewave;
1513 cout << syscall.c_str() << endl;
1514 if (system(syscall.c_str()))
1519 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1520 filePost +
" " + filewavepressure +
" " + movedmesh +
1521 " " + interwavepressure;
1523 cout << syscall.c_str() << endl;
1524 if (system(syscall.c_str()))
1541 "cp -f " + interwavepressure +
" " +
m_sessionName +
".fld";
1542 cout << syscall.c_str() << endl;
1543 if (system(syscall.c_str()))
1550 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
1552 interpstreak +
"> data" + c;
1553 cout << syscall.c_str() << endl;
1554 if (system(syscall.c_str()))
1560 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1561 cout << syscall.c_str() << endl;
1562 if (system(syscall.c_str()))
1568 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1569 cout << syscall.c_str() << endl;
1570 if (system(syscall.c_str()))
1575 syscall =
"cp -f " + movedinterpmesh +
" " + fileinterp;
1576 cout << syscall.c_str() << endl;
1577 if (system(syscall.c_str()))
1582 syscall =
"cp -f " + movedmesh +
" " + filePost;
1583 cout << syscall.c_str() << endl;
1584 if (system(syscall.c_str()))
1611 char alpchar[16] =
"";
1612 snprintf(alpchar, 16,
"%f",
m_alpha[0]);
1617 string filewavepressure =
m_sessionName +
"_wave_p_split.fld";
1620 string interwavepressure =
1622 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1623 filePost +
" " + filestreak +
" " + fileinterp +
" " +
1626 cout << syscall.c_str() << endl;
1627 if (system(syscall.c_str()))
1633 syscall =
"../../utilities/PostProcessing/Extras/MoveMesh " +
1634 filePost +
" " + filestreak +
" " + filePost +
" " +
1636 cout << syscall.c_str() << endl;
1637 if (system(syscall.c_str()))
1644 syscall =
"cp -f " + filestreak +
" " + oldstreak;
1645 cout << syscall.c_str() << endl;
1646 if (system(syscall.c_str()))
1653 string movedinterpmesh =
m_sessionName +
"_interp_moved.xml";
1657 syscall =
"../../utilities/PostProcessing/Extras/FieldToField " +
1658 fileinterp +
" " + filestreak +
" " + movedinterpmesh +
1661 cout << syscall.c_str() << endl;
1662 if (system(syscall.c_str()))
1670 syscall =
"cp -f " + meshfile +
" " + meshold;
1671 cout << syscall.c_str() << endl;
1672 if (system(syscall.c_str()))
1678 syscall =
"cp -f " + movedmesh +
" " + meshfile;
1679 cout << syscall.c_str() << endl;
1680 if (system(syscall.c_str()))
1686 syscall =
"cp -f " + interpstreak +
" " + filestreak;
1687 cout << syscall.c_str() << endl;
1688 if (system(syscall.c_str()))
1705 static NekDouble previous_real_evl = -1.0;
1706 static NekDouble previous_imag_evl = -1.0;
1707 static int min_iter = 0;
1711 previous_real_evl = -1.0;
1723 cout <<
"Growth tolerance: "
1727 cout <<
"Phase tolerance: "
1750 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2"
1764 bool returnval =
false;
1767 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
1794 cout <<
"Warning: imaginary eigenvalue is greater than 1e-2" << endl;
1832 for (i = 0; i < nstore; ++i)
1836 store = WaveForce[i];
1837 WaveForce[i] = WaveForce[i + k];
1838 WaveForce[i + k] = store;
1841 Growth[i] = Growth[i + k];
1842 Growth[i + k] = store;
1846 for (i = 0; i < nstore - 1; ++i)
1848 if (Growth[i] * Growth[i + 1] < 0.0)
1854 if (i != nstore - 1)
1859 (WaveForce[0] * Growth[1] - WaveForce[1] * Growth[0]) /
1860 (Growth[1] - Growth[0]);
1868 int idx = (i == 0) ? 1 : i;
1869 NekDouble da = WaveForce[idx + 1] - WaveForce[idx - 1];
1870 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1872 (WaveForce[idx - 1] - WaveForce[idx]) /
1873 (WaveForce[idx - 1] - WaveForce[idx + 1]);
1875 (WaveForce[idx] - WaveForce[idx - 1]) /
1876 (WaveForce[idx] - WaveForce[idx + 1]);
1878 (WaveForce[idx + 1] - WaveForce[idx - 1]) /
1879 (WaveForce[idx + 1] - WaveForce[idx]);
1881 for (j = 1; j < nsteps + 1; ++j)
1883 a = WaveForce[i] + j * da / (
NekDouble)nsteps;
1885 c1 * (a - WaveForce[idx]) * (a - WaveForce[idx + 1]) +
1886 c2 * (a - WaveForce[idx - 1]) *
1887 (a - WaveForce[idx + 1]) +
1888 c3 * (a - WaveForce[idx - 1]) * (a - WaveForce[idx]);
1890 if (gval * gval_m1 < 0.0)
1892 wavef_new = ((a + da / (
NekDouble)nsteps) * gval -
1902 if (Growth[i] > 0.0)
1947 int nstore = (
m_alpha.size() < outeriter) ?
m_alpha.size() : outeriter;
1957 for (i = 0; i < nstore; ++i)
1962 Alpha[i] = Alpha[i + k];
1963 Alpha[i + k] = store;
1966 Growth[i] = Growth[i + k];
1967 Growth[i + k] = store;
1971 for (i = 0; i < nstore - 1; ++i)
1973 if (Growth[i] * Growth[i + 1] < 0.0)
1979 if (i != nstore - 1)
1983 alp_new = (Alpha[0] * Growth[1] - Alpha[1] * Growth[0]) /
1984 (Growth[1] - Growth[0]);
1992 int idx = (i == 0) ? 1 : i;
1993 NekDouble da = Alpha[idx + 1] - Alpha[idx - 1];
1994 NekDouble gval_m1 = Growth[idx - 1], a, gval;
1995 NekDouble c1 = Growth[idx - 1] / (Alpha[idx - 1] - Alpha[idx]) /
1996 (Alpha[idx - 1] - Alpha[idx + 1]);
1997 NekDouble c2 = Growth[idx] / (Alpha[idx] - Alpha[idx - 1]) /
1998 (Alpha[idx] - Alpha[idx + 1]);
2000 (Alpha[idx + 1] - Alpha[idx - 1]) /
2001 (Alpha[idx + 1] - Alpha[idx]);
2003 for (j = 1; j < nsteps + 1; ++j)
2005 a = Alpha[i] + j * da / (
NekDouble)nsteps;
2006 gval = c1 * (a - Alpha[idx]) * (a - Alpha[idx + 1]) +
2007 c2 * (a - Alpha[idx - 1]) * (a - Alpha[idx + 1]) +
2008 c3 * (a - Alpha[idx - 1]) * (a - Alpha[idx]);
2010 if (gval * gval_m1 < 0.0)
2012 alp_new = ((a + da / (
NekDouble)nsteps) * gval -
2022 if (Growth[i] > 0.0)
2033 for (
int i =
m_alpha.size() - 1; i > 0; --i)
2060 int start = npts - 1;
2063 bool useOnlyQuads =
false;
2064 if (
m_sessionVWI->DefinesSolverInfo(
"SymmetriseOnlyQuads"))
2066 useOnlyQuads =
true;
2070 for (
int e = 0; e < nel; ++e)
2080 for (i = 0; i < e_npts; ++i)
2082 index[cnt + i] = -1;
2088 for (i = cnt; i < cnt + e_npts; ++i)
2090 xnew = -coord_x[i] + xmax;
2093 for (j = start; j >= 0; --j)
2095 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2096 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2108 for (j = npts - 1; j > start; --j)
2111 if ((coord_x[j] - xnew) * (coord_x[j] - xnew) +
2112 (coord_y[j] - ynew) * (coord_y[j] - ynew) <
2119 ASSERTL0(j != start,
"Failed to find matching point");
2128 cout <<
"relaxation..." << endl;
2135 *std::static_pointer_cast<MultiRegions::ExpList>(Iexp[reg]));
2136 int nq = Ilayer->GetTotPoints();
2141 for (
int i = 1; i < 4; ++i)
2149 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_u;
2150 std::vector<std::vector<NekDouble>> FieldData_u;
2156 fld->Import(file, FieldDef_u, FieldData_u);
2157 Ilayer->ExtractDataToCoeffs(FieldDef_u[0], FieldData_u[0],
2158 FieldDef_u[0]->m_fields[0],
2159 Ilayer->UpdateCoeffs());
2160 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2180 1, Ilayer->UpdatePhys(), 1);
2184 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2185 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2186 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef1 =
2187 Ilayer->GetFieldDefinitions();
2188 std::vector<std::vector<NekDouble>> FieldData_1(FieldDef1.size());
2190 FieldDef1[0]->m_fields.push_back(
"u");
2191 Ilayer->AppendFieldData(FieldDef1[0], FieldData_1[0]);
2192 fld->Write(file, FieldDef1, FieldData_1);
2208 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef_v;
2209 std::vector<std::vector<NekDouble>> FieldData_v;
2210 fld->Import(file, FieldDef_v, FieldData_v);
2211 Ilayer->ExtractDataToCoeffs(FieldDef_v[0], FieldData_v[0],
2212 FieldDef_v[0]->m_fields[0],
2213 Ilayer->UpdateCoeffs());
2214 Ilayer->BwdTrans(Ilayer->GetCoeffs(), Ilayer->UpdatePhys());
2229 1, Ilayer->UpdatePhys(), 1);
2232 Ilayer->FwdTransLocalElmt(Ilayer->GetPhys(), Ilayer->UpdateCoeffs());
2233 fieldcoeffs[0] = Ilayer->UpdateCoeffs();
2234 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef2 =
2235 Ilayer->GetFieldDefinitions();
2236 std::vector<std::vector<NekDouble>> FieldData_2(FieldDef2.size());
2238 FieldDef2[0]->m_fields.push_back(
"v");
2239 Ilayer->AppendFieldData(FieldDef2[0], FieldData_2[0]);
2240 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.
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 scalar 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)