[Paraview] Adding/Appending a new array to existing arrays

George george.gerber at gmail.com
Sun Dec 5 04:00:29 EST 2010


Hi Paraviewers,

Is it possible to add or append a newly created vtkFloatArray to an
existing set of arrays?
Please find below my attempt to append/add an array 'p2' to the existing
arrays 'U','U_0' and 'p'

#~~~~~~~~~~~~~~~~
from paraview import vtk
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

OpenFOAM = OpenFOAMReader( FileName='C:\\Users\\Public\\30x30x1.OpenFOAM' )
OpenFOAM.CellArrays = ['U', 'U_0', 'p']
OpenFOAM.MeshRegions = ['internalMesh']
MergeBlocks1 = MergeBlocks()

parray=servermanager.Fetch(MergeBlocks1).GetPointData().GetArray('p')
npts=parray.GetNumberOfTuples()
p2array = vtk.vtkFloatArray()
p2array.SetName('p2')
p2array.SetNumberOfComponents(1)
p2array.SetNumberOfTuples(npts)

for i in range(npts):
      p2array.SetValue(i, 999.9)

# Is it possible to add or append the p2array to the 'U','U_0' and 'p'
arrays?
# Maybe something like: MergeBlocks1.GetCellData().AddArray(p2array)
#~~~~~~~~~~~~~~~
Any help will be greatly appreciated.

Best regards,
George



More information about the ParaView mailing list