[petsc-dev] access to finite element second derivatives

Matthew Knepley knepley at gmail.com
Mon Dec 2 17:58:52 CST 2013


On Mon, Dec 2, 2013 at 5:29 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> Matthew Knepley <knepley at gmail.com> writes:
> > I do not find this argument convincing, and I don't think its coherent
> > above.
>
> The incremental cost of adding new fields is high if you have to modify
> code in more places.  If I have n fields and want to add one more, you
> would have me write three functions (f0_u, f1_u, f2_u) for residuals and
> up to 9(2n+1) for Jacobian entries [1] (and modify existing functions
> for the other direction of coupling).  Since C does not have closures,
> those functions either need to be generated (terrible workflow) or
> hand-written (worse).
>

1) You only write the functions which you have. I did physics for many
years before
    computing, and anyone who does the derivation keeps all the terms
separate
    until the end. I think polling our users would find that they like this.

2) Shoving everything into a single function makes it very hard to have
sparse input
     to the Jacobian.

3) PyLith is fairly complex and we have had no trouble writing the
functions. It would
    have been more complex to put everything in one function.


> This is wholly untenable, so we need an alternative.  I would have one
> function for residuals and one function for Jacobians, with the results
> added together.  Yes, you have to pack all the fields into the arrays,
> but a dynamic PetscBag could be used to avoid fragile indexing there.


Things that do not exist are not simpler.

   Matt


> > Are you proposing to merge f0/f1/f2? That seems untenable since we must
> > test against different things, unless you want one fat functions with
> > f0/f1/f2
> > as arguments. That does not seem any simpler to me.
>
> It is simpler because you can use loops and can decompose the terms
> however you like.
>
>
> [1] The complexities are 2 residual functions and 4(2n+1) Jacobian
>     contributions if you only need first derivatives.
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20131202/4ea9ac15/attachment.html>


More information about the petsc-dev mailing list