extracting work vectors

Jed Brown jed at 59A2.org
Fri Dec 4 04:54:23 CST 2009


On Fri, 04 Dec 2009 11:25:11 +0100, jarunan at ascomp.ch wrote:
> I would like to use user-defined preconditioner PCSHELL for GMRES,
> from which I need the work vector(Right hand side during solving which  
> is residual) and approx solution.

A preconditioner for a Krylov iteration cannot use this information,
maybe you're thinking of preconditioned Richardson iteration in which
case, see PCShellSetApplyRicharson.

>  From PCShellSetApply(pc,apply)
> 
> where 'apply' define as PetscErrorCode apply (void *ptr,Vec xin,Vec xout)

should be

  PetscErrorCode apply(PC pc,Vec xin,Vec xout);

use PCShellGetContext() to retrieve your pointer from the PC.

> Is xin automatically the approx solution?

No, it's the vector that the KSP needs you to apply your preconditioner
to.  The relationship between this vector and the "approximate solution"
is different at every iteration of every Krylov method, and different
with right versus left preconditioning.  GMRES does not even build the
"approximate solution" during the iteration, it is only built once you
have converged.  Application of your preconditioner *only* uses xin.

Jed


More information about the petsc-users mailing list