[petsc-users] snessetjacobian question

Milan Mitrovic milan.v.mitrovic at gmail.com
Thu Sep 22 09:54:37 CDT 2011


I have a problem with the snes solver...

I initialize it with:

     call SNESCreate(PETSC_COMM_WORLD, snes, info)
     call SNESSetType(snes, SNESLS, info)
     call SNESGetKSP(snes, ksp, info)
     call KSPGetPC(ksp, pc, info)
     call PCSetType(pc, PCNONE, info)
     call KSPSetFromOptions(ksp, info)
     call SNESSetFunction(snes, r, theta_step, ctx, info)
     call SNESSetJacobian(snes, J, J, jacobian, PETSC_NULL, info)

And then in the jacobian function I create one of the matrices:


    call MatCreateMPIAIJ(PETSC_COMM_WORLD, Np, Np, Ng, Ng, &
         nmax+1, PETSC_NULL_INTEGER, nmax+1, PETSC_NULL_INTEGER, Jac, info)
    call MatSetLocalToGlobalMapping(Jac,lgm,info)

then I set the values and:
    call MatAssemblyBegin(Jac, MAT_FINAL_ASSEMBLY, info)
    call MatAssemblyEnd(Jac, MAT_FINAL_ASSEMBLY, info)

and finally I do:

    P = Jac

This works fine... the solver works, I get my results, but in the end
when I try to call SNESDestroy(snes, info) I get:

[0]PETSC ERROR: --------------------- Error Message
------------------------------------
[0]PETSC ERROR: Invalid argument!
[0]PETSC ERROR: Wrong type of object: Parameter # 1!
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 8, Thu Mar 17
13:37:48 CDT 2011
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: ./ppm_pf on a linux-gnu named cbl1 by milanm Thu Sep
22 16:41:35 2011
[0]PETSC ERROR: Libraries linked from
/home/milanm/ppm/petsc-3.1-p8/linux-gnu-c-debug/lib
[0]PETSC ERROR: Configure run at Mon Sep 12 13:38:51 2011
[0]PETSC ERROR: Configure options
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: MatDestroy() line 870 in src/mat/interface/matrix.c
[0]PETSC ERROR: PCDestroy() line 88 in src/ksp/pc/interface/precon.c
[0]PETSC ERROR: KSPDestroy() line 695 in src/ksp/ksp/interface/itfunc.c
[0]PETSC ERROR: SNESDestroy() line 1413 in src/snes/interface/snes.c


What is going on here? Is there something I'm doing wrong?


More information about the petsc-users mailing list