[petsc-dev] Issue with SNESComputeJacobian before SNESSetUp
Lisandro Dalcin
dalcinl at gmail.com
Wed Mar 5 06:52:16 CST 2014
If you call SNESComputeJacobian before SNESSetUp, 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
More information about the petsc-dev
mailing list