[Paraview] vtkTransmitImageDataPiece question
Jeff Becker
jeffrey.c.becker at nasa.gov
Tue Aug 4 14:14:06 EDT 2015
Hi. I'm trying to run a Python Programmable source across four nodes
(started with mpirun -np 4 pvserver). My script contains the following
code, but the output looks wrong, so I'm not sure if the extents are
right. The partitioning among nodes is correct (using processId
filter). Also I'm careful to set Output Data Set Type to vtkImageData.
import vtk
import vtk.util.numpy_support as ns
contr = vtk.vtkMultiProcessController.GetGlobalController()
nranks = contr.GetNumberOfProcesses()
rank = contr.GetLocalProcessId()
...
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
updateExtent = [executive.UPDATE_EXTENT().Get(outInfo, i) for i in
xrange(6)]
imageData = self.GetOutput()
imageData.SetExtent(updateExtent)
myout = ns.numpy_to_vtk(bmag.ravel(),1,vtk.VTK_FLOAT)
myout.SetName("B field magnitude")
imageData.GetPointData().SetScalars(myout)
tp = vtk.vtkTrivialProducer()
tp.SetOutput(imageData)
tp.SetWholeExtent(0, mesh.MX-1, 0, mesh.MY-1, 0, mesh.MZ-1)
xmit = vtk.vtkTransmitImageDataPiece()
xmit.SetInputConnection(tp.GetOutputPort())
xmit.UpdateInformation()
xmit.SetUpdateExtent(rank, nranks, 0)
xmit.Update()
For completeness, here is my requestInformation script (mesh has
dimensions, and coordinate arrays for each of X,Y,Z)
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
outInfo.Set(vtk.vtkAlgorithm.CAN_PRODUCE_SUB_EXTENT(), 1)
outInfo.Set(executive.WHOLE_EXTENT(), 0, mesh.MX-1, 0, mesh.MY-1, 0,
mesh.MZ-1)
xspacing = (mesh.xcoords[-1] - mesh.xcoords[0])/mesh.MX
yspacing = (mesh.ycoords[-1] - mesh.ycoords[0])/mesh.MY
zspacing = (mesh.zcoords[-1] - mesh.zcoords[0])/mesh.MZ
outInfo.Set(vtk.vtkDataObject.SPACING(), xspacing, yspacing, zspacing)
This is what I've been able to come up with after spending much time
reading documentation and examples, but I've obviously missed something.
Please advise. Thanks.
-jeff
More information about the ParaView
mailing list