[petsc-users] norm of KSPBuildResidual does not match norm computed from KSPBuildSolution
Moral Sanchez, Elena
Elena.Moral.Sanchez at ipp.mpg.de
Mon Nov 3 11:39:07 CST 2025
Hi,
I am running CG with a Jacobi preconditioner. I have a monitor function that prints the residual and saves the solution at every iteration. To get the solution at every iteration, I am using the function KSPBuildSolution. I am setting the KSP norm as UNPRECONDITIONED.
The convergence test is consistent with the 2-norm of KSPBuildResidual. However this norm does not match the 2-norm of the residual computed explicitly from the solution (obtained with KSPBuildSolution). It also does not match the preconditioned norm. What norm is it computing?
When the CG is not preconditioned, the norm of KSPBuildResidual and the norm of the residual computed from the solution match, as I expected.
This is KSPView():
KSP Object: 1 MPI process
type: cg
variant HERMITIAN
maximum iterations=100, nonzero initial guess
tolerances: relative=1e-08, absolute=1e-08, divergence=10000.
left preconditioning
using UNPRECONDITIONED norm type for convergence test
PC Object: 1 MPI process
type: jacobi
type DIAGONAL
linear system matrix = precond matrix:
Mat Object: 1 MPI process
type: nest
rows=524, cols=524
Matrix object:
type=nest, rows=3, cols=3
MatNest structure:
(0,0) : type=mpiaij, rows=176, cols=176
(0,1) : NULL
(0,2) : NULL
(1,0) : NULL
(1,1) : type=mpiaij, rows=172, cols=172
(1,2) : NULL
(2,0) : NULL
(2,1) : NULL
(2,2) : type=mpiaij, rows=176, cols=176
Cheers,
Elena Moral Sánchez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20251103/4e395726/attachment.html>
More information about the petsc-users
mailing list