[Paraview] vtkTransmitImageDataPiece question
Berk Geveci
berk.geveci at kitware.com
Mon Aug 10 15:39:46 EDT 2015
Hi Jeff,
I commented that line out to mainly remove the SetExtent() call. When you
set the CAN_HANDLE_PIECE_REQUEST() key instead of the CAN_PRODUCE_SUB_EXTENT()
key, the filter is no longer passed an update extent local to the MPI rank
it is on. Rather it is passed a global update extent and is asked to
partition it as it sees fit. This means that you can no longer do
imageData.SetExtent(updateExtent)
Rather, you have to do:
self.GetOutput().ShallowCopy(xmit,GetOutput())
This copy will copy the extent from the xmit filter's output. The transmit
filter internally decides on a partition so you need to use that.
For reference to others that may be following this thread, I recommended to
Jeff that he uses the Nrrd reader, which uses MPI-IO to read raw files
(structured datasets). It is a more efficient approach.
Best,
-berk
On Fri, Aug 7, 2015 at 2:22 PM, Jeff Becker <jeffrey.c.becker at nasa.gov>
wrote:
> 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>
> 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
>>
>
>
>
>
> _______________________________________________
> 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/20150810/9e0a68d0/attachment.html>
More information about the ParaView
mailing list