Skip to content

Commit

Permalink
report points and cells numbers in *marching-cubes_MPI.cxx
Browse files Browse the repository at this point in the history
  • Loading branch information
romangrothausmann committed Nov 25, 2015
1 parent 2b5f29d commit f3160af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
15 changes: 11 additions & 4 deletions discrete_marching-cubes_MPI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <vtkStreamingDemandDrivenPipeline.h>//for extent
#include <vtkImageData.h>//for GetExtent()
#include <vtkImageConstantPad.h>
#include "filters_mod/VTK/Filters/General/vtkDiscreteMarchingCubes.h"
#include "filters_mod/VTK/Filters/General/vtkDiscreteMarchingCubes.h"//does not handle sub-extents of pvtp correctly, nor does vtkMarchingCubes but vtkContourFilter does (seems to be independent of vtkMarchingCubes)
#include <vtkWindowedSincPolyDataFilter.h>
#include <vtkXMLPPolyDataWriter.h>
#include <vtkFeatureEdges.h>
Expand Down Expand Up @@ -111,7 +111,9 @@ int main (int argc, char *argv[]){
discreteCubes->Update();//essential to SetUpdateExtent before on same filter

vtkIdType numCells = discreteCubes->GetOutput()->GetNumberOfCells();
vtkIdType numPoints = discreteCubes->GetOutput()->GetNumberOfPoints();
cerr << "Process (" << myId << "): "
<< "# points: " << numPoints
<< "# cells: " << numCells << endl;

writer->SetNumberOfPieces(numProcs);
Expand All @@ -136,7 +138,9 @@ int main (int argc, char *argv[]){
smoother->Update();//essential to SetUpdateExtent before on same filter

numCells = smoother->GetOutput()->GetNumberOfCells();
numPoints = smoother->GetOutput()->GetNumberOfPoints();
cerr << "Process (" << myId << "): "
<< "# points: " << numPoints
<< "# cells: " << numCells << endl;

std::stringstream ss;
Expand All @@ -146,11 +150,14 @@ int main (int argc, char *argv[]){
writer->SetFileName(ss.str().c_str());
writer->Write();

vtkIdType totalNumPoints = 0;
vtkIdType totalNumCells = 0;
controller->Reduce(&numCells, &totalNumCells, 1, vtkCommunicator::SUM_OP, 0);
controller->Reduce(&numPoints, &totalNumPoints, 1, vtkCommunicator::SUM_OP, 0);//does this stop thread 0 until totalNumCells is fully acquired? If so should only be used after all processing is done!
controller->Reduce(&numCells, &totalNumCells, 1, vtkCommunicator::SUM_OP, 0);//does this stop thread 0 until totalNumCells is fully acquired? If so should only be used after all processing is done!
if (myId == 0)
cerr << endl << "Process (" << myId << "): "
<< "Cell count after reduction: " << totalNumCells << endl;
cerr << endl << "Process (" << myId << ") total: "
<< "# points: " << totalNumPoints
<< "# cells: " << totalNumCells << endl;

controller->Finalize();

Expand Down
17 changes: 16 additions & 1 deletion marching-cubes_MPI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <vtkSmartPointer.h>
#include <vtkMPIController.h>
#include <vtkXMLImageDataReader.h>//seems to be the only reader that works, has outInfo->Set(CAN_PRODUCE_SUB_EXTENT(), 1) neither vtkMetaImageReader nor vtkPNrrdReader worked, vtkMPIImageReader (RAW) not tested
#include <vtkContourFilter.h>
#include <vtkContourFilter.h>//handles sub-extents of pvtp correctly, seems independent of vtkMarchingCubes (which does not handle sub-extents of pvtp correctly)
#include <vtkXMLPPolyDataWriter.h>

#include <vtkCallbackCommand.h>
Expand Down Expand Up @@ -83,6 +83,12 @@ int main (int argc, char *argv[]){
filter->SetUpdateExtent(0, myId, numProcs, 0);
filter->Update();

vtkIdType numCells = filter->GetOutput()->GetNumberOfCells();
vtkIdType numPoints = filter->GetOutput()->GetNumberOfPoints();
cerr << "Process (" << myId << "): "
<< "# points: " << numPoints
<< "# cells: " << numCells << endl;

vtkSmartPointer<vtkXMLPPolyDataWriter> writer= vtkSmartPointer<vtkXMLPPolyDataWriter>::New();
writer->SetInputConnection(filter->GetOutputPort());
writer->SetFileName(argv[2]);
Expand All @@ -97,6 +103,15 @@ int main (int argc, char *argv[]){
writer->AddObserver(vtkCommand::AnyEvent, eventCallbackVTK);
writer->Write();

vtkIdType totalNumPoints = 0;
vtkIdType totalNumCells = 0;
controller->Reduce(&numPoints, &totalNumPoints, 1, vtkCommunicator::SUM_OP, 0);//does this stop thread 0 until totalNumCells is fully acquired? If so should only be used after all processing is done!
controller->Reduce(&numCells, &totalNumCells, 1, vtkCommunicator::SUM_OP, 0);//does this stop thread 0 until totalNumCells is fully acquired? If so should only be used after all processing is done!
if (myId == 0)
cerr << endl << "Process (" << myId << ") total: "
<< "# points: " << totalNumPoints
<< "# cells: " << totalNumCells << endl;

controller->Finalize();

return EXIT_SUCCESS;
Expand Down

0 comments on commit f3160af

Please sign in to comment.