[petsc-users] preconditioner for -snes_fd or -snes_fd_color

Peter Brune prbrune at gmail.com
Fri Apr 4 16:29:47 CDT 2014


On Fri, Apr 4, 2014 at 4:22 PM, Xiangdong <epscodes at gmail.com> wrote:

>
>
>
> On Fri, Apr 4, 2014 at 5:15 PM, Xiangdong <epscodes at gmail.com> wrote:
>
>>
>>
>>
>> On Fri, Apr 4, 2014 at 5:02 PM, Peter Brune <brune at mcs.anl.gov> wrote:
>>
>>>
>>>
>>>
>>> On Fri, Apr 4, 2014 at 3:57 PM, Xiangdong <epscodes at gmail.com> wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> If we use -snes_fd or -snes_fd_color, can we still pass a
>>>> preconditioner to snes/ksp?
>>>>
>>>> In snes/ex1.c, when I use -snes_fd, the program never calls the
>>>> FormJacobian1 to get the preconditioner.
>>>>
>>>
>>> FormJacobian1 forms... wait for it... the Jacobian!  Not the
>>> preconditioner.  -snes_fd and -snes_fd_color replace the Jacobian-forming
>>> routine.
>>>
>>
>> It looks like the FormJacobian1 forms both Jacobian J and preconditioner
>> B. My observations are
>>
>> 1) Without any options, FormJacobian1 can provide both Jacobian J and
>> preconditioner B.
>>
>
From
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESJacobianFunction.html#SNESJacobianFunction:

"Pmat - the matrix to be used in constructing the preconditioner, usually
the same as Amat"

The preconditioner is formed later using Pmat, whether or not it's just the
same as the Jacobian.


> 2) With -snes_fd, the program does not call the FormJacobian1 function at
>> all, even if we have SNESSetJacobian in the codes.
>>
>> If it does not call the FormJacobian1 and SNESSetJacobian is ignored with
>> -snes_fd, how can I provide the preconditioner to snes?
>>
>> Thank you.
>>
>> Xiangdong
>>
>>
>>
>>>
>>>
>>>>
>>>> Any suggestions about providing preconditioner to snes_fd or
>>>> snes_fd_color?
>>>>
>>>>
>>> Both of these explicitly create the approximate Jacobian matrix by using
>>> finite differences, so they may be used with any preconditioner.  -snes_mf
>>> is a different beast entirely and merely approximates the action of the
>>> matrix without forming it, which is where the preconditioner issues come in.
>>>
>>
> Given that -snes_fd is explicitly formed, so -pc_type gamg or ilu will
> work. What happens if I want to provide my own preconditioner?
>
>
If you have a custom preconditioner in mind, you could implement it in a
PCSHELL
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCSHELL.htmlor
register a custom preconditioner
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCRegister.html.
 If your preconditioner is merely a matrix you may use PCMAT
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMAT.html


> Thank you.
>
> Xiangdong
>
>
>
>>
>>> - Peter
>>>
>>>
>>>> Thanks.
>>>>
>>>> Xiangdong
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140404/35b8be74/attachment.html>


More information about the petsc-users mailing list