Skip to content

Commit 85948c9

Browse files
committed
form ROM basis/operator at time of window change
1 parent 5e95bae commit 85948c9

File tree

1 file changed

+53
-25
lines changed

1 file changed

+53
-25
lines changed

rom/laghos.cpp

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,18 +1244,37 @@ int main(int argc, char *argv[])
12441244
if (dtc > 0.0) dt = dtc;
12451245
if (usingWindows)
12461246
{
1247-
// Construct the ROM_Basis for each window.
1248-
for (romOptions.window = numWindows-1; romOptions.window >= 0; --romOptions.window)
1247+
if (romOptions.hyperreductionSamplingType != eqp_energy)
12491248
{
1249+
// Construct the ROM_Basis for each window.
1250+
for (romOptions.window = numWindows-1; romOptions.window >= 0; --romOptions.window)
1251+
{
1252+
SetWindowParameters(twparam, romOptions);
1253+
basis[romOptions.window] = new ROM_Basis(romOptions, MPI_COMM_WORLD, sFactorX, sFactorV);
1254+
if (!romOptions.hyperreduce_prep)
1255+
{
1256+
romOper[romOptions.window] = new ROM_Operator(romOptions, basis[romOptions.window], rho_coeff, mat_coeff, order_e, source,
1257+
visc, vort, cfl, p_assembly, cg_tol, cg_max_iter, ftz_tol, &H1FEC, &L2FEC);
1258+
}
1259+
}
1260+
romOptions.window = 0;
1261+
}
1262+
else
1263+
{
1264+
// Construct the ROM basis and operator only for the first
1265+
// window; the ones for the next windows will be constructed
1266+
// at the time of each window change, because the current
1267+
// vector S is needed for their construction.
1268+
// In particular, forming the bases and reduced inverse mass
1269+
// matrices requires knoweldege of vector S.
12501270
SetWindowParameters(twparam, romOptions);
1251-
basis[romOptions.window] = new ROM_Basis(romOptions, MPI_COMM_WORLD, sFactorX, sFactorV);
1271+
basis[0] = new ROM_Basis(romOptions, MPI_COMM_WORLD, sFactorX, sFactorV, &timesteps);
12521272
if (!romOptions.hyperreduce_prep)
12531273
{
1254-
romOper[romOptions.window] = new ROM_Operator(romOptions, basis[romOptions.window], rho_coeff, mat_coeff, order_e, source,
1255-
visc, vort, cfl, p_assembly, cg_tol, cg_max_iter, ftz_tol, &H1FEC, &L2FEC);
1274+
romOper[0] = new ROM_Operator(romOptions, basis[0], rho_coeff, mat_coeff, order_e, source, visc, vort, cfl, p_assembly,
1275+
cg_tol, cg_max_iter, ftz_tol, &H1FEC, &L2FEC, &timesteps);
12561276
}
12571277
}
1258-
romOptions.window = 0;
12591278
}
12601279
else
12611280
{
@@ -1590,12 +1609,6 @@ int main(int argc, char *argv[])
15901609
romOper[0]->ApplyHyperreduction(romS);
15911610
}
15921611

1593-
// // TODO: do we want that for the energy-conserving EQP?
1594-
// if (rom_online && romOptions.hyperreduce && romOptions.hyperreductionSamplingType == eqp_energy)
1595-
// {
1596-
// romOper[0]->ApplyHyperreduction(romS);
1597-
// }
1598-
15991612
double windowEndpoint = 0.0;
16001613
double windowOverlapMidpoint = 0.0;
16011614
for (ti = 1; !last_step; ti++)
@@ -2045,6 +2058,34 @@ int main(int argc, char *argv[])
20452058
int rdimeprev = romOptions.dimE;
20462059

20472060
SetWindowParameters(twparam, romOptions);
2061+
if (romOptions.hyperreductionSamplingType == eqp_energy)
2062+
{
2063+
timeLoopTimer.Stop();
2064+
onlinePreprocessTimer.Start();
2065+
2066+
// Form the ROM basis and operator for the new window.
2067+
basis[romOptions.window] = new ROM_Basis(romOptions, MPI_COMM_WORLD, sFactorX, sFactorV, &timesteps);
2068+
2069+
onlinePreprocessTimer.Stop();
2070+
timeLoopTimer.Start();
2071+
2072+
// Add the last lifted solution vector as the last
2073+
// column in the bases.
2074+
basis[romOptions.window]->AddLastCol_V(*S);
2075+
basis[romOptions.window]->AddLastCol_E(*S);
2076+
2077+
timeLoopTimer.Stop();
2078+
onlinePreprocessTimer.Start();
2079+
2080+
if (!romOptions.hyperreduce_prep)
2081+
{
2082+
romOper[romOptions.window] = new ROM_Operator(romOptions, basis[romOptions.window], rho_coeff, mat_coeff,
2083+
order_e, source, visc, vort, cfl, p_assembly,
2084+
cg_tol, cg_max_iter, ftz_tol, &H1FEC, &L2FEC, &timesteps);
2085+
}
2086+
onlinePreprocessTimer.Stop();
2087+
timeLoopTimer.Start();
2088+
}
20482089
if (romOptions.use_sample_mesh)
20492090
{
20502091
basis[romOptions.window]->ProjectFromPreviousWindow(romOptions, romS, romOptions.window, rdimxprev, rdimvprev, rdimeprev);
@@ -2072,14 +2113,6 @@ int main(int argc, char *argv[])
20722113

20732114
if (!romOptions.use_sample_mesh)
20742115
{
2075-
if (romOptions.hyperreductionSamplingType == eqp_energy)
2076-
{
2077-
// Add the corresponding lifted solution vector
2078-
// to the velocity and energy bases to ensure
2079-
// energy is conserved across windows.
2080-
basis[romOptions.window]->AddLastCol_V(*S);
2081-
basis[romOptions.window]->AddLastCol_E(*S);
2082-
}
20832116
basis[romOptions.window]->ProjectFOMtoROM(*S, romS);
20842117
}
20852118
if (myid == 0)
@@ -2117,11 +2150,6 @@ int main(int argc, char *argv[])
21172150
romOper[romOptions.window]->ApplyHyperreduction(romS);
21182151
}
21192152

2120-
//if (romOptions.hyperreduce && romOptions.hyperreductionSamplingType == eqp_energy)
2121-
//{
2122-
// romOper[romOptions.window]->ApplyHyperreduction(romS);
2123-
//}
2124-
21252153
if (problem == 7 && romOptions.indicatorType == penetrationDistance)
21262154
{
21272155
std::string pd_weight_outputPath = testing_parameter_outputPath + "/pd_weight" + to_string(romOptions.window);

0 commit comments

Comments
 (0)