[petsc-users] SNESGetJacobian issue when added to snes/ex3.c

Xiangdong epscodes at gmail.com
Tue Apr 8 19:55:11 CDT 2014


On Tue, Apr 8, 2014 at 4:45 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
>    The first monitor is called BEFORE the Jacobian is ever created. So
> skip mucking with the jacobian in the 0th iteration of SNES, use the
> iteration argument in your SNES monitor routine.
>

Yes, by adding the condition iter>0 fixed the matrix unassemble problem.

Thanks a lot for mentioning the -mat_view options.

Xiangdong



>
>    BTW: there is a lot of built in viewing of PETSc matrices you can do
> without writing your own monitor. For example in the master development of
> PETSc you can use
>
> -mat_view viewer type:filename:format
>
> for example -mat_view prints the values to the screen in ASCII (use only
> for tiny matrices). -mat_view draw draws the nonzero pattern -mat_view
> binary:filename saves the matrix in binary format to the file filename.
>
>    Barry
>
> On Apr 8, 2014, at 3:18 PM, Xiangdong <epscodes at gmail.com> wrote:
>
> > Hello everyone,
> >
> > I have a question about the usage of SNESGetJacobian().
> >
> > When I added the following three lines to the snes Monitor function in
> ex3 for viewing the Jacobian matrix:
> >
> > Mat Jmat;
> > ierr = SNESGetJacobian(snes,&Jmat,NULL,NULL,NULL); CHKERRQ(ierr);
> > ierr = MatView(Jamt, PETSC_VIEWER_STDOUT_WORLD); CHKERRQ(ierr);
> >
> >  I got error message complaining:
> > Operation done in wrong order!
> > Must call MatAssemblyBegin/End() before viewing matrix!
> >  MatView() line 812 in matrix.c
> >
> >
> > Is the Jmat returned by SNESGetJacobian supposed to be assembled?
> >
> > Even if I add MatAssemblyBegin/End(), it still crashes by reporting
> argument out of range in MatSetValues_SeqAIJ() or MatSetValues_MPIAIJ().
> >
> > Any suggestions?
> >
> > Thank you.
> >
> > Xiangdong
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140408/57b7410e/attachment.html>


More information about the petsc-users mailing list