[Paraview] vtkTransmitImageDataPiece question

Jeff Becker jeffrey.c.becker at nasa.gov
Fri Aug 7 14:22:15 EDT 2015


Hi again. I have a quick question below.

On 08/07/2015 10:47 AM, Jeff Becker wrote:
> Hi Berk,
>
> On 08/07/2015 10:08 AM, Berk Geveci wrote:
>> Hey Jeff,
>>
>> Can you clarify a bit? What kind of wrong is the output?
>
> I have an updated report in the mail I sent to the list on Wednesday. 
> I will forward you that directly.  Please see updated code in that 
> mail. Right now, if I run my script on two processors, it looks like 
> both processors get the same half of the data.
>
> In the meantime, I will try to incorporate your suggestion below. Thanks.

In your version of my code below, you commented out the line:

imagedata = self.GetOutput()

I was using the example in:

http://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters#Producing_Image_Data_.28Source.29

Instead should I generate a new vtkImageData instance?


Thanks again,

-jeff
>
> -jeff
>>
>> 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 <mailto: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 <http://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
>>
>>
>
>
>
> _______________________________________________
> 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/f2c1c575/attachment.html>


More information about the ParaView mailing list