[vtkusers] is whole extent required for multiblock dataset?

Andy Bauer andy.bauer at kitware.com
Fri Jun 2 13:16:51 EDT 2017


Hi Ufuk,

If there is one vtkStructuredGrid per multi-block you don't need the whole
extent. Using a vtkStructuredGrid in a multiblock though will result in
each grid block to be considered a separate grid so if you do something
like extracting the surface it probably won't look correct unless you
generate your own ghost cells (the ghost cell generator filter in PV won't
work).

I only briefly looked through your code snippet but I suspect there's an
"off-by-1" bug in the way you're setting your point coordinates for the
structured grids but once that's fixed it will work the way you want it to.

I probably don't know your full use case but I would suggest for
non-Catalyst stuff to just avoid the multiblock here and just generate
structured grid pieces.

Best,
Andy

On Fri, Jun 2, 2017 at 8:13 AM, Ufuk Turuncoglu <ufuk.turuncoglu at itu.edu.tr>
wrote:

> Hi Again,
>
> I create following test code to write dummy data (checkerboard with 0 and
> 1) using vtkStructuredGrid in multiblock format. Without extent in left and
> top of the tiles the data looks correct but there is a gap between pieces
> (see attached screenshot). To fix the issue, i add a extra piece of code to
> overlap one row and columns (using hasLeft and hasTop control). The problem
> is that when i run the code with this modification, i am getting totally
> wrong grid representation (screen2). I just wonder that do i need to set
> whole extent in somewhere. I tried to add following to set whole extent to
> multiblock dataset,
>
> int extent[6] = {0, N-1, 0, N-1, 0, 0};
> mb->GetInformationObject(0)->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
> extent, 6);
>
> but it won't work as i expected. Any suggestion? Thanks.
>
> Regards,
>
> --ufuk
>
>
> #include <iostream>
> #include "mpi.h"
> #include "vtkStructuredGrid.h"
> #include "vtkSmartPointer.h"
> #include "vtkMultiBlockDataSet.h"
> #include "vtkMultiPieceDataSet.h"
> #include "vtkNew.h"
> #include "vtkXMLPMultiBlockDataWriter.h"
> #include "vtkMPIController.h"
> #include "vtkDoubleArray.h"
> #include "vtkDataSet.h"
> #include "vtkPointData.h"
> #include "vtkInformation.h"
> #include "vtkStreamingDemandDrivenPipeline.h"
>
> using namespace std;
>
> // global variables
> int const N = 10;
> int const tileX = 2;
> int const tileY = 2;
>
> int main(int argc, char** argv) {
>   // initialize MPI
>   MPI_Init(NULL, NULL);
>
>   // setup global controller, true means initialized externally
>   vtkNew<vtkMPIController> controller;
>   controller->Initialize(&argc, &argv, true);
> vtkMultiProcessController::SetGlobalController(controller.Get());
>
>   // get number of processor and rank
>   int nproc, myid;
>   MPI_Comm_size(MPI_COMM_WORLD, &nproc);
>   MPI_Comm_rank(MPI_COMM_WORLD, &myid);
>
>   // create 2d decomposition parameters
>   bool hasLeft = false, hasTop = false;
>   if (myid%tileX == 0) hasLeft = true;
>   if (myid/tileY == 0) hasTop = true;
>
>   int istr = myid%tileX*N/tileX;
>   int iend = istr+N/tileX-1;
>   if (hasLeft) iend = iend+1;
>   int jstr = myid/tileX*N/tileY;
>   int jend = jstr+N/tileY-1;
>   if (hasTop) jend = jend+1;
>   int size = (iend-istr+1)*(jend-jstr+1);
>   //cout << myid << " of " << nproc << " " << boolalpha << hasLeft << " "
> << hasTop << endl;
>   //cout << myid << " " << istr << " " << iend << " " << jstr << " " <<
> jend << endl;
>
>   // create structured grid
>   vtkSmartPointer<vtkStructuredGrid> grid = vtkSmartPointer<vtkStructuredG
> rid>::New();
>
>   // define grid coordinates
>   vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
>   points->SetNumberOfPoints(size);
>
>   int id = 0;
>   for (int i = istr; i <= iend; i++) {
>     for (int j = jstr; j <= jend; j++) {
>       points->SetPoint(id, i, j, 0);
>       id = id+1;
>     }
>   }
>
>   grid->SetPoints(points);
>   grid->SetExtent(istr, iend, jstr, jend, 0, 0);
>   points->Delete();
>
>   // add field, checkerboard type data with full of 0/1
>   vtkSmartPointer<vtkDoubleArray> field = vtkSmartPointer<vtkDoubleArray
> >::New();
>   field->SetName("dummy");
>   field->SetNumberOfComponents(1);
>   field->SetNumberOfValues(size);
>
>   id = 0;
>   for (int i = istr; i <= iend; i++) {
>     for (int j = jstr; j <= jend; j++) {
>       int val = (i+j)%2 ? 0 : 1;
>       field->SetValue(id, val);
>       id = id+1;
>     }
>   }
>
>   // create multi block grid
>   vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New();
>   vtkNew<vtkMultiPieceDataSet> mpds;
>   mpds->SetNumberOfPieces(nproc);
>   mpds->SetPiece(myid, grid.GetPointer());
>   mb->SetNumberOfBlocks(1);
>   mb->SetBlock(0, mpds.GetPointer());
>
>   // add field
>   vtkDataSet *ds = vtkDataSet::SafeDownCast(mpds->GetPiece(myid));
>   ds->GetPointData()->AddArray(field);
>
>   // create a writer
>   vtkSmartPointer<vtkXMLPMultiBlockDataWriter> mbw =
> vtkSmartPointer<vtkXMLPMultiBlockDataWriter>::New();
>   mbw->SetFileName("test.vtm");
>   mbw->SetDataModeToAscii();
>   mbw->SetInputData(mb);
>   mbw->Write();
>
>   // finalize the MPI environment.
>   MPI_Finalize();
>
>   return 0;
> }
>
> _______________________________________________
> 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/20170602/3a595ded/attachment.html>


More information about the vtkusers mailing list