[petsc-users] preconditioning with Matrix-Free SNES

Barry Smith bsmith at mcs.anl.gov
Tue Jun 12 15:39:19 CDT 2012


   Like in your ComputeJacobian(     Mat *J,Mat *B, ...)

    you are calling MatZeroEntries(*J....) and then MatSetValues(*J,....) 

    you should not do that. You should call the zero entries and set values on B only. Then call MatAssemblyBegin/End() separately on BOTH matrices.

    Also if you checked the error code from MatZeroEntries() with a CHKERRQ(ierr) instead of ignoring it you would likely not get the crash below but would get stack frames instead.

   Barry

On Jun 12, 2012, at 12:54 PM, Matthew Knepley wrote:

> On Wed, Jun 13, 2012 at 1:46 AM, behzad baghapour <behzad.baghapour at gmail.com> wrote:
> You are right! I do calculate the Jacobian and Preconditioning matrice in FormJacobian function with Mat context. When I used "-snes_mf_operator" I received the error:
> 
> Right, you only want to assemble the preconditioning matrix if you use MF.
> 
>    Matt
>  
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: No support for this operation for this object type!
> [0]PETSC ERROR: Mat type mffd!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 3, Fri Sep 30 10:28:33 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: ./code on a linux-gnu named behzad-desktop by behzad Tue Jun 12 22:01:48 2012
> [0]PETSC ERROR: Libraries linked from /home/behzad/softs/petsc/linux-gnu-cxx-debug/lib
> [0]PETSC ERROR: Configure run at Sat Dec 17 10:21:01 2011
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --download-f2cblaslapack=1 --download-mpich=1 --download-hypre --download-parms --with-clanguage=cxx -with-debugging=no
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: MatZeroEntries() line 5186 in src/mat/interface/matrix.c
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
> [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
> [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
> [0]PETSC ERROR: to get more information on the crash.
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Signal received!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 3, Fri Sep 30 10:28:33 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: ./code on a linux-gnu named behzad-desktop by behzad Tue Jun 12 22:01:48 2012
> [0]PETSC ERROR: Libraries linked from /home/behzad/softs/petsc/linux-gnu-cxx-debug/lib
> [0]PETSC ERROR: Configure run at Sat Dec 17 10:21:01 2011
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --download-f2cblaslapack=1 --download-mpich=1 --download-hypre --download-parms --with-clanguage=cxx -with-debugging=no
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file
> application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
> [cli_0]: aborting job:
> application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
> make: [run] Error 59 (ignored)
> 
> 
> 
> On Tue, Jun 12, 2012 at 8:47 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> On Tue, Jun 12, 2012 at 11:12 AM, behzad baghapour <behzad.baghapour at gmail.com> wrote:
> Thank you. Now, I received the error which I should change Mat into mffd.
> 
> Always include the entire error message!
> 
> You have to assemble a matrix to use most preconditioners.
> 
> 
> 
> 
> -- 
> 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



More information about the petsc-users mailing list