Skip to content
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 elliptic eigenvalue global prom example #266

Merged
merged 33 commits into from
Apr 3, 2024
Merged

Conversation

ckendrick
Copy link
Collaborator

@ckendrick ckendrick commented Feb 2, 2024

Adds a simple elliptic eigenvalue global pROM example based on MFEM example 11p.

Note: MFEM needs to be compiled with MFEM_USE_LAPACK enabled to run the online phase. This adds a -l option to the compile.sh script to build MFEM with lapack enabled.

Sample runs:

./elliptic_eigenproblem_global_rom -offline -p 2 -id 0 -a 0.40
./elliptic_eigenproblem_global_rom -offline -p 2 -id 1 -a 0.45
./elliptic_eigenproblem_global_rom -offline -p 2 -id 2 -a 0.55
./elliptic_eigenproblem_global_rom -offline -p 2 -id 3 -a 0.60

./elliptic_eigenproblem_global_rom -merge -p 2 -ns 4

./elliptic_eigenproblem_global_rom -fom -p 2 -a 0.50 -visit

./elliptic_eigenproblem_global_rom -online -p 2 -a 0.50

Example FOM output:

Number of unknowns: 289
 Eigenvalue 0: 0.04533314
 Eigenvalue 1: 0.11332411
 Eigenvalue 2: 0.11486387
 Eigenvalue 3: 0.18192
 Eigenvalue 4: 0.22964377
Elapsed time for assembling FOM: 1.475750e-03 second
Elapsed time for solving FOM: 3.390041e-01 second

Example online output:

spatial basis dimension is 289 x 20
Eigenvalue 0: = 0.048430949
Eigenvalue 1: = 0.12021157
Eigenvalue 2: = 0.12147847
Eigenvalue 3: = 0.19456504
Eigenvalue 4: = 0.24285855
Relative error of ROM solution for eigenvalue 0 = 0.068334316
Relative error of ROM solution for eigenvalue 1 = 0.060776586
Relative error of ROM solution for eigenvalue 2 = 0.057586388
Relative error of ROM solution for eigenvalue 3 = 0.069508795
Relative error of ROM solution for eigenvalue 4 = 0.057544708
Relative l2 error of ROM eigenvector 0 = 0.070430601
Relative l2 error of ROM eigenvector 1 = 1.996413
Relative l2 error of ROM eigenvector 2 = 0.077548522
Relative l2 error of ROM eigenvector 3 = 0.10685373
Relative l2 error of ROM eigenvector 4 = 0.1494834
Elapsed time for assembling ROM: 5.230334e-03 second
Elapsed time for solving ROM: 7.794170e-04 second

@@ -26,6 +26,7 @@ USE_MFEM="Off"
UPDATE_LIBS=false
INSTALL_SCALAPACK=false
MFEM_USE_GSLIB="Off"
MFEM_USE_LAPACK="NO"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if there are any reasons to have different kinds of options, "On" vs "Off", "Yes" vs "No", true vs false. Can we unify them?

@siuwuncheung
Copy link
Member

Inviting @dreamer2368 as a reviewer to evaluate the changes in the build process in this PR.

Copy link
Collaborator

@dreamer2368 dreamer2368 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup procedure looks good in general. If LAPACK is required for this example, can we install mfem with LAPACK dependency in our docker container?

@ckendrick ckendrick added the RFR Ready for review label Mar 26, 2024
@ckendrick ckendrick changed the title Add laplace eigenvalue global prom example Add elliptic eigenvalue global prom example Mar 26, 2024
Copy link
Member

@siuwuncheung siuwuncheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except some minor things. Thanks @ckendrick!

For boarder communication, I am able to reproduce the eigenvalues, but the L2 error of eigenvectors appear different. The signs of the eigenvectors seem to be sort of random, which occasionally gives 200% error. One example that I got is

Relative l2 error of ROM eigenvector 0 = 2.0185057
Relative l2 error of ROM eigenvector 1 = 0.090773417
Relative l2 error of ROM eigenvector 2 = 0.076616931
Relative l2 error of ROM eigenvector 3 = 1.9746465
Relative l2 error of ROM eigenvector 4 = 1.9912245

I'll follow up with this example in PR#277 to enable the followings:

  1. Use consistent signs of eigenfunctions
  2. Add boundary condition switch
  3. Clean up to retain only 4 problems, i.e. poisson, reaction-diffusion in heterogeneous media, Schrodinger equation with harmonic potential, Schrodinger equation with negative Gaussian potential well
  4. Extend to 3D examples
  5. Change some filenames

@siuwuncheung
Copy link
Member

siuwuncheung commented Mar 28, 2024

I had approved this PR after reviewing the changes and reproducing the results. We need one more approval to get this PR merged.

lib/mfem/Utilities.hpp Outdated Show resolved Hide resolved
lib/mfem/Utilities.hpp Outdated Show resolved Hide resolved
lib/mfem/Utilities.hpp Outdated Show resolved Hide resolved
lib/mfem/Utilities.hpp Outdated Show resolved Hide resolved
lib/mfem/Utilities.cpp Outdated Show resolved Hide resolved
@ckendrick ckendrick requested a review from dylan-copeland April 2, 2024 17:37
double mesh_center = 0.5 * (bb_max[i] + bb_min[i]);

// check that t is within the limit relative to the center of the mesh
if (std::abs((t(i) - mesh_center)) - (0.5 * domain_limit) > 1.0e-14)
Copy link
Collaborator

@dylan-copeland dylan-copeland Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the condition being checked here is
if (std::abs(t(i) - mesh_center) > 0.5 * domain_limit)
The current version is equivalent, but less clear.

@ckendrick ckendrick merged commit e2b7416 into master Apr 3, 2024
4 checks passed
@ckendrick ckendrick deleted the eigenvalue_example branch April 3, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants