1

I just started with PETSC and I'm trying to plot a matrix using matView. My code is like:

 MatCreateSeqAIJWithArrays(PETSC_COMM_WORLD, nodes, nodes, rows, cols, values, net); //I want to visualize "net"

 //Visualization
    if(display >= 1){
        PetscPrintf(PETSC_COMM_WORLD, "CSR structure created.\n");
        MatView(*net,PETSC_VIEWER_DRAW_WORLD);
    }

When I use MatView this way:

MatView(*net,PETSC_VIEWER_STDOUT_WORLD);

I can see a list with the rows. But when I change it to

MatView(*net,PETSC_VIEWER_DRAW_WORLD);

nothing happens.

I can't see anything about net structure, not even the list.

I tried to run the examples but they don't work at all. Also, the PETSC documentation just makes things worse. Can someone help me? I don't want to see a list of rows, but the matrix (graphically).


More context from the comments:

  • X windows is functioning properly -- was able to confirm with gvim, xlogo, xeyes, etc.
  • Library has been rebuilt using --with-x option in configure. Still nothing appears.
chrisaycock
  • 36,470
  • 14
  • 88
  • 125
  • Does the drawing routine require an X server? Are you able to run other X windows programs? – chrisaycock May 29 '15 at 17:06
  • I'm not pretty sure of what is an X server... How can I check it? @chrisaycock – Francielly Rodrigues May 29 '15 at 17:13
  • I tried to run "xinit": "Server is already active for display 0 If this server is no longer running, remove /tmp/.X0-lock and start again." – Francielly Rodrigues May 29 '15 at 17:15
  • Make sure you have a `$DISPLAY` environment variable in your shell. If you have ssh'ed to a server from your desktop, make sure that you have X forwarding enabled. Try to run a graphical program, like `gvim`. You might also be able to run `xlogo` or `xeyes` if those are installed. We just want to ensure that you can run graphical programs before focusing on your code. – chrisaycock May 29 '15 at 17:19
  • It's working for gvim, xlogo and xeyes. @chrisaycock – Francielly Rodrigues May 29 '15 at 17:24
  • So X windows works correctly. And your `MatView()` function still displays nothing? – chrisaycock May 29 '15 at 17:29
  • No. MatView only shows the list of rows when I use "STDOUT" instead of "DRAW" as mentioned above. – Francielly Rodrigues May 29 '15 at 17:32
  • I found it "You create Draw windows or ViewerDraw windows or use options -ksp_monitor_lg_residualnorm or -snes_monitor_lg_residualnorm and the program seems to run OK but windows never open. The libraries were compiled without support for X windows. Make sure that ./configure was run with the option --with-x" and tried to reconfigure my PETSC, but nothing changed. @chrisaycock – Francielly Rodrigues May 29 '15 at 17:36
  • Did you run `make` and `make install` as well? Running `configure` will generate a new Makefile, but you'll have to rebuild the library from scratch. – chrisaycock May 29 '15 at 17:38
  • Yes. Everything done and... I see nothing. @chrisaycock – Francielly Rodrigues May 29 '15 at 17:42

1 Answers1

1

Try using "-draw_pause -1" as an argument to your PETSc program, if you're not doing it yet.

-draw_pause - Sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Daniel Plucenio
  • 111
  • 2
  • 5