Matrix free example snes/ex20.c

Vijay M vijay.m at gmail.com
Sun Dec 30 12:44:24 CST 2007


Matt,

Thanks for the reply. What you suggested makes sense and so to start from a
common ground, I used no preconditioner at all in both the J-free and
analytical Jacobian cases. But now, interestingly, the analytical Jacobian
takes around twice the number of linear iterations. 

mpirun -np 1 ex20 -ksp_type gmres -snes_monitor -pc_type none
Number of Newton iterations = 6
Number of Linear iterations = 112
Average Linear its / Newton = 1.866667e+01

mpirun -np 1 ex20 -ksp_type gmres -snes_monitor -snes_mf -pc_type none
Number of Newton iterations = 6
Number of Linear iterations = 54
Average Linear its / Newton = 9.000000e+00

I understand that both the methods will not give me the same number of total
linear iterations but a factor of 2 seems a little odd to me. This leads to
another question whether the user can actually change the epsilon used for
computing the perturbation in J-free scheme or is this fixed in PETSc ?

If not, then what do you think is the reason for this ? Do let me know your
comments when you get some time. Thanks.

Vijay

-----Original Message-----
From: owner-petsc-users at mcs.anl.gov [mailto:owner-petsc-users at mcs.anl.gov]
On Behalf Of Matthew Knepley
Sent: Saturday, December 29, 2007 9:05 PM
To: petsc-users at mcs.anl.gov
Subject: Re: Matrix free example snes/ex20.c

On Dec 29, 2007 8:07 PM, Vijay M <vijay.m at gmail.com> wrote:
> Hi all,
>
> I was trying to compile and run the ex20.c example code in the tutorial
> section of SNES. Although it does not explicitly specify that -snes_mf
> option can be used, my understanding is that as long as a nonlinear
residual
> function is written correctly, PETSc will calculate via finite difference
> the action of the Jacobian on a given vector. Is that correct ?

Yes.

> Now if that is the case, then please observe the discrepancy in the number
> of linear iterations taken with an analytical Jacobian and matrix-free
> option. What puzzles me is that the SNES function norm are quite close for
> both the methods but the linear iterations differ by a factor of 3. Why
> exactly is this ?

There is no PC when using -snes_mf whereas the default is ILU for the
analytic
Jacobian.

   Matt

> Here's the output to make this clearer.
>
> vijay :mpirun -np 1 ex20 -ksp_type gmres -snes_monitor
>
>   0 SNES Function norm 2.271442542876e-01
>
>   1 SNES Function norm 6.881516100891e-02
>
>   2 SNES Function norm 1.813939751552e-02
>
>   3 SNES Function norm 2.354176462207e-03
>
>   4 SNES Function norm 3.063728077362e-05
>
>   5 SNES Function norm 3.106106268946e-08
>
>   6 SNES Function norm 5.344742712545e-12
>
>   0 SNES Function norm 2.271442542876e-01
>
>   1 SNES Function norm 6.881516100891e-02
>
>   2 SNES Function norm 1.813939751552e-02
>
>   3 SNES Function norm 2.354176462207e-03
>
>   4 SNES Function norm 3.063728077362e-05
>
>   5 SNES Function norm 3.106106268946e-08
>
>   6 SNES Function norm 5.344742712545e-12
>
> Number of Newton iterations = 6
>
> Number of Linear iterations = 18
>
> Average Linear its / Newton = 3.000000e+00
>
>
>
> vijay :mpirun -np 1 ex20 -ksp_type gmres -snes_monitor -snes_mf
>
>   0 SNES Function norm 2.271442542876e-01
>
>   1 SNES Function norm 6.870629867542e-02
>
>   2 SNES Function norm 1.804335379848e-02
>
>   3 SNES Function norm 2.290074339682e-03
>
>   4 SNES Function norm 3.082384186373e-05
>
>   5 SNES Function norm 3.926396277038e-09
>
>   6 SNES Function norm 3.754922566585e-16
>
>   0 SNES Function norm 2.271442542876e-01
>
>   1 SNES Function norm 6.870629867542e-02
>
>   2 SNES Function norm 1.804335379848e-02
>
>   3 SNES Function norm 2.290074339682e-03
>
>   4 SNES Function norm 3.082384186373e-05
>
>   5 SNES Function norm 3.926396277038e-09
>
>   6 SNES Function norm 3.754922566585e-16
>
> Number of Newton iterations = 6
>
> Number of Linear iterations = 54
>
> Average Linear its / Newton = 9.000000e+00
>
>
>
> Thanks,
>
> Vijay
>
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener




More information about the petsc-users mailing list