[vtkusers] vtkExodusIIReader/Writer examples in Python

David Thompson david.thompson at kitware.com
Fri Nov 15 08:50:46 EST 2013


> ... The datasets that I have contain two features that I would like to get at
> - global information, like total energy input, total kinetic energy, etc.,
> that I would like to be able to graph,

Those will be read if you add:

rdr.SetAllArrayStatus(rdr.GLOBAL,1)

to the script.

> and then unstructured blocks
> hexahedrons with point and cell data that I would like to (for example) be
> able to probe with a plane. I have looked at the files with 'ncdump' but
> wasn't sure how the various structures end up the vtkExodusIIReader
> object. I could have the wrong idea about Exodus II files as well - my
> understanding of the format does not go much past "they end in .exo"

There is manual for the Exodus library API that includes some information about storage conventions on the SourceForge page:
	http://sourceforge.net/projects/exodusii/files/Documentation/Documentation/

> 
> I think I have a good-ish idea of what should be in the file, just not so
> good of an idea of how to get it and plot it, etc. If I were to have a
> wish list of things for examples it might read something like:
> 
> Print out the list of global information (like 'EKIN', the kinetic
> energy), select one and plot it in 2D.

You might look at using the vtkExtractArraysOverTime filter to get a time series of global information, but I am not sure how fast that will be. The ExodusIIReader has a mechanism called "FastPath" (you'll see it in the reader's documentation) that will extract one point- or cell-value over time, but I don't think it works for global variables -- so the reader may have to cycle through all the time steps manually to extract it.

> Print out a list of the node or cell information (like 'DENSITY'), and
> plot it in 3D.

I'm not sure what you mean by "plot it in 3-D" means... do you mean color the mesh with the variable? Or a 3-D scatter plot? There should by python examples on the VTK wiki that deal with the former. The latter is possible but not terribly straightforward.

You can list the node and cell variables for any dataset like so:

ugrid = rdr.GetOutput().GetBlock(0).GetBlock(0)
print 'Point Data:'
fields = ugrid.GetPointData()
for i in range(fields.GetNumberOfArrays()):
  print '  ' + fields.GetAbstractArray(i).GetName()
print 'Cell Data:'
fields = ugrid.GetCellData()
for i in range(fields.GetNumberOfArrays()):
  print '  ' + fields.GetAbstractArray(i).GetName()

	David


> On 11/14/13 6:47 AM, "David Thompson" <david.thompson at kitware.com> wrote:
> 
>> Hi Tim,
>> 
>>> ... does anyone have Python examples of how to use
>>> vtkExodusIIReader/Writer other than the ones in the documentation?
>>> (namely, TestContourGrid.py)
>> 
>> Not using both together, but attached is a simple reader example that
>> fetches some data and computes order statistics (quantiles) on one array.
>> You'll have to edit the "SetFileName" line to point to a checkout of the
>> ParaViewData directory. Was there some particular feature you are having
>> trouble with?
>> 
>> 	David
>> 
> 
> 



More information about the vtkusers mailing list