Quantcast

add cell data to unstructured grid in time.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

add cell data to unstructured grid in time.

kayarre
I have created an unstructured grid data set that uses the SetTimeStep method to get the data for each time step. What I am having trouble doing to adding an array with calculated information and then writing the file out.

see below.


I create a variable TAWSS

TAWSS = vtk.vtkFloatArray()
TAWSS.SetNumberOfComponents(1)
TAWSS.SetNumberOfValues(calc2.GetOutput().GetNumberOfCells())
TAWSS.SetName("TAWSS")

then I calculate the average over the whole dataset, where calc2 is a vtkArrayCalculator() earlier in the pipeline.

for i in range(N):
    reader.SetTimeStep(i)
    print("Time step {0} for average calc".format(i))
    reader.Update()
    calc2.Update()
    wss_temp = calc2.GetOutput().GetCellData().GetArray("WSS")
    if ( i == 0 ):
        TAWSS.DeepCopy(wss_temp)
    else:
        array_avg(TAWSS, wss_temp, reader.GetOutput().GetNumberOfCells(), float(i+1.0))

    calc2.GetOutput().GetCellData().AddArray(TAWSS)

this doesn't add TAWSS to the outfile.

writer = vtk.vtkXMLUnstructuredGridWriter()
writer.SetFileName("calc_test.vtu")
writer.SetNumberOfTimeSteps(N)
writer.SetInputConnection(calc2.GetOutputPort())
writer.Start()

for i in range(N):
    reader.SetTimeStep(i)
    print("Writing time step {0}".format(i))
    calc2.GetOutput().GetCellData().AddArray(TAWSS)
    reader.Update()
    calc2.Update()

    writer.WriteNextTime(reader.GetTimeStep())
writer.Stop()

--
Kurt Sansom

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Loading...