problem with -snes_mf_operator option

Barry Smith bsmith at mcs.anl.gov
Thu Mar 27 06:55:55 CDT 2008


     When you are providing the function with SNESetJacobian() and the
A matrix and the B matrix are DIFFERENT they must BOTH have  
MatAssemblyBegin/End()
called on them.  For example in snes/examples/tutorials/ex1.c we
use
   if (*jac != *B){
     ierr = MatAssemblyBegin(*jac,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
     ierr = MatAssemblyEnd(*jac,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }

Note: in your original code both matrices are the same but with the
-snes_mf_operator option the A matrix is changed to a MFFD matrix so is
now different then the B matrix.

Please let us know if this resolves the problem,

   Barry

I have added this information to the manual page for SNESSetJacobian()



On Mar 26, 2008, at 4:14 PM, Vijay S. Mahadevan wrote:
> Hi all,
>
> I have a nonlinear solver test code that can use a user specified
> Jacobian function directly, set using SNESSetJacobian. Now if I use
> -snes_mf option, the solution scheme depends only on the residual and
> the convergence is equivalent to the case when using the real Jacobian
> matrix itself. But if I try the -snes_mf_operator option, with the
> Jacobian=NULL to start with and the preconditioner being correctly
> allocated the memory needed, I end up with a NULL argument exception.
> I also alternately set the preconditioner to Identity matrix in order
> to avoid any problems from user code to trickling in, but to no avail.
>
> Here's the call stack.
>
> [0]PETSC ERROR: Null argument, when expecting valid pointer!
> [0]PETSC ERROR: Null Object: Parameter # 1!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 2.3.3, Patch 7, Fri Oct 26
> 14:21:35 CDT 2007 HG revision:
> 2e223033ba960114833e1f9713ab393ec78c056f
> [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: bin/test-dbg on a linux-gnu named grove by vijaysm Wed
> Mar 26 16:06:45 2008
> [0]PETSC ERROR: Libraries linked from
> /state/partition1/local/petsc-2.3.3-p7/lib/linux-gnu-c-debug
> [0]PETSC ERROR: Configure run at Fri Nov  9 15:02:46 2007
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=ifort
> --with-cxx=g++ --download-f-blas-lapack=1 --download-mpich=1
> --with-shared=1
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: PetscObjectGetComm() line 34 in src/sys/objects/ 
> gcomm.c
> [0]PETSC ERROR: VecNormBegin() line 495 in src/vec/vec/utils/comb.c
> [0]PETSC ERROR: MatMFFDCompute_WP() line 73 in src/mat/impls/mffd/wp.c
> [0]PETSC ERROR: MatMult_MFFD() line 294 in src/mat/impls/mffd/mffd.c
> [0]PETSC ERROR: MatMult() line 1632 in src/mat/interface/matrix.c
> [0]PETSC ERROR: PCApplyBAorAB() line 584 in src/ksp/pc/interface/ 
> precon.c
> [0]PETSC ERROR: GMREScycle() line 159 in src/ksp/ksp/impls/gmres/ 
> gmres.c
> [0]PETSC ERROR: KSPSolve_GMRES() line 241 in src/ksp/ksp/impls/gmres/ 
> gmres.c
> [0]PETSC ERROR: KSPSolve() line 379 in src/ksp/ksp/interface/itfunc.c
> [0]PETSC ERROR: SNES_KSPSolve() line 2578 in src/snes/interface/snes.c
> [0]PETSC ERROR: SNESSolve_LS() line 184 in src/snes/impls/ls/ls.c
> [0]PETSC ERROR: SNESSolve() line 1871 in src/snes/interface/snes.c
>
> From what I can understand from the PETSc code (snes.c, mffd.c), the
> current_u for MFFD context is NULL here. And that is the reason for
> the final exception. But I do not understand how this can be since it
> works perfectly fine with -snes_mf option with no changes in the code.
>
> Please do let me know if you think I should specifically be looking
> for something to tackle this issue. Any help will be appreciated.
>
> Thanks,
> Vijay
>




More information about the petsc-users mailing list