[petsc-users] How to view draw a matrix?
Florian Lindner
mailinglists at xgm.de
Fri Nov 4 09:33:08 CDT 2016
Hey,
Am 04.11.2016 um 15:21 schrieb Matthew Knepley:
> On Fri, Nov 4, 2016 at 9:14 AM, Florian Lindner <mailinglists at xgm.de <mailto:mailinglists at xgm.de>> wrote:
>
> Hello,
>
> I want to print the sparsity structure of a matrix of type MPISBAIJ and try to use this code:
>
> PetscErrorCode ierr = 0;
> PetscViewer viewer;
> PetscDraw draw;
> ierr = PetscViewerCreate(communicator, &viewer); CHKERRV(ierr);
> ierr = PetscViewerSetType(viewer, PETSCVIEWERDRAW); CHKERRV(ierr);
> ierr = MatView(matrix, viewer); CHKERRV(ierr);
> ierr = PetscViewerDrawGetDraw(viewer, 0, &draw); CHKERRV(ierr);
> ierr = PetscDrawSetPause(draw, -1); CHKERRV(ierr); // Wait for user
> ierr = PetscDrawDestroy(&draw); CHKERRV(ierr);
> ierr = PetscViewerDestroy(&viewer); CHKERRV(ierr);
>
> communicator is of type MPI_Comm and is PETSC_COMM_WORLD.
>
> It opens an X window and shows the matrix just fine. The window closes after a right click and then my application
> crashes:
>
> --------------------------------------------------------------------------
> [1]PETSC ERROR: PetscDrawFlush() line 27 in
> /data/scratch/lindnefn/software/petsc/src/sys/classes/draw/interface/dflush.c
> Wrong type of object: Parameter # 1
> --------------------------------------------------------------------------
>
> I tried to swap the DrawDestroy and ViewerDestroy calls (though, imho the order is correct), but changes nothing.
>
>
> 1) Do not Destroy the Draw you get. That is just a borrowed reference.
Perfekt, that works.
> 2) You can do all that by calling
>
> MatViewFromOptions(matrix, NULL, "-mymat_view");
>
> and then passing
>
> -mymat_view draw -draw_pause -1
Yeah, the arguments or .petscrc are really great for experimenting!
Best,
Florian
> --
> 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