[petsc-dev] Issue with SNESComputeJacobian before SNESSetUp

Matthew Knepley knepley at gmail.com
Wed Mar 5 13:55:16 CST 2014


On Wed, Mar 5, 2014 at 1:49 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Mar 5, 2014, at 6:52 AM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
>
> > If you call SNESComputeJacobian before SNESSetUp,
>
>    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?
>
>    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.
>
>     I can hack it not to crash in this case but .... not sure what the
> correct solution is.


I call SNESComputeJacobian() outside of SNESSolve() in ex12/62 and it works
fine. What is
the error you get?

  Thanks,

     Matt


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


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20140305/433fe3b4/attachment.html>


More information about the petsc-dev mailing list