[Paraview] Assistance with programmable filter

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Tue Dec 3 22:28:27 EST 2013


Peter,

You may want to use Python Calculator
(http://paraview.org/Wiki/index.php?title=ParaView/Users_Guide/Python_Calculator)
instead. It'll take care of the the VTK data set iteration related
logic for you and you can just concentrate on the expression.

Utkarsh

On Fri, Nov 29, 2013 at 11:32 AM, Peter A. Gustafson
<peter.gustafson at wmich.edu> wrote:
> Hi all,
>
> I'm working with an exodus file which has stress (S) as a 6 component array
> (obviously a symmetric rank 2 tensor in reality).  I want to find the
> principal stresses and directions and think a programmable filter is the
> best way to do it.
>
> I have tried many variations on the code below without success. Could
> someone point me to a similar example?
>
> Thanks,
> Pete
>
>
> My code is:
> -----
> def process_block(input_block, output_block):
>  S = input_block.PointData['S']
>  #SP =
> eigenvalue(array([[S[:,0],S[:,3],S[:,5],S[:,3],S[:,1],S[:,4],S[:,5],S[:,4],S[:,2]]]))
>  #SP =
> eigenvalue(array([S[:,0],S[:,3],S[:,5],S[:,3],S[:,1],S[:,4],S[:,5],S[:,4],S[:,2]]))
>  SP =
> eigenvalue(array([[S[:,0],S[:,3],S[:,5]],[S[:,3],S[:,1],S[:,4]],[S[:,5],S[:,4],S[:,2]]]))
>  output_block.PointData.append(SP, "SP")
>
> from paraview.vtk.dataset_adapter import MultiCompositeDataIterator
> iter = MultiCompositeDataIterator([inputs[0], output])
>
> for input_block, output_block in iter:
>     process_block(input_block, output_block)
>
>
> ------
> The error message is:
> ------
>
> Traceback (most recent call last):
>   File "<string>", line 21, in <module>
>   File "<string>", line 16, in RequestData
>   File "<string>", line 8, in process_block
>   File "/usr/lib64/paraview-4.0/site-packages/paraview/vtk/algorithms.py",
> line 293, in eigenvalue
>     return _matrix_math_filter(narray, "Eigenvalue")
>   File "/usr/lib64/paraview-4.0/site-packages/paraview/vtk/algorithms.py",
> line 129, in _matrix_math_filter
>     dataset = narray.DataSet()
> AttributeError: 'numpy.ndarray' object has no attribute 'DataSet'
>
>
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview


More information about the ParaView mailing list