[vtkusers] MPI application writing PVTI
Berk Geveci
berk.geveci at kitware.com
Wed Jun 3 10:33:02 EDT 2015
Hi Alejandro,
(I CCed the mailing list to share the knowledge)
(Note that you need VTK 6.2 or later for what I am about to describe.)
What you have is almost correct. You just need a way for the whole extent
information to get to the writer. So do this:
vtkNew<vtkTrivialProducer> tp;
tp->SetOutput(imageData);
tp->SetWholeExtent(0, msx-1, 0, msy-1, 0, msz-1);
writer->SetInputConnection(tp->GetOutputPort());
By the way, SetInputData() does almost exactly this except that it has no
way of setting the whole extent.
Best,
-berk
On Tue, Jun 2, 2015 at 12:28 PM, Alejandro Fernández <
alejandro.fernandez at bsc.es> wrote:
> Thanks for your answer!
>
> I used the vtkXMLPImageDataWriter to write my .pvti file only with MPI
> process 0. However, I can not find a way to specify the whole extent of the
> .pvti file separately from the extent of each piece. My domains are
> patitioned along the Z axis (third) component. But the writer seems to
> implicitly partition the Y axis and I do not know how to specify it
> separately. Please, can you tell me if there is any way to do so? Here is
> the structure of my code:
>
> vtkSmartPointer<vtkImageData> imageData =
> vtkSmartPointer<vtkImageData>::New();
> imageData->SetExtent(0, msx-1, 0, msy-1, zstart, zend); // zstart and zend
> vary depending on MPI process
> imageData->SetSpacing(hx, hy, hz);
>
> vtkSmartPointer<VtkFloatArray> sf = vtkSmartPointer<VtkFloatArray>::New();
> sf->SetNumberOfComponents(nDims);
> sf->SetNumberOfTuples(msx*msy*(zend-zstart+1));
> ... loop
> sf->SetTuple(tupleCount++, field_data);
> ...
>
> imageData->GetPointData()->AddArray(sf);
>
> vtkSmartPointer<vtkXMLPImageDataWriter> writer =
> vtkSmartPointer<vtkXMLPImageDataWriter>::New();
>
> // I would expect a way to specify the "whole extent" here
> // This does not work
> http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Removal_of_SetWholeExtent
> if (world->rank() != 0) writer->WriteSummaryFileOff();
> writer->SetNumberOfPieces(world->size());
> writer->SetEndPiece(world->rank());
> writer->SetStartPiece(world->rank());
>
> writer->SetFileName("output.pvti");
> writer->SetInputData(imageData);
> writer->Write();
>
> Thanks a lot!
>
> --
>
> Alejandro Fernández Suárez
> Computer Science Dept.
> K2M Building - Room 104 - (+34) 934 137 529
> Barcelona Supercomputing Center - CNSwww.bsc.es
>
> On 01/06/2015 19:52, Shawn Waldon wrote:
>
> One of the key things to realize about the vtkXMLP*Writers is that the
> writer makes no assumptions when used in parallel. The P is for Piece not
> Parallel, so you have to tell it how many pieces total are being written.
> You also have to tell it the start and end piece numbers for each process
> (probably just the process id). Otherwise it defaults to one total piece
> and each process thinks it is writing piece 0 so the file gets clobbered
> when all the processes try to write it. See the vtkXMLPDataWriter
> documentation [1] for details on how to set these options.
>
> HTH,
> Shawn
>
> [1]: http://www.vtk.org/doc/nightly/html/classvtkXMLPDataWriter.html
>
> On Mon, Jun 1, 2015 at 1:15 PM, Berk Geveci <berk.geveci at kitware.com>
> wrote:
>
>> The easiest thing is to use vtkXMLPImageDataWriter in parallel to write
>> an example and then to follow that template.
>>
>> Best,
>> -berk
>>
>> On Thu, May 28, 2015 at 2:20 PM, Alejandro Fernández <
>> alejandro.fernandez at bsc.es> wrote:
>>
>>> Hello everyone,
>>>
>>> I have a C++ MPI application that writes the results of a
>>> domain-decomposed mesh in different VTI files. Each process writes its own
>>> VTI file with the points corresponding to its domain. In order to group all
>>> VTI files into a single 3D image in paraview, I want to produce a single
>>> PVTI file using XMLPImageDataWriter. However, I have not found any example
>>> and do not know how to achieve this result with just the raw class method
>>> documentation.
>>>
>>> Please, can somebody provide me a C++ example or point me to the
>>> required documentation?
>>>
>>> Thank you very much, your help will be much appreciated.
>>>
>>> --
>>>
>>> Alejandro Fernández Suárez
>>> Computer Science Dept.
>>> K2M Building - Room 104 - (+34) 934 137 529
>>> <%28%2B34%29%20934%20137%20529>
>>> Barcelona Supercomputing Center - CNS
>>> www.bsc.es
>>>
>>> _______________________________________________
>>> 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 VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>>
>>
>> _______________________________________________
>> 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 VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150603/f6b03b30/attachment.html>
More information about the vtkusers
mailing list