@@ -93,6 +93,7 @@ int main(int argc, char *argv[])
93
93
bool dirichlet = true ;
94
94
int order = 1 ;
95
95
int nev = 4 ;
96
+ int nev_os = 0 ;
96
97
int seed = 75 ;
97
98
bool prescribe_init = false ;
98
99
int lobpcg_niter = 200 ;
@@ -133,6 +134,8 @@ int main(int argc, char *argv[])
133
134
" Order (degree) of the finite elements." );
134
135
args.AddOption (&nev, " -n" , " --num-eigs" ,
135
136
" Number of desired eigenmodes." );
137
+ args.AddOption (&nev_os, " -nos" , " --num-eigs-os" ,
138
+ " Number of oversampled eigenmodes." );
136
139
args.AddOption (&seed, " -s" , " --seed" ,
137
140
" Random seed used to initialize LOBPCG." );
138
141
args.AddOption (&litude, " -a" , " --amplitude" ,
@@ -172,7 +175,7 @@ int main(int argc, char *argv[])
172
175
" Number of iterations for the LOBPCG solver." );
173
176
args.AddOption (&lobpcg_tol, " -tol" , " --fom-tol" ,
174
177
" Tolerance for the LOBPCG solver." );
175
- args.AddOption (&eig_tol, " -tol" , " --fom -tol" ,
178
+ args.AddOption (&eig_tol, " -eig- tol" , " --eig -tol" ,
176
179
" Tolerance for eigenvalues to be considered equal." );
177
180
#ifdef MFEM_USE_SUPERLU
178
181
args.AddOption (&slu_solver, " -slu" , " --superlu" , " -no-slu" ,
@@ -298,7 +301,7 @@ int main(int argc, char *argv[])
298
301
// 8. Set BasisGenerator if offline
299
302
if (offline)
300
303
{
301
- options = new CAROM::Options (fespace->GetTrueVSize (), nev, nev,
304
+ options = new CAROM::Options (fespace->GetTrueVSize (), nev,
302
305
update_right_SV);
303
306
std::string snapshot_basename = baseName + " par" + std::to_string (id);
304
307
generator = new CAROM::BasisGenerator (*options, isIncremental,
@@ -309,7 +312,7 @@ int main(int argc, char *argv[])
309
312
if (merge)
310
313
{
311
314
mergeTimer.Start ();
312
- options = new CAROM::Options (fespace->GetTrueVSize (), max_num_snapshots, nev,
315
+ options = new CAROM::Options (fespace->GetTrueVSize (), max_num_snapshots,
313
316
update_right_SV);
314
317
generator = new CAROM::BasisGenerator (*options, isIncremental, basis_filename);
315
318
for (int paramID=0 ; paramID<nsets; ++paramID)
@@ -457,7 +460,7 @@ int main(int argc, char *argv[])
457
460
}
458
461
459
462
lobpcg = new HypreLOBPCG (MPI_COMM_WORLD);
460
- lobpcg->SetNumModes (nev);
463
+ lobpcg->SetNumModes (nev + nev_os );
461
464
lobpcg->SetRandomSeed (seed);
462
465
lobpcg->SetPreconditioner (*precond);
463
466
lobpcg->SetMaxIter (lobpcg_niter);
@@ -469,8 +472,8 @@ int main(int argc, char *argv[])
469
472
470
473
if (prescribe_init && (fom || (offline && id > 0 )))
471
474
{
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++)
474
477
{
475
478
std::string snapshot_filename = baseName + " ref_snapshot_" + std::to_string (i);
476
479
std::ifstream snapshot_infile (snapshot_filename + " ." + std::to_string (myid));
@@ -479,7 +482,7 @@ int main(int argc, char *argv[])
479
482
snapshot_vecs[i]->Read (MPI_COMM_WORLD, snapshot_filename.c_str ());
480
483
if (myid == 0 ) std::cout << " Loaded " << snapshot_filename << std::endl;
481
484
}
482
- lobpcg->SetInitialVectors (nev, snapshot_vecs);
485
+ lobpcg->SetInitialVectors (nev + nev_os , snapshot_vecs);
483
486
if (myid == 0 ) std::cout << " LOBPCG initial vectors set" << std::endl;
484
487
}
485
488
@@ -496,25 +499,29 @@ int main(int argc, char *argv[])
496
499
{
497
500
if (myid == 0 )
498
501
{
499
- std::cout << " Eigenvalue " << i << " : " << eigenvalues[i] << " \n " ;
502
+ std::cout << " Eigenvalue " << i << " : " << eigenvalues[i] << " \n " ;
500
503
}
501
504
if (offline)
502
505
{
503
506
eigenfunction_i = lobpcg->GetEigenvector (i);
504
507
eigenfunction_i /= sqrt (InnerProduct (eigenfunction_i, eigenfunction_i));
505
508
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++)
507
517
{
508
518
std::string snapshot_filename = baseName + " ref_snapshot_" + std::to_string (i);
509
519
const HypreParVector snapshot_vec = lobpcg->GetEigenvector (i);
510
520
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;
512
523
}
513
524
}
514
- }
515
-
516
- if (offline)
517
- {
518
525
generator->writeSnapshot ();
519
526
delete generator;
520
527
delete options;
0 commit comments