Making a tensor from scalars

Dear ParaView Community,

I have the components of a tensor as scalar variables, and I would like to combine them into a single tensor variable so I can use the Tensor Glyph filter. The ParaView Wiki indicates that this can be done using a Programmable Filter, but when I use the suggested script, I get the following error: “TypeError: Could not find a suitable VTK type for object.” Could someone please explain how to fix the error? Here is the script from the Wiki:

from paraview.vtk.numpy_interface import dataset_adapter as dsa
import numpy

def make_tensor(xx,yy,zz, xy, yz, xz):
    t = numpy.vstack([xx,yy,zz,xy, yz, xz]).transpose().view(dsa.VTKArray)
    t.DataSet = xx.DataSet
    t.Association = xx.Association
    return t

xx = inputs[0].PointData["sigma_xx"]
yy = inputs[0].PointData["sigma_yy"]
zz = inputs[0].PointData["sigma_zz"]
xy = inputs[0].PointData["sigma_xy"]
yz = inputs[0].PointData["sigma_yz"]
xz = inputs[0].PointData["sigma_xz"]
output.PointData.append(make_tensor(xx,yy,zz,xy,yz,xz), "tensor")

Best regards,

Can you share your input data ?

You need to make sure that your data contains sigma_xx and other arrays.


I have the same problem as Mike described. Using

output.PointData.append(xx, “test”)

is working so I am sure that the data is called successfully. However, I am not able to create a tensor using the function from the Wiki.

Best Regards


Can you share the code that is not working in your case ?

I had the same issue as Lennart. Figured out it was related to the input data being a vtkMultiBlockDataSet. Adding a MergeBlocks filter helped.