On Dec 13, 2012, at 5:34 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> Options for drawing the result, using coloring instead of dense differencing, 
> and thresholding using rtol and atol to avoid false positives. IIRC, the 
> reason I added all of those variants was because I was given some Jacobian 
> code that was only incorrect when something occurred at a boundary, and was 
> not always obvious for small sizes. In any case, drawing the difference is 
> quite handy.

  I suggest 

    -snes_check_jacobian_view <ascii,draw,binary,?> 

then MatView is just called on the appropriate viewer instead of ugly variant 
options like snes_check_jacobian_draw etc

    In fact this paradigm could be used many places, for example -mat_view 
-mat_view_socket -mat_view_binary -mat_view_draw   could be simplified to 
-mat_view <viewertype> 

   Barry

We'll write a utility routine that when given a viewer type returns the 
appropriate canonical form.



> 
> 
> On Thu, Dec 13, 2012 at 3:29 PM, Peter Brune <prbrune at gmail.com> wrote:
> Reaction after looking at Barry's changeset -- yeah this is great.  Jed, does 
> -compare_explicit_* do anything that's missing here?
> 
> - Peter
> 
> 
> 
> On Thu, Dec 13, 2012 at 5:22 PM, Peter Brune <prbrune at gmail.com> wrote:
> 
> 
> 
> On Thu, Dec 13, 2012 at 5:10 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> On Dec 13, 2012, at 5:04 PM, Peter Brune <prbrune at gmail.com> wrote:
> 
> > Dangit Barry!  I already started a patch moving all Jed's -snes_compare_* 
> > garbage in SNESComputeJacobian() over to a SNESJacobianMonitor registration 
> > type deal where it has functions you can register to run after computing 
> > the Jacobian.  This will allow you to do all sorts of nice comparisons.
> 
>   Dang it we don't need yet another registration thingy, I used the 
> SNESSetUpdate() hook.
>   
>   Actually I don't mind if you do something better and remove mine (it is the 
> story of my life) but don't remove mine until yours produces as pretty an 
> output and has good names for the options and yes
> snes_compare_explicit is a terrible name. At least put jacobian in the option 
> so I have some clue that it has something to do with the jacobian!
> 
> 
> I agree, and this seems like a fine place for it to happen.  I'll have to 
> look at exactly what you did, but you could save a Jacobian computation if 
> you put it after the user Jacobian has been computed, which is why I was 
> putting it as hooks to be run at the end of SNESComputeJacobian().
> 
> I want similar facilities for the objectives as well.   There's already an FD 
> test objective in place (used by SNESTEST to verify if you have written a 
> proper objective -> function -> jacobian set).  If we had it so you could 
> register multiple tests (even in the update slot) we could provide a whole 
> suite of potential useful output without much work.
> 
> - Peter
> 
>   Barry
> 
> >
> > Dangit Jed!  -snes_compare_* is a seeerious mess and shouldn't be in 
> > SNESComputeJacobian().  Barry's recent holy war against string comparisons 
> > will find this some day and there will be a lot of explaining to do.
> >
> > - Peter
> >
> >
> > On Thu, Dec 13, 2012 at 4:59 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> > Surely you were aware of the -snes_compare_* options that can be activated 
> > in SNESComputeJacobian().
> >
> > Can we settle on one common way to do this testing and perhaps remove 
> > -snes_type test.
> >
> >
> > On Thu, Dec 13, 2012 at 2:55 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> >    I got sick of -snes_type test only checking the Jacobian at the initial 
> > solution and not being able to test later Jacobians so I added 
> > -snes_check_jacobian that allows the regular running of SNESSolve() (also 
> > inside TS) and compares every Jacobian computed with a finite difference 
> > version.
> >
> >   For example, (already found one bug in one example :-(). This may be the 
> > best thing I've added to PETSc in a decade.
> >
> >    Barry
> >
> >
> > Barrys-MacBook-Pro:advection-diffusion-reaction barrysmith$ ./ex1 
> > -snes_check_jacobian -snes_monitor  -ts_type arkimex | more
> >     0 SNES Function norm 2.182384017537e+00
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       1.68322e-09 = ||J - Jfd||//J|| 6.69028e-06  = ||J - Jfd||
> >     1 SNES Function norm 4.695397453383e-07
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       2.45109e-09 = ||J - Jfd||//J|| 9.74235e-06  = ||J - Jfd||
> >     2 SNES Function norm 4.020379099215e-13
> >     0 SNES Function norm 6.799718390407e-01
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       1.65487e-09 = ||J - Jfd||//J|| 6.5776e-06  = ||J - Jfd||
> >     1 SNES Function norm 4.558192078678e-08
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       2.93714e-09 = ||J - Jfd||//J|| 1.16742e-05  = ||J - Jfd||
> >     2 SNES Function norm 9.907308296870e-14
> >     0 SNES Function norm 1.000842117652e+00
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       1.24476e-09 = ||J - Jfd||//J|| 4.94755e-06  = ||J - Jfd||
> >     1 SNES Function norm 9.875108391772e-08
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       1.10818e-10 = ||J - Jfd||//J|| 4.40468e-07  = ||J - Jfd||
> >     2 SNES Function norm 7.677760150017e-14
> >     0 SNES Function norm 2.179048757949e+00
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       1.32338e-09 = ||J - Jfd||//J|| 5.27058e-07  = ||J - Jfd||
> >     1 SNES Function norm 4.625448863612e-05
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >         Run with -snes_check_jacobian_display to show difference of 
> > hand-coded and finite difference Jacobian.
> >       1.57582e-09 = ||J - Jfd||//J|| 6.27588e-07  = ||J - Jfd||
> >     2 SNES Function norm 4.391784647745e-14
> >     0 SNES Function norm 6.761591873515e-01
> >         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the 
> > hand-coded Jacobian is probably correct.
> >
> >
> >
> >
> 
> 
> 
> 

Reply via email to