[vtkusers] vtkExodusIIWriter time series with vtkMultiBlockDataSet vtkTemporalDataSet

David Fuentes fuentesdt at gmail.com
Sun Apr 29 21:51:52 EDT 2012


Hi,

Are there any examples on how to create the data structures needed write a
time series of vtkMultiBlockDataSets to a single exodus file ?

I've tried storing one vtkMultiBlockDataSet per time step as
a vtkTemporalDataSet.
Another strategy, from the documentation seems to imply that the
ModelMetaData needs to be setup ?


  vtkTemporalDataSet = vtk.vtkTemporalDataSet()
  multiBlockData = {}
  for timeID in range(ntime):
      if exodusObject.IsA("vtkMultiBlockDataSet"):
        iter = exodusObject.NewIterator()
        iter.UnRegister(None)
        iter.InitTraversal()
        # loop over blocks...
        while not iter.IsDoneWithTraversal():
          curInput = iter.GetCurrentDataObject()
          curNumberPoints = curInput.GetNumberOfPoints()
          fem_point_data= curInput.GetPointData()
          DeepCopy = 1
          #print timeID,listSliceInit,curNumberPoints
          vtkOnes= vtkNumPy.numpy_to_vtk( numpy.ones(curNumberPoints ) ,
DeepCopy)
          fem_point_data.AddArray( vtkOnes )
          fem_point_data.Update()
          curInput.Update()
          iter.GoToNextItem();
      multiBlockData['%d' % timeID] = vtk.vtkMultiBlockDataSet()
      multiBlockData['%d' % timeID].DeepCopy(exodusObject)
      vtkTemporalDataSet.SetTimeStep( timeID, multiBlockData['%d' % timeID]
)
      vtkTemporalDataSet.Update()
  # write time steps
  vtkExodusIIWriter = vtk.vtkExodusIIWriter()
  vtkExodusIIWriter.SetFileName( '%s/fem_stats.e' % data_dir )
  vtkExodusIIWriter.WriteOutBlockIdArrayOn ();
  vtkExodusIIWriter.WriteOutGlobalNodeIdArrayOn ();
  vtkExodusIIWriter.WriteOutGlobalElementIdArrayOn ();
  vtkExodusIIWriter.WriteAllTimeStepsOn ();
  print "#time", vtkTemporalDataSet.GetNumberOfTimeSteps()
  vtkExodusIIWriter.SetInput( vtkTemporalDataSet )
  vtkExodusIIWriter.Update()



Thank you,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120429/75d9d6cf/attachment.htm>


More information about the vtkusers mailing list