-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add QDEIM option to some examples #229
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1d5c203
Adding QDEIM option to some examples.
dylan-copeland 46ce469
Merge branch 'master' of github.com:LLNL/libROM into qdeim-examples
dylan-copeland a18d70f
Adding new Hyperreduction class to simplify calls to different types …
dylan-copeland d47c558
Minor edits.
dylan-copeland 604f53e
Style
dylan-copeland e6cfaa5
Update regression tests.
dylan-copeland 9c9bf28
Added hrtype to command line examples
axla-io 97cf09c
Increased max iterations for M_solver
axla-io c05bda7
Small bug fix
axla-io 893d7cb
Revert changes made in error
axla-io 7070d3d
Merge branch 'qdeim-examples' of https://github.com/LLNL/libROM into …
axla-io 16a7679
Actually reverting
axla-io 568c86a
Added qdeim regression test. Added results for QDEIM sample runs.
dylan-copeland bb82ac7
Merge branch 'master' of github.com:LLNL/libROM into qdeim-examples
dylan-copeland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,50 +31,57 @@ | |
// Analytic test (reproductive) | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -offline | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -merge -ns 1 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -nsdim 20 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -nsdim 20 -sopt | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -nsdim 20 -hrtype deim | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -nsdim 20 -hrtype qdeim | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -nsdim 20 -hrtype sopt | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -nsdim 20 -ns 1 -eqp | ||
// | ||
// Relative l2 error of ROM solution at final timestep using DEIM sampling: 1.096776797994166e-08 | ||
// Elapsed time for time integration loop using DEIM sampling: 0.6351594580000001 | ||
// Elapsed time for time integration loop using DEIM sampling: 0.5686423310000001 | ||
// Relative l2 error of ROM solution at final timestep using QDEIM sampling: 1.227055339859034e-08 | ||
// Elapsed time for time integration loop using QDEIM sampling: 0.575228571 | ||
// Relative l2 error of ROM solution at final timestep using S_OPT sampling: 1.01945081122054e-08 | ||
// Elapsed time for time integration loop using S_OPT sampling: 0.6669736559999999 | ||
// Relative l2 error of ROM solution at final timestep using EQP: 1.46205848438194e-07 | ||
// Elapsed time for time integration loop using EQP: 0.431521853 | ||
// Elapsed time for time integration loop using S_OPT sampling: 0.5311964850000001 | ||
// Relative l2 error of ROM solution at final timestep using EQP: 1.052559143494963e-08 | ||
// Elapsed time for time integration loop using EQP: 0.346165296 | ||
// | ||
// Note that the timing of the time integration loop does not include setup, | ||
// which can be greater for S_OPT and EQP than for DEIM. | ||
// | ||
// Initial step test (reproductive) | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -offline -p 1 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -merge -ns 1 -p 1 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -p 1 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -p 1 -sopt | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -p 1 -hrtype deim | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -p 1 -hrtype sopt | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -online -rrdim 8 -rwdim 8 -nldim 20 -p 1 -ns 1 -eqp | ||
// | ||
// Relative l2 error of ROM solution at final timestep using DEIM sampling: 0.0003712362376412496 | ||
// Elapsed time for time integration loop using DEIM sampling: 0.364855569 | ||
// Elapsed time for time integration loop using DEIM sampling: 0.339288686 | ||
// Relative l2 error of ROM solution at final timestep using QDEIM sampling: 0.000375066186385267 | ||
// Elapsed time for time integration loop using QDEIM sampling: 0.32320409 | ||
// Relative l2 error of ROM solution at final timestep using S_OPT sampling: 0.0003797338657417907 | ||
// Elapsed time for time integration loop using S_OPT sampling: 0.300462563 | ||
// Relative l2 error of ROM solution at final timestep using EQP sampling: 0.0003710336208386964 | ||
// Elapsed time for time integration loop using EQP sampling: 0.481740662 | ||
// Elapsed time for time integration loop using S_OPT sampling: 0.32422266 | ||
// Relative l2 error of ROM solution at final timestep using EQP sampling: 0.0003709977143117392 | ||
// Elapsed time for time integration loop using EQP sampling: 0.457011311 | ||
// | ||
// Initial step parametric test (predictive) | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -offline -id 0 -sh 0.25 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -offline -id 1 -sh 0.15 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -offline -id 2 -sh 0.35 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -merge -ns 3 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -offline -id 3 -sh 0.3 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -online -rrdim 8 -rwdim 8 -nldim 20 -sh 0.3 -id 3 | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -online -rrdim 8 -rwdim 8 -nldim 20 -sh 0.3 -id 3 -sopt | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -online -rrdim 8 -rwdim 8 -nldim 20 -sh 0.3 -id 3 -hrtype deim | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -online -rrdim 8 -rwdim 8 -nldim 20 -sh 0.3 -id 3 -hrtype sopt | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -p 1 -online -rrdim 8 -rwdim 8 -nldim 20 -sh 0.3 -id 3 -ns 3 -eqp -maxnnls 30 | ||
// | ||
// Relative l2 error of ROM solution at final timestep using DEIM sampling: 0.002681387312231006 | ||
// Elapsed time for time integration loop using DEIM sampling: 0.355846074 | ||
// Elapsed time for time integration loop using DEIM sampling: 0.359206509 | ||
// Relative l2 error of ROM solution at final timestep using QDEIM sampling: 0.00266355670204476 | ||
// Elapsed time for time integration loop using QDEIM sampling: 0.309432016 | ||
// Relative l2 error of ROM solution at final timestep using S_OPT sampling: 0.002701713369494112 | ||
// Elapsed time for time integration loop using S_OPT sampling: 0.348985935 | ||
// Elapsed time for time integration loop using S_OPT sampling: 0.41139788 | ||
// Relative l2 error of ROM solution at final timestep using EQP: 0.002659978000520714 | ||
// Elapsed time for time integration loop using EQP sampling: 0.176821221 | ||
// Elapsed time for time integration loop using EQP sampling: 0.164961644 | ||
// | ||
// Pointwise snapshots for DMD input | ||
// mpirun -n 1 ./mixed_nonlinear_diffusion -pwsnap -pwx 101 -pwy 101 | ||
|
@@ -90,9 +97,7 @@ | |
#include "linalg/BasisGenerator.h" | ||
#include "linalg/BasisReader.h" | ||
#include "linalg/NNLS.h" | ||
#include "hyperreduction/DEIM.h" | ||
#include "hyperreduction/GNAT.h" | ||
#include "hyperreduction/S_OPT.h" | ||
#include "hyperreduction/Hyperreduction.h" | ||
#include "mfem/SampleMesh.hpp" | ||
#include "mfem/PointwiseSnapshot.hpp" | ||
|
||
|
@@ -550,7 +555,7 @@ int main(int argc, char *argv[]) | |
bool offline = false; | ||
bool merge = false; | ||
bool online = false; | ||
bool use_sopt = false; | ||
const char *samplingType = "deim"; | ||
bool use_eqp = false; | ||
bool writeSampleMesh = false; | ||
int num_samples_req = -1; | ||
|
@@ -619,8 +624,8 @@ int main(int argc, char *argv[]) | |
"Enable or disable the online phase."); | ||
args.AddOption(&merge, "-merge", "--merge", "-no-merge", "--no-merge", | ||
"Enable or disable the merge phase."); | ||
args.AddOption(&use_sopt, "-sopt", "--sopt", "-no-sopt", "--no-sopt", | ||
"Use S-OPT sampling instead of DEIM for the hyperreduction."); | ||
args.AddOption(&samplingType, "-hrtype", "--hrsamplingtype", | ||
"Sampling type for hyperreduction."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend adding different hyper-reduction sampling types in the regression test for this example, similar to the mixed nonlinear diffusion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
args.AddOption(&num_samples_req, "-nsr", "--nsr", | ||
"Number of samples for the sampling algorithm to select."); | ||
args.AddOption(&use_eqp, "-eqp", "--eqp", "-no-eqp", "--no-eqp", | ||
|
@@ -950,8 +955,6 @@ int main(int argc, char *argv[]) | |
CAROM::BasisReader readerFR("basisFR"); | ||
FR_librom = readerFR.getSpatialBasis(0.0); | ||
|
||
// Compute sample points using DEIM, for hyperreduction | ||
|
||
if (nldim == -1) | ||
{ | ||
nldim = FR_librom->numColumns(); | ||
|
@@ -1005,6 +1008,7 @@ int main(int argc, char *argv[]) | |
else | ||
{ | ||
// Setup hyperreduction using DEIM, GNAT, or S-OPT | ||
CAROM::Hyperreduction hr(samplingType); | ||
vector<int> num_sample_dofs_per_proc(num_procs); | ||
|
||
if (num_samples_req != -1) | ||
|
@@ -1019,44 +1023,15 @@ int main(int argc, char *argv[]) | |
// Now execute the chosen sampling algorithm to get the sampling information. | ||
Bsinv = new CAROM::Matrix(nsamp_R, nldim, false); | ||
vector<int> sample_dofs(nsamp_R); // Indices of the sampled rows | ||
if (use_sopt) | ||
{ | ||
if (myid == 0) | ||
printf("Using S_OPT sampling\n"); | ||
CAROM::S_OPT(FR_librom, | ||
nldim, | ||
sample_dofs, | ||
num_sample_dofs_per_proc, | ||
*Bsinv, | ||
myid, | ||
num_procs, | ||
nsamp_R); | ||
} | ||
else if (nsamp_R != nldim) | ||
{ | ||
if (myid == 0) | ||
printf("Using GNAT sampling\n"); | ||
CAROM::GNAT(FR_librom, | ||
nldim, | ||
sample_dofs, | ||
num_sample_dofs_per_proc, | ||
*Bsinv, | ||
myid, | ||
num_procs, | ||
nsamp_R); | ||
} | ||
else | ||
{ | ||
if (myid == 0) | ||
printf("Using DEIM sampling\n"); | ||
CAROM::DEIM(FR_librom, | ||
nldim, | ||
sample_dofs, | ||
num_sample_dofs_per_proc, | ||
*Bsinv, | ||
myid, | ||
num_procs); | ||
} | ||
|
||
hr.ComputeSamples(FR_librom, | ||
nldim, | ||
sample_dofs, | ||
num_sample_dofs_per_proc, | ||
*Bsinv, | ||
myid, | ||
num_procs, | ||
nsamp_R); | ||
|
||
vector<int> sample_dofs_S; // Indices of the sampled rows | ||
vector<int> num_sample_dofs_per_proc_S(num_procs); | ||
|
@@ -1068,8 +1043,6 @@ int main(int argc, char *argv[]) | |
readerS = new CAROM::BasisReader("basisS"); | ||
S_librom = readerS->getSpatialBasis(0.0); | ||
|
||
// Compute sample points using DEIM | ||
|
||
if (nsdim == -1) | ||
{ | ||
nsdim = S_librom->numColumns(); | ||
|
@@ -1083,7 +1056,7 @@ int main(int argc, char *argv[]) | |
if (myid == 0) | ||
printf("reduced S dim = %d\n",nsdim); | ||
|
||
// Now execute the DEIM algorithm to get the sampling information. | ||
// Now use a hyperreduction method to compute samples. | ||
if (num_samples_req != -1) | ||
{ | ||
nsamp_S = num_samples_req; | ||
|
@@ -1095,38 +1068,16 @@ int main(int argc, char *argv[]) | |
|
||
Ssinv = new CAROM::Matrix(nsamp_S, nsdim, false); | ||
sample_dofs_S.resize(nsamp_S); | ||
if (use_sopt) | ||
{ | ||
CAROM::S_OPT(S_librom, | ||
nsdim, | ||
sample_dofs_S, | ||
num_sample_dofs_per_proc_S, | ||
*Ssinv, | ||
myid, | ||
num_procs, | ||
nsamp_S); | ||
} | ||
else if (nsamp_S != nsdim) | ||
{ | ||
CAROM::GNAT(S_librom, | ||
nsdim, | ||
sample_dofs_S, | ||
num_sample_dofs_per_proc_S, | ||
*Ssinv, | ||
myid, | ||
num_procs, | ||
nsamp_S); | ||
} | ||
else | ||
{ | ||
CAROM::DEIM(S_librom, | ||
nsdim, | ||
sample_dofs_S, | ||
num_sample_dofs_per_proc_S, | ||
*Ssinv, | ||
myid, | ||
num_procs); | ||
} | ||
|
||
|
||
hr.ComputeSamples(S_librom, | ||
nsdim, | ||
sample_dofs_S, | ||
num_sample_dofs_per_proc_S, | ||
*Ssinv, | ||
myid, | ||
num_procs, | ||
nsamp_S); | ||
} | ||
|
||
// Construct sample mesh | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this result corresponds to
-hrtype deim
? Perhaps we should report the example results for Q-DEIM and S-OPT here and in the libROM webpage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought was not to add it, because the QDEIM result is almost the same as DEIM. For completeness, I went ahead and added it. I agree that the webpage should be updated as well, to let users know about the QDEIM option.
I actually updated all the run times. Reporting run times is troublesome, because they vary even on the same machine. When a new result is added, all runs have to be updated for a fair comparison.