[Paraview] vtkTransmitImageDataPiece question

Berk Geveci berk.geveci at kitware.com
Fri Aug 7 13:08:32 EDT 2015


Hey Jeff,

Can you clarify a bit? What kind of wrong is the output?

Also, I would probably do this a bit differently, assuming you use a newer
ParaView (>= 4.2). The issue is that vtkTransmitImageDataPiece is not a
"CAN_PRODUCE_SUB_EXTENT()" filter. Rather it is a
"CAN_HANDLE_PIECE_REQUEST()" filter. Meaning that it wants to determine the
extents of the output based on the piece request it receives. So some
changes:

* Swap CAN_PRODUCE_SUB_EXTENT() with CAN_HANDLE_PIECE_REQUEST() in request
info.
* In the main script, do something like this:

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)
# >> this probably needs to happen on rank 0 only
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()
self.GetOutput().ShallowCopy(xmit,GetOutput())

I didn't verify the code so it may need tweaking.

Best,
-berk


On Tue, Aug 4, 2015 at 2:14 PM, Jeff Becker <jeffrey.c.becker at nasa.gov>
wrote:

> 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
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150807/746e178f/attachment.html>


More information about the ParaView mailing list