[petsc-users] -snes_type test

Jed Brown jed at 59A2.org
Fri Mar 18 08:23:16 CDT 2011


On Fri, Mar 18, 2011 at 14:03, Gianluca Meneghello <gianmail at gmail.com>wrote:

> what do you mean by constant +1 and constant -1? Is it the
> starting/user-defined state vector +1 and -1?
>
> My problem should not be ill posed
>

Not ill-posed, just ill-conditioned, which can be the result of poor
scaling. For example, changing the units of velocity or pressure so that
these parts of the Jacobian were "the same size" might improve the
conditioning of the system. Depending on the solver, it may or may not make
a convergence difference.


>
> using -mat_fd_type_ds -snes_type test:
>
>   Testing hand-coded Jacobian, if the ratio is
>   O(1.e-8), the hand-coded Jacobian is probably correct.
>   Run with -snes_test_display to show difference
>   of hand-coded and finite difference Jacobian.
>    Norm of matrix ratio 9.17279e-09 difference 2.58883e-06
>   Norm of matrix ratio 8.79304e-08 difference 2.59233e-05
>   Norm of matrix ratio 8.87045e-08 difference 2.58875e-05
>

This numbers are an order of magnitude smaller than before which indicates
that the differencing is sensitive to choice of step.

In the best case, cond=1, this differencing can give you
sqrt(machine_epsilon) which for double precision means you could get 7 or 8
digits correct. You lose precision when the conditioning of the operator
degrades (because of the mesh, physics, or just poor relative scaling of
fields) and if the step size is not chosen well. The default step size
algorithm "wp" is cheaper to compute in parallel, "ds" is more robust.


> while using -ksp_rtol 1e-12 -pc_type lu -snes_monitor
>
>  0 SNES Function norm 2.981436587230e+00
>  1 SNES Function norm 1.487397936082e+00
>  2 SNES Function norm 3.490136703474e-01
>  3 SNES Function norm 1.303397000344e-01
>  4 SNES Function norm 3.181190030949e-02
>  5 SNES Function norm 5.280858553562e-03
>  6 SNES Function norm 3.168168082141e-04
>  7 SNES Function norm 1.217775965490e-06
>  8 SNES Function norm 1.559322624068e-11
>

This looks like quadratic convergence so your Jacobian is probably correct.

> is there a way to see/save/load into matlab the difference between the
computed jacobian and the fd one, apart from output to screen?

Not as currently written, but it would be simple to add. If you are
interested, look at src/snes/impls/test/snestest.c. You could add a runtime
option -snes_test_display_matlab <filename> and then view to a Matlab file
inside SNESSolve_Test(). Let us know if you get lost (preferably on
petsc-dev).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110318/51109024/attachment.htm>


More information about the petsc-users mailing list