[petsc-users] Example for solving system of pde with snes

Jed Brown jed at jedbrown.org
Sun Sep 10 08:29:45 CDT 2017


Matthew Knepley <knepley at gmail.com> writes:

> On Sun, Sep 10, 2017 at 9:15 AM, Praveen C <cpraveen at gmail.com> wrote:
>
>>
>>
>>>
>>> You can use SNESSetJacobian, but DMSNESSetJacobianLocal is more
>>> convenient in my opinion.
>>>
>>> > I still have some doubt. If
>>> >
>>> > da0 --> for residual
>>> > da1 --> for jacobian
>>> >
>>> > I still need to call SNESetDM. So here I pass da0 ? But then how will
>>> snes
>>> > know about da1 ?
>>>
>>> This should work.
>>>
>>> DMCreateMatrix(da1, &Jpre);
>>> SNESSetDM(snes, da0);
>>> SNESSetJacobian(snes, NULL, Jpre, NULL, NULL);
>>> DMDASNESSetJacobianLocal(da0, func, ctx);
>>>
>>>
>>> In the last line above, should it not be da1 ?
>>
>
> No, Jed is saying that using a DA with a wider stencil on that Jacobian is
> alright as long as
> you do not try to input values outside the more restricted sparsity pattern.

Yeah, SNES only knows about one DM and will use it for communication,
etc.  An alternative is to implement a function for SNESSetJacobian --
if you do this, you need to get the local work space and do
communication explicitly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170910/482514f6/attachment.sig>


More information about the petsc-users mailing list