<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 4, 2016 at 9:14 AM, Florian Lindner <span dir="ltr"><<a href="mailto:mailinglists@xgm.de" target="_blank">mailinglists@xgm.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I want to print the sparsity structure of a matrix of type MPISBAIJ and try to use this code:<br>
<br>
  PetscErrorCode ierr = 0;<br>
  PetscViewer viewer;<br>
  PetscDraw draw;<br>
  ierr = PetscViewerCreate(<wbr>communicator, &viewer); CHKERRV(ierr);<br>
  ierr = PetscViewerSetType(viewer, PETSCVIEWERDRAW); CHKERRV(ierr);<br>
  ierr = MatView(matrix, viewer); CHKERRV(ierr);<br>
  ierr = PetscViewerDrawGetDraw(viewer, 0, &draw); CHKERRV(ierr);<br>
  ierr = PetscDrawSetPause(draw, -1); CHKERRV(ierr); // Wait for user<br>
  ierr = PetscDrawDestroy(&draw); CHKERRV(ierr);<br>
  ierr = PetscViewerDestroy(&viewer); CHKERRV(ierr);<br>
<br>
communicator is of type MPI_Comm and is PETSC_COMM_WORLD.<br>
<br>
It opens an X window and shows the matrix just fine. The window closes after a right click and then my application crashes:<br>
<br>
------------------------------<wbr>------------------------------<wbr>--------------<br>
[1]PETSC ERROR: PetscDrawFlush() line 27 in /data/scratch/lindnefn/<wbr>software/petsc/src/sys/<wbr>classes/draw/interface/dflush.<wbr>c<br>
    Wrong type of object: Parameter # 1<br>
------------------------------<wbr>------------------------------<wbr>--------------<br>
<br>
I tried to swap the DrawDestroy and ViewerDestroy calls (though, imho the order is correct), but changes nothing.<br></blockquote><div><br></div><div>1) Do not Destroy the Draw you get. That is just a borrowed reference.</div><div><br></div><div>2) You can do all that by calling</div><div><br></div><div>  MatViewFromOptions(matrix, NULL, "-mymat_view");</div><div><br></div><div>and then passing</div><div><br></div><div>  -mymat_view draw -draw_pause -1</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks,<br>
Florian<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>