Re: [Paraview] Assemble Variables into Tensor

2017-11-30 Thread Utkarsh Ayachit
You're most welcome :).

Utkarsh

On Thu, Nov 30, 2017 at 10:20 AM, Nicholas Richmond
 wrote:
> 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
>  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
>>  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 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
>>>
>>
>
___
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


Re: [Paraview] Assemble Variables into Tensor

2017-11-30 Thread Nicholas Richmond
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.ayac...@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.richm...@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
>> 
>>  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
>>
>>
>
___
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


Re: [Paraview] Assemble Variables into Tensor

2017-11-29 Thread Utkarsh Ayachit
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.richm...@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
> 
>  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
>
>
___
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