On Fri, Nov 4, 2016 at 9:14 AM, Florian Lindner <[email protected]> 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.

2) You can do all that by calling

  MatViewFromOptions(matrix, NULL, "-mymat_view");

and then passing

  -mymat_view draw -draw_pause -1

   Matt


> Thanks,
> 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

Reply via email to