Help with vtkInterpolateDataSetAttributes
"Andrew E. Slaughter via vtkusers" <[email protected]>
| Newsgroups | gmane.comp.lib.vtk.user |
|---|---|
| Message-ID | <[email protected]> |
I am attempting to interpolate between two ExodusII (vtkExodusIIReader) results using the vtkInterpolateDataSetAttributes, but am having trouble getting it to work. I was able to perform an interpolation that mimics the behavior with calls to vtkAbstractArray::InterpolateTuple, but this doesn’t seem like the correct solution. I have attached a script that show what I am trying to do, including what is working and what is not. I know that for this problem I could use vtkTemporalInterpolator, but for the actual problem I am trying to solve it isn’t appropriate. I am using python bindings with VTK7.1 on MacOS. I would appreciate any help I can get making this work. Thanks, Andrew _______________________________________________ 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: https://public.kitware.com/mailman/listinfo/vtkusers
input_no_adapt_out.e
(application/octet-stream, 35.7 KB) - not displayed
interpolate_data_set.py
(text/x-python-script, 2 KB)
#!/usr/bin/env python
import vtk
filename = 'input_no_adapt_out.e'
variable = 'u'
drange = [0, 10]
reader0 = vtk.vtkExodusIIReader()
reader0.SetFileName(filename)
reader0.UpdateInformation()
reader0.SetTimeStep(0)
reader0.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL, 1)
reader0.Update()
data0 = reader0.GetOutput().GetBlock(0).GetBlock(0)
print data0.GetPointData().GetAbstractArray(0).GetRange() # [0, 5]
reader1 = vtk.vtkExodusIIReader()
reader1.SetFileName(filename)
reader1.UpdateInformation()
reader1.SetTimeStep(1)
reader1.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL, 1)
reader1.Update()
data1 = reader1.GetOutput().GetBlock(0).GetBlock(0)
print data1.GetPointData().GetAbstractArray(0).GetRange() # [0, 14]
# How do I get this working?
interpolator = vtk.vtkInterpolateDataSetAttributes()
interpolator.AddInputData(reader0.GetOutput().GetBlock(0).GetBlock(0))
interpolator.AddInputData(reader1.GetOutput().GetBlock(0).GetBlock(0))
interpolator.SetT(0.5)
interpolator.Update()
print interpolator.GetOutput().GetPointData().GetAbstractArray(0)#.GetRange() # [0, 9.5]
# How do I get this working? This is what happens with the vtkInterpolateDataSetAttributes
n = data0.GetPointData().GetNumberOfTuples()
data = vtk.vtkPointData()
data.InterpolateAllocate(data0.GetPointData())
for i in xrange(n):
data.InterpolateTime(data0.GetPointData(),
data1.GetPointData(),
i,
0.5)
print data.GetAbstractArray(0).GetRange() # [0, 9.5]
# THIS WORKS!
data = vtk.vtkPointData()
data.CopyStructure(data0.GetPointData())
data.SetNumberOfTuples(n)
for i in xrange(data.GetNumberOfTuples()):
data.GetAbstractArray(0).InterpolateTuple(i,
i, data0.GetPointData().GetAbstractArray(0),
i, data1.GetPointData().GetAbstractArray(0),
0.5)
print data.GetAbstractArray(0).GetRange() # [0, 9.5]