Improve Documentation for vtkXMLP*Writers
I have a software that is using different types of vtkXMLPWriters and found that they would not work as the output in the parallel files was wrong. In fact it only showed the piece of processor 0. As it took me over 4 hours (incl. reading the VTK source code) to figure out how to get this to work I would like to suggest an improvement to the documentation such that users will in the future find the desired information much quicker. Now my software uses bulk standard MPI_Init() and then in the output sets up a vtkXMLPWriter (In my case * = {UnstructuredGrid, MultiBlockData, PolyData}) as follows:
vtkSmartPointer<vtkXMLPUnstructuredGridWriter> pwriter = vtkSmartPointer<vtkXMLPUnstructuredGridWriter>::New(); pwriter->SetFileName(filename); #if VTK_MAJOR_VERSION < 6 pwriter->SetInput(unstructuredGrid); #else pwriter->SetInputData(unstructuredGrid); #endif pwriter->SetNumberOfPieces(nprocs); pwriter->SetStartPiece(rank); pwriter->SetEndPiece(rank); pwriter->Write();
It was already not clear to me that the Set{Start,End}Piece function calls were required. But this information was rather easy to find. What was more difficult is the fact that vtk needs to be aware of your MPI settings. To ensure this the following code needs to be put in some sort of initializer:
vtkMPIController *vtkController = vtkMPIController::New(); vtkController->Initialize(); vtkMultiProcessController::SetGlobalController(vtkController);
The Initialize() without arguments tells VTK that it should use an existing MPI controller, i.e. the one that comes with the main software. The SetGlobalController basically tells the writers that they should use this MPI controller to do their communication. I think there are other ways to achieve the communication by using vtk functions to initialize MPI, but this might not always be feasible.
So it would be great if there is either a example that highlights this or if the documentation points towards the fact that a functioning vtkMPIController needs to be available.