@@ -93,6 +93,7 @@ int main(int argc, char *argv[])
9393 bool dirichlet = true ;
9494 int order = 1 ;
9595 int nev = 4 ;
96+ int nev_os = 0 ;
9697 int seed = 75 ;
9798 bool prescribe_init = false ;
9899 int lobpcg_niter = 200 ;
@@ -133,6 +134,8 @@ int main(int argc, char *argv[])
133134 " Order (degree) of the finite elements." );
134135 args.AddOption (&nev, " -n" , " --num-eigs" ,
135136 " Number of desired eigenmodes." );
137+ args.AddOption (&nev_os, " -nos" , " --num-eigs-os" ,
138+ " Number of oversampled eigenmodes." );
136139 args.AddOption (&seed, " -s" , " --seed" ,
137140 " Random seed used to initialize LOBPCG." );
138141 args.AddOption (&litude, " -a" , " --amplitude" ,
@@ -172,7 +175,7 @@ int main(int argc, char *argv[])
172175 " Number of iterations for the LOBPCG solver." );
173176 args.AddOption (&lobpcg_tol, " -tol" , " --fom-tol" ,
174177 " Tolerance for the LOBPCG solver." );
175- args.AddOption (&eig_tol, " -tol" , " --fom -tol" ,
178+ args.AddOption (&eig_tol, " -eig- tol" , " --eig -tol" ,
176179 " Tolerance for eigenvalues to be considered equal." );
177180#ifdef MFEM_USE_SUPERLU
178181 args.AddOption (&slu_solver, " -slu" , " --superlu" , " -no-slu" ,
@@ -298,7 +301,7 @@ int main(int argc, char *argv[])
298301 // 8. Set BasisGenerator if offline
299302 if (offline)
300303 {
301- options = new CAROM::Options (fespace->GetTrueVSize (), nev, nev,
304+ options = new CAROM::Options (fespace->GetTrueVSize (), nev,
302305 update_right_SV);
303306 std::string snapshot_basename = baseName + " par" + std::to_string (id);
304307 generator = new CAROM::BasisGenerator (*options, isIncremental,
@@ -309,7 +312,7 @@ int main(int argc, char *argv[])
309312 if (merge)
310313 {
311314 mergeTimer.Start ();
312- options = new CAROM::Options (fespace->GetTrueVSize (), max_num_snapshots, nev,
315+ options = new CAROM::Options (fespace->GetTrueVSize (), max_num_snapshots,
313316 update_right_SV);
314317 generator = new CAROM::BasisGenerator (*options, isIncremental, basis_filename);
315318 for (int paramID=0 ; paramID<nsets; ++paramID)
@@ -457,7 +460,7 @@ int main(int argc, char *argv[])
457460 }
458461
459462 lobpcg = new HypreLOBPCG (MPI_COMM_WORLD );
460- lobpcg->SetNumModes (nev);
463+ lobpcg->SetNumModes (nev + nev_os );
461464 lobpcg->SetRandomSeed (seed);
462465 lobpcg->SetPreconditioner (*precond);
463466 lobpcg->SetMaxIter (lobpcg_niter);
@@ -469,8 +472,8 @@ int main(int argc, char *argv[])
469472
470473 if (prescribe_init && (fom || (offline && id > 0 )))
471474 {
472- HypreParVector** snapshot_vecs = new HypreParVector*[nev];
473- for (int i = 0 ; i < nev; i++)
475+ HypreParVector** snapshot_vecs = new HypreParVector*[nev + nev_os ];
476+ for (int i = 0 ; i < nev + nev_os ; i++)
474477 {
475478 std::string snapshot_filename = baseName + " ref_snapshot_" + std::to_string (i);
476479 std::ifstream snapshot_infile (snapshot_filename + " ." + std::to_string (myid));
@@ -479,7 +482,7 @@ int main(int argc, char *argv[])
479482 snapshot_vecs[i]->Read (MPI_COMM_WORLD , snapshot_filename.c_str ());
480483 if (myid == 0 ) std::cout << " Loaded " << snapshot_filename << std::endl;
481484 }
482- lobpcg->SetInitialVectors (nev, snapshot_vecs);
485+ lobpcg->SetInitialVectors (nev + nev_os , snapshot_vecs);
483486 if (myid == 0 ) std::cout << " LOBPCG initial vectors set" << std::endl;
484487 }
485488
@@ -496,25 +499,29 @@ int main(int argc, char *argv[])
496499 {
497500 if (myid == 0 )
498501 {
499- std::cout << " Eigenvalue " << i << " : " << eigenvalues[i] << " \n " ;
502+ std::cout << " Eigenvalue " << i << " : " << eigenvalues[i] << " \n " ;
500503 }
501504 if (offline)
502505 {
503506 eigenfunction_i = lobpcg->GetEigenvector (i);
504507 eigenfunction_i /= sqrt (InnerProduct (eigenfunction_i, eigenfunction_i));
505508 generator->takeSample (eigenfunction_i.GetData ());
506- if (prescribe_init && id == 0 )
509+ }
510+ }
511+
512+ if (offline)
513+ {
514+ if (prescribe_init && id == 0 )
515+ {
516+ for (int i = 0 ; i < nev + nev_os; i++)
507517 {
508518 std::string snapshot_filename = baseName + " ref_snapshot_" + std::to_string (i);
509519 const HypreParVector snapshot_vec = lobpcg->GetEigenvector (i);
510520 snapshot_vec.Print (snapshot_filename.c_str ());
511- if (myid == 0 ) std::cout << " Saved " << snapshot_filename << std::endl;
521+ if (myid == 0 ) std::cout << " Saved " << snapshot_filename <<
522+ " for LOBPCG initialization" << std::endl;
512523 }
513524 }
514- }
515-
516- if (offline)
517- {
518525 generator->writeSnapshot ();
519526 delete generator;
520527 delete options;
0 commit comments