Hello,
I am using a programmable filter capable of reading cell centered data. It converts some arrays from cell data to point data and then it performs some calculations with the new point-based data (see code below).
However, this firstly requires sending the converted point data arrays to the output and then to call them again in order to perform further calculations with these arrays. This is not memory efficient because I only want to have the new arrays in the output (not the converted ones).
So, how can I read the new point based arrays from vtkCellDataToPointData without storing it in the output?
I provided some data in order to show this. I want only the “NewArray” in the output.
Thanks in advance!
Miguel
CellDataToPointData.pvsm (619.8 KB)
PV_ERROR_TEST.cas (298.6 KB)
PV_ERROR_TEST.dat (491.3 KB)
import vtk
use pass arrays to extract a copy with the arrays of interest
myArrays=vtk.vtkPassArrays()
myArrays.SetInputDataObject(self.GetInputDataObject(0,0))
myArrays.ClearArrays()
myArrays.AddPointDataArray(’’)
myArrays.AddCellDataArray(‘X_VELOCITY’)
myArrays.AddCellDataArray(‘Y_VELOCITY’)
myArrays.AddFieldDataArray(’’)
use CellToPoints to operate on the arrays we care about
c2p = vtk.vtkCellDataToPointData()
c2p.SetInputConnection(myArrays.GetOutputPort())
c2p.Update()
iterate over blocks and copy in the result
iter=dsa.MultiCompositeDataIterator([c2p.GetOutputDataObject(0), output])
for in_block, output_block in iter:
output_block.PointData.append(in_block.VTKObject.GetPointData().GetArray(‘X_VELOCITY’), “Vx”)
output_block.PointData.append(in_block.VTKObject.GetPointData().GetArray(‘Y_VELOCITY’), “Vy”)
Further calculation with the point data:
Vx = output_block.PointData[“Vx”]
Vy = output_block.PointData[“Vx”]
NewArray = VxVx+VyVy
output.PointData.append(NewArray, “NewArray”)