<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,
<div class="moz-forward-container">
<p>I'm currently trying to find a correct documentation on how to
use parallel writers provided by VTK with MPI. After something
like 2h of research on the web, here I am! Either I really don't
know how to search information, or there is no documentation at
all about how to use the parallel reader/writers of VTK... <br>
</p>
<p>My problem: I have several MPI processes (for the moment on my
machine, in local, but they will be distributed on several
machines after). Each of them owns data (points on a cubic
region) I want to gather and plot on a single graph. <br>
</p>
<p>What I tried: Assuming all the code presented below is executed
on each MPI process, and the local data of the current process
is stored in "vtkSmartPointer<vtkPolyData> data":<br>
</p>
<ul>
<li>Something I found in <a moz-do-not-send="true"
href="https://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Filters/ParallelMPI/Testing/Cxx/TestImplicitConnectivity.cxx">this
test file from VTK</a> (but seems out of date as I don't
have the method SetWriteMetaFile).<br>
vtkSmartPointer<vtkXMLPPolyDataWriter> pwriter =
vtkSmartPointer<vtkXMLPPolyDataWriter>::New();<br>
std::string parallel_filename = std::string("Dataset_") +
std::to_string(m_dataset_index) + std::string(".pvtp");<br>
<br>
pwriter->SetFileName(parallel_filename.c_str());<br>
pwriter->SetInputData(data);<br>
pwriter->Write();<br>
</li>
<li>Something I guessed from <a moz-do-not-send="true"
href="https://gerstrong.github.io/blog/2016/08/20/hacking-vtk-for-parallelisation">this
blog</a>.<br>
// And we can save it on each process<br>
std::string filename = std::string("Dataset_") +
std::to_string(m_dataset_index) + std::string("_")<br>
+ std::to_string(m_rank) +
std::string(".vtp");<br>
writer->SetFileName(filename.c_str());<br>
#if VTK_MAJOR_VERSION <= 5<br>
writer->SetInput(data);<br>
#else<br>
writer->SetInputData(data);<br>
#endif<br>
writer->Write();<br>
if(m_rank == 0) {<br>
std::string parallel_filename =
std::string("Dataset_") + std::to_string(m_dataset_index) +
std::string(".pvtp");<br>
vtkSmartPointer<vtkXMLPPolyDataWriter> pwriter =
vtkSmartPointer<vtkXMLPPolyDataWriter>::New();<br>
pwriter->SetFileName(parallel_filename.c_str());<br>
pwriter->SetNumberOfPieces(m_size);<br>
pwriter->SetStartPiece(0);<br>
pwriter->SetEndPiece(m_size-1);<br>
#if VTK_MAJOR_VERSION <= 5<br>
pwriter->SetInput(data);<br>
#else<br>
pwriter->SetInputData(data);<br>
#endif<br>
pwriter->Update();<br>
}</li>
</ul>
<p>None of them worked: the first one only create the .vtp file
for process 0 (and the .ptvp file also), and the second one
create 4 identical .tvp files (and I checked, the processes
don't have the same data).<br>
</p>
<p>So here my question: What is the correct way to use the
parallel writers of VTK?</p>
<p>Thanks for your time, I hope this was not a stupid question
easily answered by something I didn't found on the internet...</p>
</div>
</body>
</html>