Barry, Perfect. Yes, that did the trick.
I spent hours trying to figure out what was going on and never thought of the following, since the Jacobian MFFD matrix for -snes_mf_operator is created and handled by SNESSetup and SNESSolve. But now I understand that for -snes_mf option, the PETSc wrapper function for FormJacobian is called instead of the user function, and hence, it makes a difference in -snes_mf_operator alone. Thanks a lot for the help Barry. Also, appreciate updating the manual pages. Cheers, Vijay > -----Original Message----- > From: owner-petsc-users at mcs.anl.gov [mailto:owner-petsc-users at > mcs.anl.gov] > On Behalf Of Barry Smith > Sent: Thursday, March 27, 2008 6:56 AM > To: petsc-users at mcs.anl.gov > Subject: Re: problem with -snes_mf_operator option > > > 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 > > > > No virus found in this incoming message. > Checked by AVG. > Version: 7.5.519 / Virus Database: 269.22.1/1346 - Release Date: 3/27/2008 > 10:03 AM > No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.1/1346 - Release Date: 3/27/2008 10:03 AM
