Skip to content

Commit 1c4fdcf

Browse files
authored
GMRES in nodalPoisson (#1)
* GMRES in nodalPoisson * add postsolve to linop
1 parent 35e26f3 commit 1c4fdcf

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

ExampleCodes/EB/NodalPoisson/GNUmakefile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include ./Make.package
1717

1818
Pdirs := Base Boundary AmrCore
1919
Pdirs += EB
20+
Pdirs += LinearSolvers
2021
Pdirs += LinearSolvers/MLMG
2122

2223
Ppack += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package)

ExampleCodes/EB/NodalPoisson/inputs

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ verbose = 2
44
n_cell = 256 128
55
max_grid_size = 256
66

7+
use_GMRES = 1
8+
79
eb2.geom_type = merge
810
#eb2.geom_type = sphere
911
#eb2.sphere_center = 0.5 0.5 0.5

ExampleCodes/EB/NodalPoisson/main.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
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

Comments
 (0)