[petsc-users] A flag for FormFunction.

Jed Brown jed at 59A2.org
Thu Jan 14 10:02:22 CST 2010


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