[petsc-users] Preconditioning in matrix free SNES

Jed Brown jed at 59A2.org
Fri Feb 4 08:40:47 CST 2011


On Fri, Feb 4, 2011 at 11:02, Travis C. Fisher <travis.fisher at nasa.gov>wrote:

> I am trying to precondition a matrix free SNES solution. The application is
> a high order compressible Navier Stokes solver.
>

What sort of high-order methods?


> My implementation is:
>
> I use the -snes_mf_operator option and create a matrix free matrix via
> MatCreateSNESMF. The function SNESSetJacobian points to (FormJacobian) uses
> MatMFFDComputeJacobian to calculate the matrix free jacobian. I then use
> SNESSetFromOptions and extract the linear solver and preconditioner. The
> linear solver is GMRES. The matrix free jacobian solve with no
> preconditioner works pretty well for the smooth test problem I am currently
> working on, but in general I don't expect it to perform that well without
> preconditioning. I have attempted to perform the preconditioning in two
> ways:
>
> 1) Simply setting the preconditioner extracted from the SNES to PCLU. The
> preconditioner matrix I calculate in my FormJacobian routine is a frozen
> Jacobian matrix, so for the first linear solve, the preconditioned operator
> is essentially the identity operator. The code performs an LU decomposition,
> but the effect of the preconditioner is a larger linear residual, so clearly
> something is wrong.
>

The assembled matrix is likely incorrect, try using a tiny problem size and
-snes_type test. See also SNESSetLagJacobian
http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/SNES/SNESSetLagJacobian.html
.

I realize this may point to my preconditioner matrix being completely wrong,
> but it "looks" right when I check values.
>

How are you creating it and how do you know what the values should "look"
like?


> It would take a lot of effort for me to set up the coloring to have petsc
> calculate the jacobian via finite differences since I am using a high order
> stencil with full boundary closures.
>

That's what -snes_type test is for.


> My question is am I obviously doing something incorrectly?
>

It sounds right to me, but run with -snes_view to see what's happening.


> Am I somehow failing to direct the SNES context to apply the LU
> decomposition and not assume that I have given it a preconditioner matrix to
> simply perform a matrix multiply?
>

This almost never makes sense and it would be very hard to do accidentally:
http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/PC/PCMAT.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110204/6968ef1b/attachment.htm>


More information about the petsc-users mailing list