[Paraview] Assemble Variables into Tensor

Nicholas Richmond nicholas.richmond at maine.edu
Thu Nov 30 10:20:30 EST 2017


Hi Utkarsh,

Using the script you wrote with the Programmable Filter does the job
nicely! Thanks so much for going above and beyond to help me assemble the
arrays into a tensor. Programmable Filter never occurred to me and I am now
looking forward to exploring Chapter 13 of the Paraview Guide to see what
else I can do with it.

Many thanks,
Nick Richmond

On Wed, Nov 29, 2017 at 9:56 PM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:

> Nick,
>
> You can use the *Programmable Filter* instead with something like the
> following script as the *Script*:
>
>
> 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")
>
>
> Utkarsh
>
> On Wed, Nov 29, 2017 at 5:01 PM, Nicholas Richmond <
> nicholas.richmond at maine.edu> wrote:
>
>> Greetings,
>>
>> I have a vtk Polygonal Mesh with six separate arrays (sigma_xx, sigma_yy,
>> sigma_zz, sigma_xy, sigma_yz, sigma_xz). I'd like to assemble these into a
>> tensor so that I may apply the Tensor Glyph filter.
>>
>> After reading that the paraview.simple.TensorGlyph
>> <https://www.paraview.org/ParaView/Doc/Nightly/www/py-doc/paraview.simple.TensorGlyph.html>
>>  expects a symmetric tensor with the order XX, YY, ZZ, XY, YZ, XZ, I
>> tried to assemble the six separate arrays into a single array with the
>> Python Calculator, but have been unsuccessful.
>>
>> I've tried a variety of approaches, including:
>>
>> *Expression:* np.array([sigma_xx, sigma_yy, sigma_zz, sigma_xy,
>> sigma_yz, sigma_xz])
>> *Array Association:* Point Data
>>
>> I can make a vector of the normal stresses using the "make_vector"
>> function from paraview.vtk.numpy_interface.algorithms, but there is no
>> "make_tensor" function to assemble both normal and shear stresses into a
>> single symmetric tensor.
>>
>> Any guidance would be most appreciated.
>> Many thanks,
>> Nick Richmond
>>
>> _______________________________________________
>> 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 ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171130/2deed224/attachment.html>


More information about the ParaView mailing list