From b6b8e575444c6d989d09081121dc5e9b46e89bc9 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Wed, 15 Nov 2023 08:32:57 -0800 Subject: [PATCH 1/4] Add assemble timer and timing prints --- .../dg_advection_local_rom_matrix_interp.cpp | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/prom/dg_advection_local_rom_matrix_interp.cpp b/examples/prom/dg_advection_local_rom_matrix_interp.cpp index 244b42908..00e43f35d 100644 --- a/examples/prom/dg_advection_local_rom_matrix_interp.cpp +++ b/examples/prom/dg_advection_local_rom_matrix_interp.cpp @@ -527,7 +527,9 @@ int main(int argc, char *argv[]) VectorFunctionCoefficient velocity(dim, velocity_function); FunctionCoefficient inflow(inflow_function); FunctionCoefficient u0(u0_function); + StopWatch fom_timer, assemble_timer; + assemble_timer.Start(); ParBilinearForm *m = new ParBilinearForm(fes); ParBilinearForm *k = new ParBilinearForm(fes); if (pa) @@ -574,6 +576,8 @@ int main(int argc, char *argv[]) u->ProjectCoefficient(u0); HypreParVector *U = u->GetTrueDofs(); + assemble_timer.Stop(); + { ostringstream mesh_name, sol_name; mesh_name << "dg_advection_local_rom_matrix_interp-mesh." << setfill('0') << @@ -681,9 +685,7 @@ int main(int argc, char *argv[]) } } - StopWatch fom_timer; double t = 0.0; - int max_num_snapshots = t_final / dt + 1; bool update_right_SV = false; bool isIncremental = false; @@ -714,6 +716,8 @@ int main(int argc, char *argv[]) if (online) { + assemble_timer.Start(); + if (!online_interp) { CAROM::BasisReader reader(basisName); @@ -884,6 +888,8 @@ int main(int argc, char *argv[]) u_in = new Vector(numColumnRB); *u_in = 0.0; + + assemble_timer.Stop(); } TimeDependentOperator* adv; @@ -1037,6 +1043,23 @@ int main(int argc, char *argv[]) osol.close(); } + // 13. print timing info + if (myid == 0) + { + if (fom || offline) + { + printf("Elapsed time for assembling FOM: %e second\n", + assemble_timer.RealTime()); + printf("Elapsed time for solving FOM: %e second\n", fom_timer.RealTime()); + } + if (online) + { + printf("Elapsed time for assembling ROM: %e second\n", + assemble_timer.RealTime()); + printf("Elapsed time for solving ROM: %e second\n", fom_timer.RealTime()); + } + } + // 16. Free the used memory. delete U; delete u; From d2a4a70605f6d731ffaee667fcfc457896b367dc Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Mon, 20 Nov 2023 09:12:41 -0800 Subject: [PATCH 2/4] Fix issue with -online_interp when running in parallel --- examples/prom/dg_advection_local_rom_matrix_interp.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/prom/dg_advection_local_rom_matrix_interp.cpp b/examples/prom/dg_advection_local_rom_matrix_interp.cpp index 00e43f35d..5a45d4752 100644 --- a/examples/prom/dg_advection_local_rom_matrix_interp.cpp +++ b/examples/prom/dg_advection_local_rom_matrix_interp.cpp @@ -809,14 +809,11 @@ int main(int argc, char *argv[]) std::vector M_hats; std::vector b_hats; std::vector u_init_hats; - std::ofstream fout; - fout.open("frequencies.txt"); for(auto it = frequencies.begin(); it != frequencies.end(); it++) { CAROM::Vector* point = new CAROM::Vector(1, false); point->item(0) = *it; parameter_points.push_back(point); - fout << *it << std::endl; std::string parametricBasisName = "basis_" + std::to_string(*it); CAROM::BasisReader reader(parametricBasisName); @@ -843,7 +840,6 @@ int main(int argc, char *argv[]) parametricuinithat->read("u_init_hat_" + std::to_string(*it)); u_init_hats.push_back(parametricuinithat); } - fout.close(); if (myid == 0) printf("spatial basis dimension is %d x %d\n", numRowRB, numColumnRB); From 73ff70add7b1d357b4b7fc22e459a15ae792c344 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 30 Nov 2023 13:07:38 -0800 Subject: [PATCH 3/4] Update timing print --- .../dg_advection_local_rom_matrix_interp.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/prom/dg_advection_local_rom_matrix_interp.cpp b/examples/prom/dg_advection_local_rom_matrix_interp.cpp index 5a45d4752..d7bf6c0ca 100644 --- a/examples/prom/dg_advection_local_rom_matrix_interp.cpp +++ b/examples/prom/dg_advection_local_rom_matrix_interp.cpp @@ -1042,18 +1042,11 @@ int main(int argc, char *argv[]) // 13. print timing info if (myid == 0) { - if (fom || offline) - { - printf("Elapsed time for assembling FOM: %e second\n", - assemble_timer.RealTime()); - printf("Elapsed time for solving FOM: %e second\n", fom_timer.RealTime()); - } - if (online) - { - printf("Elapsed time for assembling ROM: %e second\n", - assemble_timer.RealTime()); - printf("Elapsed time for solving ROM: %e second\n", fom_timer.RealTime()); - } + const std::string type = online ? "ROM" : "FOM"; + std::cout << "Elapsed time for assembling " << type << ": " << std::scientific + << std::setprecision(8) << assemble_timer.RealTime() << " second\n"; + std::cout << "Elapsed time for solving " << type << ": " << std::scientific << + std::setprecision(8) << fom_timer.RealTime() << " second\n"; } // 16. Free the used memory. From b97510536fede0126c9dac87010f65e2a4fe23be Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 7 Dec 2023 05:18:09 -0800 Subject: [PATCH 4/4] Fix minor typo in examples --- examples/prom/dg_advection_local_rom_matrix_interp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/prom/dg_advection_local_rom_matrix_interp.cpp b/examples/prom/dg_advection_local_rom_matrix_interp.cpp index d7bf6c0ca..d0db96f14 100644 --- a/examples/prom/dg_advection_local_rom_matrix_interp.cpp +++ b/examples/prom/dg_advection_local_rom_matrix_interp.cpp @@ -32,7 +32,7 @@ // dg_advection_local_rom_matrix_interp -interp_prep -ff 1.08 -rdim 40 // dg_advection_local_rom_matrix_interp -fom -ff 1.05 // dg_advection_local_rom_matrix_interp -online_interp -ff 1.05 -rdim 40 (interpolate using a linear solve) -// dg_advection_local_rom_matrix_interp -online_interp -ff 1.05 -rdim 40 -im "LP" (interpolate using lagragian polynomials) +// dg_advection_local_rom_matrix_interp -online_interp -ff 1.05 -rdim 40 -im "LP" (interpolate using lagrangian polynomials) // dg_advection_local_rom_matrix_interp -online_interp -ff 1.05 -rdim 40 -im "IDW" (interpolate using inverse distance weighting) // // Sample runs: