2424#include < AMReX_PlotFileUtil.H>
2525#include < AMReX_MultiFabUtil.H>
2626#include < AMReX_MLMG.H>
27+ #include < AMReX_GMRES_MLMG.H>
2728
2829#include " Poisson.H"
2930
@@ -37,6 +38,7 @@ int main (int argc, char* argv[])
3738 int verbose = 1 ;
3839 int n_cell = 128 ;
3940 int max_grid_size = 32 ;
41+ int use_GMRES = 0 ;
4042 amrex::Vector<int > n_cell_2d;
4143 // read parameters
4244 {
@@ -45,6 +47,7 @@ int main (int argc, char* argv[])
4547 // pp.query("n_cell", n_cell);
4648 pp.queryarr (" n_cell" , n_cell_2d);
4749 pp.query (" max_grid_size" , max_grid_size);
50+ pp.query (" use_GMRES" ,use_GMRES);
4851 }
4952
5053 Geometry geom;
@@ -158,7 +161,16 @@ int main (int argc, char* argv[])
158161
159162 // Solve linear system
160163 phi.setVal (0.0 ); // initial guess for phi
161- mlmg.solve ({&phi}, {&q}, tol_rel, tol_abs);
164+
165+ if (use_GMRES) {
166+ amrex::GMRESMLMG gmsolve (mlmg);
167+ gmsolve.solve (phi, q, tol_rel, tol_abs);
168+ amrex::Vector<amrex::MultiFab> vmf;
169+ vmf.emplace_back (phi, amrex::make_alias, 0 , phi.nComp ());
170+ linop.postSolve (vmf);
171+ } else {
172+ mlmg.solve ({&phi}, {&q}, tol_rel, tol_abs);
173+ }
162174
163175 // // store plotfile variables; q and phi
164176 MultiFab plotfile_mf (grids, dmap, 2 , 0 , MFInfo (), factory);
0 commit comments