MCPcopy Create free account
hub / github.com/Kitware/VTK / DIYAggregateDataSet

Function DIYAggregateDataSet

Filters/ParallelDIY2/Testing/Cxx/DIYAggregateDataSet.cxx:25–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include <iostream>
24
25int DIYAggregateDataSet(int argc, char* argv[])
26{
27 // This is here to avoid false leak messages from vtkDebugLeaks when
28 // using mpich. It appears that the root process which spawns all the
29 // main processes waits in MPI_Init() and calls exit() when
30 // the others are done, causing apparent memory leaks for any objects
31 // created before MPI_Init().
32 MPI_Init(&argc, &argv);
33
34 // Note that this will create a vtkMPIController if MPI
35 // is configured, vtkThreadedController otherwise.
36 vtkMPIController* contr = vtkMPIController::New();
37 contr->Initialize(&argc, &argv, 1);
38
39 int retVal = EXIT_SUCCESS;
40
41 vtkMultiProcessController::SetGlobalController(contr);
42
43 int me = contr->GetLocalProcessId();
44 if (!contr->IsA("vtkMPIController"))
45 {
46 if (me == 0)
47 {
48 std::cout << "DIYAggregateDataSet test requires MPI" << std::endl;
49 }
50 contr->Delete();
51 return EXIT_FAILURE;
52 }
53
54 int numProcs = contr->GetNumberOfProcesses();
55
56 // Create and execute pipeline
57 vtkRTAnalyticSource* wavelet = vtkRTAnalyticSource::New();
58 wavelet->UpdatePiece(me, numProcs, 0);
59 vtkDIYAggregateDataSetFilter* aggregate = vtkDIYAggregateDataSetFilter::New();
60
61 aggregate->SetInputConnection(wavelet->GetOutputPort());
62 aggregate->SetNumberOfTargetProcesses(2);
63
64 aggregate->UpdatePiece(me, numProcs, 0);
65
66 if (me % 2 == 1 && vtkDataSet::SafeDownCast(aggregate->GetOutput())->GetNumberOfPoints() != 4851)
67 {
68 vtkGenericWarningMacro("Wrong number of imagedata points on process "
69 << me << ". Should be 4851 but is "
70 << vtkDataSet::SafeDownCast(aggregate->GetOutput())->GetNumberOfPoints());
71 retVal = EXIT_FAILURE;
72 }
73 else if (me % 2 != 1 &&
74 vtkDataSet::SafeDownCast(aggregate->GetOutput())->GetNumberOfPoints() != 0)
75 {
76 vtkGenericWarningMacro("Wrong number of imagedata points on process "
77 << me << ". Should be 0 but is "
78 << vtkDataSet::SafeDownCast(aggregate->GetOutput())->GetNumberOfPoints());
79 retVal = EXIT_FAILURE;
80 }
81
82 aggregate->Delete();

Callers

nothing calls this directly

Calls 15

IsAMethod · 0.80
GetNumberOfProcessesMethod · 0.80
UpdatePieceMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
InitializeMethod · 0.45
GetLocalProcessIdMethod · 0.45
SetInputConnectionMethod · 0.45
GetOutputPortMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetOutputMethod · 0.45

Tested by

no test coverage detected