(Petsc SNES) Reevaluating Function right after evaluating the Jacobian

Barry Smith bsmith at mcs.anl.gov
Mon Dec 1 12:56:57 CST 2008


On Dec 1, 2008, at 12:28 PM, Edson Tadeu wrote:

>   Hi,
>
>    I'm solving non-linear problems with Line Search, and sometimes I  
> need to change an entire row of the Jacobian together with the  
> corresponding element in the Function, but I only know which rows/ 
> elements need to be changed when I'm computing the Jacobian. So,  
> what I'd like to know first is:

    Maybe if you explain why you need to "change an entire row of the  
Jacobian together with the corresponding element in the Function" we  
could come up
with some suggestions on how to proceed.
>
>
>   1) Am I allowed to change the Function vector from inside  
> FormJacobian? (I've looked inside SNESSolve_LS, and it seems that  
> this is not allowed, because "fnorm" is evaluated before  
> SNESComputeJacobian, and if I change F inside FormJacobian, fnorm  
> would be wrong).
>
>   or
>
>   2) Am I allowed to change the Function vector from PreCheck routine?
>
>   If none of that is allowed, another solution that I thought was to  
> compute the Jacobian while computing the Function. The FAQ says that  
> "You are free to have your 'FormFunction' compute as much of the  
> Jacobian at that point as you like, keep the information in the user  
> context (the final argument to FormFunction and FormJacobian) and  
> then retreive the information in your FormJacobian() function". The  
> problem is that FormFunction is called many times more than  
> FormJacobian, and Jacobian calculation is slow, so:
>
>   3) Is there any way to know when I should really recompute the  
> Jacobian from inside FormFunction? (I don't think so, but...)

   No. But if you do not use any line search at all then each function  
evaluation will have an associated Jacobian so you can compute them
together. (Of course you lose the globalization of the line search so  
SNES may not converge).  You can turn off all line searches with - 
snes_ls basic
from the command line or from the code  
SNESLineSearchSet(snes,SNESLineSeachNo,PETSC_NULL);

    Barry


>
>
>   Well, is there any way to solve this problem? ;)
>
> Thanks in advance,
>   Edson
>




More information about the petsc-users mailing list