[vtkusers] Saving multiple time steps in a vtkXMLStructuredGrid file ...

Meehan, Bernard MEEHANBT at nv.doe.gov
Thu Jul 23 14:07:53 EDT 2015


I’ve looked all over the wiki, and all of the books that I have, and I
just can’t figure this out. Was vtkXMLStructuredGrid just plain not
designed to handle time?

In the vts file, I can see that the time steps are saved: 0.0, 0.1, 0.2,
just like I wrote them, but when I load them into ParaView, they show up
as 0, 1, 2.

In the file it seems to record three separate time steps, but it calls
them all TimeStep=“0”

I get the feeling that I am leaving something simple out, any help would
be appreciated.

On 7/8/15, 8:02 AM, "Meehan, Bernard" <MEEHANBT at nv.doe.gov> wrote:

>I was hoping to be able to write a scalar field that changed over time to
>a vtkXMLStructuredGridFile, following the example on this thread:
>http://public.kitware.com/pipermail/vtkusers/2012-November/077262.html
>
>But when I examined my ³*vts² file, the scalar function wasn¹t written to
>a different time step. I¹d be happy to turn this into an example on the
>wiki if I could get it to work Š
>
>import vtk
>
>NX = 10
>NY = 10
>NZ = 10
>
>#-------------------------------Create your
>Grid-------------------------------#
>pts = vtk.vtkPoints()
>for i in range(NX):
>  for j in range(NY):
>    for k in range(NZ):
>      pts.InsertNextPoint(i, j, k)
>
>sg = vtk.vtkStructuredGrid()
>sg.SetDimensions(NX, NY, NZ)
>sg.SetPoints(pts)
>
>f1 = vtk.vtkDoubleArray()
>f1.SetName("Function 1")
>for i in range(NX):
>  for j in range(NY):
>    for k in range(NZ):
>      f1.InsertNextValue(i+j+k)
>sg.GetPointData().AddArray(f1)
>
>#----------------------------------Save
>File-----------------------------------#
>w = vtk.vtkXMLStructuredGridWriter()
>w.SetFileName("test.vts")
>w.SetInputData(sg)
>w.SetDataModeToAscii()
>w.SetCompressorTypeToNone()
>w.SetNumberOfTimeSteps(3)
>
>w.Start()
>w.WriteNextTime(0.0)
>w.WriteNextTime(0.1)
>
># I wanted to see if I could change "Function 1" at the third time step,
>but
># when I look at the file that is written, the time step for this never
>seems
># to change?
>
>f1 = vtk.vtkDoubleArray()
>f1.SetName("Function 1")
>for i in range(NX):
>  for j in range(NY):
>    for k in range(NZ):
>      f1.InsertNextValue(-(i+j+k))
>sg.GetPointData().AddArray(f1)
>sg.Modified()
>
>w.WriteNextTime(0.2)
>w.Stop()
>



More information about the vtkusers mailing list