[petsc-users] User-defined residual norm calculation in PETSC solvers

Jed Brown jed at jedbrown.org
Thu Nov 27 04:19:00 CST 2014


Kirill Voronin <kvoronin at labchem.sscc.ru> writes:

> Hello!
>
> Thanks Matthew Knepley and Barry Smith for the answers to my previous
> questions!
>
> I am solving Ax = b with PETSC BiCGStab with user-defined preconditioner
> and want to compare it with other iteration process.
>
> The question is
> 1)
> Is there a possibility to monitor a user-defined function of residual
> norm(e.g., useer-defined computation of NORM_1) at each iteration of PETSC
> solver?

KSPMonitorSet your own implementation, written similarly to this:

http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/interface/iterativ.c.html#KSPMonitorTrueResidualMaxNorm

> (I cannot rewrite the user-defined routine for residual norm using
> PETSC interface since it is just fixed and given to me)?
>
> ------
> It seems now that the residual norm (L1 = NORM_1) is calculated somewhat
> different through PETSC and user-defined routine.

You're comparing VecNorm(X,NORM_1,&nrm1) to a user-defined function that
purports to compute the same thing?  What is your implementation?

> The difference is rather
> small but still for comparison with other solver I would prefer to have
> the same numbers.
> As a result, by now I have different values of residual norms measured for
> the same data by PETSC and external user-defined routine. (I checked it
> just be getting arrays from PETSC vectors and then giving them to the
> user-defined routine of residual norm).
>
> I found KSPSetConvergenceTest but the convergence is measured always in
> terms of NORM_2 of the error as far as I understand.

Your convergence test can use any norm you want, but it's expensive to
build a residual for some Krylov methods (e.g., GMRES), so you might not
be happy with the performance.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141127/204adb8e/attachment.pgp>


More information about the petsc-users mailing list