[petsc-users] Change linear solver during SNES iteration

Barry Smith bsmith at mcs.anl.gov
Sat Sep 11 09:57:52 CDT 2010


On Sep 11, 2010, at 2:00 AM, Gong Ding wrote:

> Hi,
> I wonder if it is possible to use different linear solvers as well as PCs
> in each SNES iteration. For example, I would like to use MUMPS
> in the first nonlinear iteration. And then use the factorized matrix by 
> MUMPS as the preconditioner for i.e. BCGS solver in the second iteration. 

   -snes_lag_preconditioner 2 and it will use the old factorization once then on the third Newton step it will do the factorization again -snes_lag_preconditioner 3 means reuse factorization for two more iterations etc. If computing the Jacobian is expensive you can use -snes_mf_operator -snes_lag_preconditioner 100 and -snes_lag_jacobian 100 and it will use the initial factorization for all Newton steps and never form the Jacobian again just apply it matrix free for the iterative solver using the initial factorization as the preconditioner.


> Or even i can use direct/iterative solver alternately for nonlinear iterations?

   To do more complicated things. Like using a a direct solver and then SOR or ASM or some other solver you need to write a little code. You can add your own SNESMonitorSet() routine that changes the PC in the SNES based on some criteria. But likely using the lag options is all you need.

   Barry

> 
> Gong Ding
> 
> 



More information about the petsc-users mailing list