[petsc-users] How to do a precondition in SNES flow

Barry Smith bsmith at petsc.dev
Tue Oct 3 13:57:09 CDT 2023



> On Oct 3, 2023, at 2:44 PM, Gong Ding <gongding at cn.cogenda.com> wrote:
> 
> Any better choice if I can do right precondition?
> 
> Merge Jacobian to Function evaluation has performance lost.  
> 

  Why ? Should still just compute the Jacobian once, just earlier in the process.

> On 2023/10/4 02:13, Barry Smith wrote:
>> 
>>   Simply evaluate the Jacobian during your SNESComputeFunction and save it for SNESComputeJacobian.
>> 
>> 
>> 
>>> On Oct 3, 2023, at 1:51 PM, Gong Ding <gongding at cn.cogenda.com> <mailto:gongding at cn.cogenda.com> wrote:
>>> 
>>> Hi all,
>>> 
>>> I'd like to do a  special jacobian precondition during the snes iteration, for which jacobian matrix and RHS vector must be modified explicitly.
>>> 
>>> In the SNESComputeJacobian, the preconditioner P is built after assembly of jacobian matrix.
>>> 
>>> I need to multiply P to J and RHS vector  explicitly as left precondition before the solve stage of J*dx = rhs. 
>>> 
>>> However, I find that petsc evaluates function before jacobian, so P*RHS vector can not be processed at SNESComputeFunction.
>>> 
>>> As a result,  I must find a hook function after SNESComputeJacobian and before the solve stage. 
>>> 
>>> Any suggest? 
>>> 
>>> Gong Ding
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231003/85b83a20/attachment.html>


More information about the petsc-users mailing list