[petsc-users] on SNESSetJacobian semantics

Matthew Knepley knepley at gmail.com
Thu Oct 22 09:40:04 CDT 2015


On Thu, Oct 22, 2015 at 9:37 AM, Marco Zocca <zocca.marco at gmail.com> wrote:

> Thank you, but this is not really helping;
>
> why are there two slots to supply the Jacobian of the same function, i.e.
> Amat and J ?
>

Amat is just the storage, not the values. J computes the values.

   Matt


> Marco
>
>
>
>
> On 22 October 2015 at 16:30, Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Thu, Oct 22, 2015 at 9:20 AM, Marco Zocca <zocca.marco at gmail.com>
>> wrote:
>>
>>> The signature of SNESSetJacobian is
>>>
>>> PetscErrorCode  SNESSetJacobian(SNES snes,Mat Amat,Mat
>>> Pmat,PetscErrorCode (*J)(SNES,Vec,Mat,Mat,void*),void *ctx)
>>>
>>> however it would seem redundant to supply both a constant matrix and a
>>> function to compute the Jacobian.
>>> The manual says of J "(if NULL then SNES retains any previously set
>>> value": this would only apply to linear functions, is this correct?
>>>
>>
>> It means, if you give NULL, but have previously called SetJacobian() then
>> it uses the function pointer previously passed
>> rather than setting it to NULL.
>>
>>   Matt
>>
>>
>>> Why then are there not two monomorphic "SetJacobian" functions, one for
>>> linear maps that wouldn't require recomputation and one for every other
>>> case ?
>>>
>>> Coming from a functional background, I find reasoning with "NULL" to be
>>> very error-prone.
>>>
>>> Thank you,
>>> Marco
>>>
>>
>>
>>
>> --
>> 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
>>
>
>


-- 
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-users/attachments/20151022/d22dd167/attachment.html>


More information about the petsc-users mailing list