Basic KSP Convergence Information

I’d like to get basic some sort of iterate diagnostic information about the convergence of my linear solver, invoked via a LinearProblem structure within the Python implementation. If I were just doing pure, command line petsc, I’d execute with the -ksp_monitor flag and that would give me what I want, but I can’t figure out what the analog is here.

You can pass whatever PETSc options you want to the dolfinx.fem.petsc.LinearProblem. Take for instance the demo_poisson.py demo and use

problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu", "ksp_monitor": ""})

to see

  Residual norms for dolfinx_solve_140057445083280 solve.
  0 KSP Residual norm 3.576808899808e-01 
  1 KSP Residual norm 2.628530401697e-15 

in the terminal output.

1 Like