[vtkusers] Proper use of vtkXMLPRectilinearGGridWriter with MPI

Guillaume Tauzin guillaumetauzin.ut at gmail.com
Thu Jun 30 19:52:38 EDT 2016


/Hi,

I am working on a C++ CFD parallel code on HPC architecture for
vizualization with Paraview and I would like to use the vtk C++ library
along with MPI. I have been trying to use the vtkXMLPRectilinearGridWriter
without any success so far. I encountered the following problems:
- The extent of the piece in the .pvtr file and of each .vtr file is wrong
- When I correct the extents manually, I cannot open it in paraview as it
seems it cannot properly represent the boundaries between each piece.

Below is a small test code:

Please note that locatl dimension dimX_l = dimX_g / mpi_size and dimY_l,
dimZ_l = dimY_g, dimZ_g (1D domain partitioning)

void writePVTR(const int mpi_rank, const int mpi_size, std::string&
fileName,
  vtkSmartPointer<vtkDoubleArray> scalarArray) {

  int startX = mpi_rank * dimX_l;
  std::cout << startX << std::endl;

vtkSmartPointer<vtkRectilinearGrid> rectilinearGrid =
    vtkSmartPointer<vtkRectilinearGrid>::New();

 rectilinearGrid->SetDimensions(dimX_l, dimY_l, dimZ_l);
 rectilinearGrid->SetExtent(startX, startX+dimX_l-1, 0, dimY_l-1, 0,
dimZ_l-1);

  rectilinearGrid->GetPointData()->AddArray(scalarArray);

  vtkSmartPointer<vtkDoubleArray> xArray =
    vtkSmartPointer<vtkDoubleArray>::New();
  xArray->SetName("X");
  for(unsigned int iX = startX; iX < startX+dimX_l; ++iX) {
    xArray->InsertNextValue(iX);
  }
  rectilinearGrid->SetXCoordinates(xArray);

  vtkSmartPointer<vtkDoubleArray> yArray =
    vtkSmartPointer<vtkDoubleArray>::New();
  yArray->SetName("Y");
  for(unsigned int iY = 0; iY < dimY_l; ++iY) {
    yArray->InsertNextValue(iY);
  }
  rectilinearGrid->SetYCoordinates(yArray);

  vtkSmartPointer<vtkDoubleArray> zArray =
    vtkSmartPointer<vtkDoubleArray>::New();
  zArray->SetName("Z");
  for(unsigned int iZ = 0; iZ < dimZ_l; ++iZ) {
    zArray->InsertNextValue(iZ);
  }
  rectilinearGrid->SetZCoordinates(zArray);

  std::string parallel_fileName = fileName + ".pvtr";
  vtkSmartPointer<vtkXMLPRectilinearGridWriter> pwriter =
     vtkSmartPointer<vtkXMLPRectilinearGridWriter>::New();
   pwriter->SetNumberOfPieces(mpi_size);
   pwriter->SetStartPiece(0);
   pwriter->SetEndPiece(mpi_size-1);
   pwriter->SetFileName(parallel_fileName.c_str());
   pwriter->SetInputData(rectilinearGrid);
   pwriter->Write();

}

Does anyone have insights on how to use vtkXMLPRectilinearGridWriter with
MPI properly? If anyone has any working example and would like to share,
that would be greatly appreciated

Thank you for your help,
Guillaume

-- 

   - Guillaume
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160701/0b8893a5/attachment.html>


More information about the vtkusers mailing list