[petsc-users] ASM Preconditioner with SNES

Jed Brown jed at 59A2.org
Mon Nov 29 13:08:33 CST 2010


On Mon, Nov 29, 2010 at 20:01, Gaetan Kenway <kenway at utias.utoronto.ca>wrote:

> I am wondering how one sets options for the sub-ksp contexts when using the
> ASM preconditoner for the krylov solve in a SNES.  After I create the snes
> context, set the FormFunction routine, set the snesSetJacobian routine, I
> run something like this:
>
>  call SNESGetKSP(snes,ksp,ierr)
>  call KSPSetType(ksp,KSPGMRES,ierr)
>  call KSPGMRESSetRestart(ksp, 80, ierr)
>  call KSPGetPC(ksp,pc,ierr)
>  call PCSetType( pc, PCASM, ierr)
>  call PCASMSetOverlap(pc,3,ierr)
>
> All good up until here.  Elsewhere where I use just a Krylov solve (for the
> adjoint of the non-linear system),  I would normally use
>
> call PCASMGetSubKSP( pc, nlocal,  first, subksp, ierr)
> call KSPGetPC( subksp, subpc, ierr)
> call PCSetType( subpc, PCILU, ierr)
> call PCFactorSetLevels( subpc, fillLevel , ierr)
> call KSPSetType(subksp, KSPPREONLY, ierr)
>

Note that you are basically just setting defaults, but maybe this is a model
for where your application takes active control of the algorithm?

However, calling the PCASMGetSubKSP gives an error, specifically Error Code
> 58: "Operation done in wrong order".
>

The these cannot be created (or they wouldn't be useful yet) because we
don't have a matrix yet, so we can't know how big the overlap 3 system will
be.  You can call these functions after PCSetUp, but you need to set a
matrix (with correct nonzero, not necessarily correct values) to do PCSetUp.
 So you should either find a way to provide that information before
SNESSolve() and call PCSetUp before PCASMGetSubKSP, or use the options
database to customize the inner solvers.

Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101129/0a5c656a/attachment.htm>


More information about the petsc-users mailing list