[petsc-users] A flag for FormFunction.

Barry Smith bsmith at mcs.anl.gov
Thu Jan 14 10:49:11 CST 2010


   Jed,

     In this case I think one would provide a different function to  
the code that computes the Jacobian then one provides to the SNES as  
the function evaluation. So, for example, one forms a Mat with  
MatFDColoringCreate() and then provides the other function with  
MatFDColoringSetFunction()? (Rather than having one function and try  
to figure out how it is being calling and doing different things).

    Does this handle all situations you are thinking of?

    Barry

On Jan 14, 2010, at 10:02 AM, Jed Brown wrote:

> On Thu, 14 Jan 2010 09:29:33 -0600, Barry Smith <bsmith at mcs.anl.gov>  
> wrote:
>>    Do you want this so you know when the function is being called
>> directly vs when it is being called in computing a Jacobian  
>> derivative
>> with finite differencing? Do you want the function to do something
>> different in the two cases?
>
> Actually, here's a use case where it would be good to know.
>
> Suppose that F does some caching of intermediate quantities needed to
> apply J, or that make assembly of J cheaper.  For example, I apply
> full-accuracy Jacobians unassembled, and assemble something else for
> preconditioning.
>
> But suppose I wanted to use a preconditioning matrix computed by
> coloring, that perhaps also discards some coupling.  For example, we
> might precondition a 3-component STENCIL_BOX discretization with
> STENCIL_STAR where inter-field coupling has been discarded [1].
>
> Since I have a fast full-accuracy Jacobian, I wouldn't want to use the
> inexact thing as the real Jacobian, and caching the intermediate terms
> isn't a lot of work, but it might add 20% to the cost of evaluating  
> F(x)
> and thus be worthwhile if the line search typically needs less than 5
> steps or so.  But perhaps more importantly, if I'm recaching J while
> computing the preconditioner with FD, then J will be evaluated at
> x+eps*y instead of at x which may hurt quadratic convergence.
>
> Jed
>
> [1] STENCIL_STAR preconditioning isn't just hypothetical, I have a  
> nice
> 2D p-Laplacian example where -snes_mf_operator with STENCIL_STAR
> preconditioning beats the analytic (STENCIL_BOX) Jacobian in every
> measure.



More information about the petsc-users mailing list