<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 5, 2014 at 1:49 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
On Mar 5, 2014, at 6:52 AM, Lisandro Dalcin <<a href="mailto:dalcinl@gmail.com">dalcinl@gmail.com</a>> wrote:<br>
<br>
> If you call SNESComputeJacobian before SNESSetUp,<br>
<br>
</div>   This is a tricky business because snes has lagjacobian and lagpreconditioner which are suppose to relate to when the Jacobian is computed during the Newton process. By calling SNESComputeJacobian() outside of the Newton process those flags will not work exactly as intended. Maybe this is no big deal but maybe it could cause unexpected behavior?<br>

<br>
   I am not sure how we should handle this.  We could just not allow SNESComputeJacobian() to be called randomly but that seems kind of pedantic.<br>
<br>
    I can hack it not to crash in this case but …. not sure what the correct solution is.</blockquote><div><br></div><div>I call SNESComputeJacobian() outside of SNESSolve() in ex12/62 and it works fine. What is</div><div>
the error you get?</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888"><br>

   Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
> the former routine<br>
> tries to call KSPSetReusePreconditioner, but the snes->ksp object is<br>
> not available yet.<br>
><br>
> I guess a single call to  SNESGetKSP(snes,&snes->ksp) would be enough<br>
> to fix the issue.<br>
><br>
> Barry, could you review and eventually fix it?<br>
><br>
> $ cat tmp.py<br>
> from petsc4py import PETSc<br>
><br>
> X = PETSc.Vec().createSeq(2)<br>
> F = PETSc.Vec().createSeq(2)<br>
> J = PETSc.Mat().createDense([2,2])<br>
> J.setUp()<br>
><br>
> def Fun(snes,x,F): F.assemble()<br>
> def Jac(snes,x,J,P): J.assemble()<br>
><br>
> snes = PETSc.SNES().create()<br>
> snes.setFunction(Fun, F)<br>
> snes.setJacobian(Jac, J)<br>
><br>
> snes.computeFunction(X, F)<br>
> snes.computeJacobian(X, J)<br>
><br>
> $ python tmp.py<br>
> Traceback (most recent call last):<br>
>  File "tmp.py", line 16, in <module><br>
>    snes.computeJacobian(X, J)<br>
>  File "SNES.pyx", line 223, in petsc4py.PETSc.SNES.computeJacobian<br>
> (src/petsc4py.PETSc.c:136887)<br>
> petsc4py.PETSc.Error: error code 85<br>
> [0] SNESComputeJacobian() line 2262 in<br>
> /home/devel/petsc/dev/src/snes/interface/snes.c<br>
> [0] KSPSetReusePreconditioner() line 191 in<br>
> /home/devel/petsc/dev/src/ksp/ksp/interface/itfunc.c<br>
> [0] Null argument, when expecting valid pointer<br>
> [0] Null Object: Parameter # 1<br>
><br>
><br>
> --<br>
> Lisandro Dalcin<br>
> ---------------<br>
> CIMEC (UNL/CONICET)<br>
> Predio CONICET-Santa Fe<br>
> Colectora RN 168 Km 472, Paraje El Pozo<br>
> 3000 Santa Fe, Argentina<br>
> Tel: +54-342-4511594 (ext 1016)<br>
> Tel/Fax: +54-342-4511169<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>