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 string c = std::to_string(cnt);
608 string c_alpha = std::to_string(
m_alpha[0]);
609 if (
m_sessionVWI->GetSolverInfo(
"INTERFACE") ==
"phase")
612 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
614 "meshhalf_pos_Spen_stability_moved.fld "
615 "meshhalf_pos_Spen_advPost_moved.fld " +
616 c_alpha +
" > data_alpha0";
617 cout << syscall.c_str() << endl;
618 if (system(syscall.c_str()))
623 syscall =
"cp -f meshhalf_pos_Spen_stability_moved_u_5.bc " +
625 cout << syscall.c_str() << endl;
626 if (system(syscall.c_str()))
630 syscall =
"cp -f meshhalf_pos_Spen_stability_moved_v_5.bc " +
632 cout << syscall.c_str() << endl;
633 if (system(syscall.c_str()))
640 syscall =
"../../utilities/PostProcessing/Extras/FldCalcBCs " +
641 movedmesh +
" " + wavefile +
" " + filestreak +
" " +
642 c_alpha +
" > datasub_" + c;
643 cout << syscall.c_str() << endl;
644 if (system(syscall.c_str()))
653 string wave_subalp =
m_sessionName +
"_wave_subalp_" + c +
".fld";
654 syscall =
"cp -f " + wavefile +
" " + wave_subalp;
655 cout << syscall.c_str() << endl;
656 if (system(syscall.c_str()))
670 static int projectfield = -1;
681 if (projectfield == -1)
688 for (
int j = 0; j < BndConds.size(); ++j)
690 if (BndConds[j]->GetBoundaryConditionType() ==
697 if (projectfield != -1)
702 if (projectfield == -1)
704 cout <<
"using first field to project non-linear forcing which "
705 "imposes a Dirichlet condition"
735 invnorm = 1.0 / Linf;
749 cout <<
"Area: " << area << endl;
750 invnorm =
sqrt(area / invnorm);
789 std::vector<std::string> variables(3);
790 std::vector<Array<OneD, NekDouble>> outfield(3);
791 variables[0] =
"u_w";
792 variables[1] =
"v_w";
793 variables[2] =
"w_w";
833 Vmath::Vvtvp(npts, u_imag, 1, u_imag, 1, val, 1, val, 1);
839 Vmath::Vvtvp(npts, u_imag, 1, v_imag, 1, val, 1, val, 1);
859 Vmath::Vvtvp(npts, v_imag, 1, v_imag, 1, val, 1, val, 1);
878 m_sessionVWI->MatchSolverInfo(
"Symmetrization",
"True", symm,
true);
901 for(i = 0; i < npts; ++i)
903 coord[0] = coord_x[i];
904 coord[1] = coord_y[i];
912 for(i = 0; i < npts; ++i)
915 coord[0] = coord_x[i];
916 coord[1] = coord_y[i];
917 der2 [i] =
m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
930 for(i = 0; i < npts; ++i)
933 coord[0] = coord_x[i];
934 coord[1] = coord_y[i];
935 der2[i] =
m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
944 m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der2, m_vwiForceing[1]);
951 cout <<
"symmetrization is active" << endl;
956 for (i = 0; i < npts; ++i)
960 val[i] = 0.5 * (der1[i] - der1[index[i]]);
972 for (i = 0; i < npts; ++i)
976 val[i] = 0.5 * (der2[i] - der2[index[i]]);
991 cout <<
"F_Linf: " <<
Vmath::Vmax(npts, val, 1) << endl;
1010 for (
int j = 0; j < 2; ++j)
1015 for (
int i = 0; i < npts; ++i)
1025 std::vector<std::string> variables(4);
1026 std::vector<Array<OneD, NekDouble>> outfield(4);
1029 variables[2] =
"pr";
1030 variables[3] =
"pi";
1049 cout <<
"int P^2: " <<
m_wavePressure->GetPlane(0)->Integral(val)
1052 cout <<
"PLinf: " <<
Vmath::Vmax(npts, val, 1) << endl;
1061 outfield, variables);
1085 cout <<
"int P^2 " <<
m_wavePressure->GetPlane(0)->Integral(val) << endl;
1089 cout <<
"Linf: " << Linf << endl;
1102 l2 =
sqrt(norm / area);
1104 cout <<
"L2: " << l2 << endl;
1106 cout <<
"Ratio Linf/L2: " << Linf / l2 << endl;
1111 static map<string, int> opendir;
1113 if (opendir.find(dir) == opendir.end())
1116 string mkdir =
"mkdir " + dir;
1117 ASSERTL0(system(mkdir.c_str()) == 0,
1118 "Failed to make directory '" + dir +
"'");
1124 dir +
"/" + file +
"." + boost::lexical_cast<std::string>(n);
1125 string syscall =
"cp -f " + file +
" " +
savefile;
1127 ASSERTL0(system(syscall.c_str()) == 0, syscall.c_str());
1132 static map<string, int> opendir;
1134 if (opendir.find(dir) == opendir.end())
1137 string mkdir =
"mkdir " + dir;
1138 ASSERTL0(system(mkdir.c_str()) == 0,
1139 "Failed to make directory '" + dir +
"'");
1144 dir +
"/" + file +
"." + boost::lexical_cast<std::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)
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)
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 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 > log(scalarT< T > in)
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)