[petsc-users] A question on finite difference Jacobian

Barry Smith bsmith at mcs.anl.gov
Tue Oct 6 20:09:41 CDT 2015


> On Oct 6, 2015, at 4:22 PM, Zou (Non-US), Ling <ling.zou at inl.gov> wrote:
> 
> 
> 
> On Tue, Oct 6, 2015 at 2:38 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> > On Oct 6, 2015, at 3:29 PM, Zou (Non-US), Ling <ling.zou at inl.gov> wrote:
> >
> > Hi All,
> >
> > If the non-zero pattern of a finite difference Jacobian needs 20 colors to color it (20 comes from MatFDColoringView, the non-zero pattern is pre-determined from mesh connectivity), is it true that PETSc needs 40 functions evaluation to get the full Jacobian matrix filled? This is because that a perturbation per color needs two function evaluation according to PETSc manual (ver 3.6, page 123, equations shown in the middle of the page).
> > But I only see 20 function evaluations. I probably have some misunderstanding somewhere. Any suggestions?
> 
>    PETSc uses forward differencing to compute the derivatives, hence it needs a single function evaluation at the given point (which has almost always been previously computed in Newton's method)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Is it a potential problem if the user chooses to use a different (e.g. simplified) residual function as the function for MatFDColoringSetFunction?

   Yes, you can do that. But this may result in a "Newton" direction that is not a descent direction hence Newton stalls. If you have 20 colors I doubt that it would be a good idea to use a cheaper function there. If you have several hundred colors then you can use a simpler function PLUS -snes_mf_operator to insure that the Newton direction is correct.


  Barry

> 
>  
> and then one function evaluation for each color. This is why it reports 20 function evaluations.
> 
>   Barry
> 
> 
> >
> > Ling
> 
> 



More information about the petsc-users mailing list