[petsc-users] PETSc recommended visualization packages

Matthew Knepley knepley at gmail.com
Thu Jul 7 13:14:18 CDT 2011


On Thu, Jul 7, 2011 at 5:12 PM, Ethan Coon <ecoon at lanl.gov> wrote:

> Hmm, I've been tricked apparently.  What I thought was PETSc writing out
> VTK was actually PFLOTRAN writing out VTK from PETSc data structures.
>

PETSc will write out VTK if you

  a) set the PETSC_VIEWER_ASCII_VTK format

  b) view the DA first and then Vecs

   Matt


> On a day-to-day basis I tend to use HDF5, and I've checked that that
> does, in fact, work with only PETSc, and only a few lines of PETSc.
> Follow/run example:
>
>
> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/dm/da/examples/tutorials/ex9.c.html
>
> Then load that in python with h5py and view with matplotlib:
>
> In [1]: import h5py
>
> In [2]: ex9 = h5py.File('hdf5output')
>
> In [3]: ex9
> Out[3]: <HDF5 file "hdf5output" (mode r+, 142.7k)>
>
> In [4]: ex9.keys()
> Out[4]: ['Vec_0x84000000_0']
>
> In [5]: vec = ex9[ex9.keys()[0]]
>
> In [6]: vec
> Out[6]: <HDF5 dataset "Vec_0x84000000_0": shape (90, 100, 2), type
> "<f8">
>
> In [7]: vec.shape  # vec was created from a 2D DA, size (90,100), with 2
> dofs
> Out[7]: (90, 100, 2)
>
> In [8]: from matplotlib import pyplot as plt
>
> In [9]: plt.imshow(vec[:,:,0].transpose(), origin='lower')
> Out[9]: <matplotlib.image.AxesImage object at 0x2310850>
>
> In [10]: plt.colorbar()
> Out[10]: <matplotlib.colorbar.Colorbar instance at 0x2313320>
>
> In [11]: plt.show()
>
>
> The downside of this option is that, in order for hdf5 files to work in
> anything but python (which is smart enough to use introspection on the
> file itself) you need a special viewer (the VisIt people call this a
> "flavor" of HDF5), see
>
> http://visitusers.org/index.php?title=VisIt_and_HDF5
>
> These work on both VisIt and Paraview, but I've never tried to write one
> myself, so I don't know how ugly they are.  They basically specify the
> layout of the hdf5 file.
>
> Note that if you go with the HDF5 option, you'll likely want to move to
> petsc-dev, which includes more HDF5 functionality, such as groups.
>
> Ethan
>
>
> On Thu, 2011-07-07 at 08:21 -0600, Andrew T Barker wrote:
> > > Should PETSc ship some Python code to
> > > read IS's, Vec's, Mat's in binary format?
> >
> > Yes.  Please.
> >
> > I have played with matplotlib some to view Petsc output (vtk), with mixed
> results.  I wonder if Ethan would be willing to share an example or two?
> >
> > Best,
> >
> > Andrew
>
> --
> ------------------------------------
> Ethan Coon
> Post-Doctoral Researcher
> Applied Mathematics - T-5
> Los Alamos National Laboratory
> 505-665-8289
>
> http://www.ldeo.columbia.edu/~ecoon/
> ------------------------------------
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110707/c55b4af7/attachment.htm>


More information about the petsc-users mailing list