[petsc-users] which function return the L2 norm of the residual vector in ksp solver

Barry Smith bsmith at mcs.anl.gov
Tue Jul 9 22:49:11 CDT 2013


   This depends on when you want the l2 norm and which solver. 

   With right preconditioning generally the l2 norm of the residual (or a an estimate of it) is computed as part of the computation and is available. With left preconditioning the l2 norm of the preconditioned residual (which is B*r) is computed and available.  It is also possible to explicitly compute the residual and its l2 norm (at additional computation). For example the routine http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/interface/iterativ.c.html#KSPMonitorTrueResidualNorm explicitly computes the norm. 

   You can provide a routine that is called at each iteration with KSPMonitorSet() that takes as one of its inputs the (preconditioned) residual norm. 

   See also KSPSetNormType() for determining which residual norm is used and computed by the solver.

   After the solve is complete you can call KSPGetResidualNorm() to get the l2 norm of the (preconditioned) residual.

   If you tell us when and where you plan to use this value we might be able to provide additional ways to obtain it.

   Barry



On Jul 9, 2013, at 9:54 PM, 丁老师 <ztdepyahoo at 163.com> wrote:

> 
> 



More information about the petsc-users mailing list