Search code examples
pythonsliceattributeerrorparaviewpvpython

AttributeError: GetNumberOfCells


Im trying to extract a single line concentration profile from an exodus dataset by way of a 'pvpython script'.

The procedure I'm attempting to implement was taken from here (2nd post):

http://www.cfd-online.com/Forums/paraview/96308-extracting-paraview-data-into-python-arrays.html

The code pasted below is my attempt to adapt this procedure to my problem:

import paraview
from paraview.simple import *
from paraview import servermanager
servermanager.Connect()
#paraview.simple._DisableFirstRenderCameraReset()

out_split_1_e = ExodusIIReader( FileName=['/home/kribby/Documents/projects/Inputs_and_Data/determine_kappa2/cont_OX/6/kappa0a1/out_split.1.e'] )
#~ 
SliceFile = Slice(out_split_1_e)
SliceData = paraview.servermanager.Fetch(SliceFile)

print SliceData
numCells = SliceData.GetNumberOfCells()


data=[]
for x in range(numCells):
    data.append(SliceData.GetCellData().GetArray('p').GetValue(x))

print data

When running this code I get the following error (TERMINAL PASTE):

>      Number Of Components: 0
>      Number Of Tuples: 0
>      Number Of Children: 4
>      Child 0: NULL
>      Child 1: NULL
>      Child 2: NULL
>      Child 3: NULL


>Traceback (most recent call last):
>  File "testarray.py", line 13, in <module>
>    numCells = SliceData.GetNumberOfCells()
>AttributeError: GetNumberOfCells

I can't seem to resolve this issue. Can anyone shed any light?

Thank you very much in advance.


Solution

  • Exodus Reader produces a multiblock dataset - which is a dataset comprising of other datasets.

    Try this:

    Slice(...)
    mb = MergeBlocks(...)
    # Now fetch mb instead.