[petsc-users] SNESSetJacobian

Matthew Knepley knepley at gmail.com
Wed Sep 24 05:48:15 CDT 2014


On Wed, Sep 24, 2014 at 6:21 AM, anton <popov at uni-mainz.de> wrote:

>
> On 09/23/2014 06:11 PM, Barry Smith wrote:
>
>> On Sep 23, 2014, at 9:50 AM, anton <popov at uni-mainz.de> wrote:
>>
>>  Starting from version 3.5 the matrix parameters in SNESSetJacobian are
>>> no longer pointers, hence my question:
>>> What is the most appropriate place to call SNESSetJacobian if I need  to
>>> change the Jacobian during solution?
>>> What about FormFunction?
>>>
>>     Could you please explain why you need to change the Mat? Our hope was
>> that people would not need to change it. Note that you can change the type
>> of a matrix at any time. So for example inside your FormJacobian you can
>> have code like MatSetType(J,MATAIJ) this wipes out the old matrix data
>> structure and gives you an empty matrix of the new type ready to be
>> preallocated and then filled. Let us know what you need.
>>
>
>
> How should a user switch from assembled to a matrix-free Jacobian (for
> example) within one run? Simplest is resetting SNES altogether, I guess.
>

Set the type to MATSHELL and set your apply function. You still should not
need to change the pointer, exactly as Barry says above.

  Matt


> Anton
>
>     Barry
>>
>>  Thanks,
>>> Anton
>>>
>>
>


-- 
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/20140924/0a32415c/attachment.html>


More information about the petsc-users mailing list