[petsc-users] Set PC PythonContext within NPC

Asbjørn Nilsen Riseth riseth at maths.ox.ac.uk
Wed Jun 24 19:02:20 CDT 2015


Hi all,

I'm currently trying to set up a nonlinear solver that uses NGMRES with
NEWTONLS as a right preconditioner. The NEWTONLS has a custom linear
preconditioner. Everything is accessed through petsc4py.

*Is there a way I can configure a NPC NEWTONLS KSP CompositePC without
first calling solve on my outer snes?*

My NEWTONLS has the following KSP setup:
FGMRES
| PCCOMPOSITE
|| PYTHON
|| ILU

The way I understand things, the NPC is not created/set up until
SNESSolve_NGMRES() is called. Therefore, I cannot call
snes.getNPC().ksp.pc.getCompositePC(0).setPythonContext(ctx) before I have
called snes.solve().

What I currently do is a try/except on snes.solve to create/set up the
pccomposite. Then I can set my pythoncontext and it runs fine. This is
quite ugly though, so I was hoping anyone would have a better approach.


Ozzy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150625/b6726481/attachment.html>


More information about the petsc-users mailing list