Output number of iterations for PETSc Krylov solver


347
views
-1
8 months ago by
Hi.

I'm trying to find a good AMG preconditioner for MINRES for my linear system, so I would like to know how many iterations the solver uses. The problem is that no matter what log level I use, the solver just says e.g. "PETSc Krylov solver starting to solve 80401 x 80401 system.", but doesn't report how many iterations were used. I see in PETScKrylovSolver.cpp that it appears that it's supposed to do it, but again, I don't see anything. Does anyone know why this happens?

I'm using FEniCS with dolfin 2017.1.0 in Docker on macOS with Python.

Thank you.
Community: FEniCS Project
If you provided MWE there would be better chance solving your logging problem.
written 8 months ago by Jan Blechta  

1 Answer


1
8 months ago by
The number of iteration is returned by the solver. If you store it into a variable you are able to print it.
solver = PETScKrylovSolver("minres", "hypre_amg")
niter = solver.solve(u.vector(), b)
print(niter​)
1
Thank you very much! I was just looking at the command prompt.
written 8 months ago by petterjf  
1
Edited for python 3 compatibility.
written 8 months ago by Jan Blechta  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »