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]);
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);
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()))
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);