[vtkusers] vtkExodusIIReader/Writer examples in Python

Andrew.Wilkins at csiro.au Andrew.Wilkins at csiro.au
Thu Nov 14 22:35:50 EST 2013


Hi Tim,

See my code below.  My code was checking that the exodusIIWriter eliminates all side-set (etc) information if you pass it a multiblock VTK.  (If you pass it an exodus it does the correct thing.)

Code snippet:

# Read filename exo_with_ss
r_ss = vtk.vtkExodusIIReader()
r_ss.SetFileName(exo_with_ss)
r_ss.GenerateGlobalNodeIdArrayOn()
r_ss.GenerateGlobalElementIdArrayOn()
r_ss.ExodusModelMetadataOn()
r_ss.UpdateInformation()
# ensure that sidesets are actually loaded, since by default they're not
for ss_id in range(r_ss.GetNumberOfSideSetArrays()):
   r_ss.SetSideSetArrayStatus(r_ss.GetSideSetArrayName(ss_id), 1)

# translate the exodus information to multiblock vtk
r_ss.Update()
r_ss = r_ss.GetOutput()

# print some information
      for i in range(r_ss.GetNumberOfBlocks()):
         blk = r_ss.GetBlock(i)
         if blk.GetNumberOfBlocks() > 0:
            print " " + r_ss.GetMetaData(i).Get(vtk.vtkCompositeDataSet.NAME())
            for j in range(blk.GetNumberOfBlocks()):
               print "  " + blk.GetMetaData(j).Get(vtk.vtkCompositeDataSet.NAME())

# write an exodus file
writer = vtk.vtkExodusIIWriter()
writer.SetFileName(output_file)
writer.SetInputConnection(r_ss.GetProducerPort())
writer.Write()


Ph: +61 7 3327 4497.  Fax: +61 7 3327 4666
Queensland Centre for Advanced Technologies
PO Box 883, Kenmore, Qld, 4069

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Meehan, Bernard
Sent: Thursday, 14 November 2013 8:49 AM
To: vtkusers at vtk.org
Subject: [vtkusers] vtkExodusIIReader/Writer examples in Python

Hi - does anyone have Python examples of how to use vtkExodusIIReader/Writer other than the ones in the documentation?
(namely, TestContourGrid.py)

Thanks,
Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131115/c90bcd78/attachment.htm>


More information about the vtkusers mailing list