Skip to content

Commit 03faebd

Browse files
committed
iterative solver on MPI)
1 parent 913e113 commit 03faebd

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

examples/ex50.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ function solve_poisson(N=100, da_refine=0; solver_opts...)
100100
da_grid_x = parse(Int, get(opts, Symbol("da_grid_x"), string(N)))
101101
da_grid_y = parse(Int, get(opts, Symbol("da_grid_y"), string(N)))
102102

103-
# Use CG solver with LU preconditioner as defaults (robust for MPI tests)
103+
# Use CG solver with appropriate preconditioner based on MPI status
104104
ksp_type = get(opts, Symbol("ksp_type"), "cg")
105-
pc_type = get(opts, Symbol("pc_type"), "lu")
105+
# Use LU for serial runs, GAMG for parallel MPI runs (more scalable)
106+
nprocs = MPI.Comm_size(comm)
107+
default_pc = nprocs > 1 ? "gamg" : "lu"
108+
pc_type = get(opts, Symbol("pc_type"), default_pc)
106109
ksp_rtol = parse(Float64, get(opts, Symbol("ksp_rtol"), "1e-12"))
107110

108111
# Set the grid options

0 commit comments

Comments
 (0)