------------------------------------------------------------------------------
| 92 | |
| 93 | //------------------------------------------------------------------------------ |
| 94 | int vtkStructuredGridPartitioner::RequestData(vtkInformation* vtkNotUsed(request), |
| 95 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 96 | { |
| 97 | // STEP 0: Get input object |
| 98 | vtkInformation* input = inputVector[0]->GetInformationObject(0); |
| 99 | assert("pre: input information object is nullptr" && (input != nullptr)); |
| 100 | vtkStructuredGrid* grd = |
| 101 | vtkStructuredGrid::SafeDownCast(input->Get(vtkDataObject::DATA_OBJECT())); |
| 102 | |
| 103 | // STEP 1: Get output object |
| 104 | vtkInformation* output = outputVector->GetInformationObject(0); |
| 105 | assert("pre: output information object is nullptr" && (output != nullptr)); |
| 106 | vtkMultiBlockDataSet* multiblock = |
| 107 | vtkMultiBlockDataSet::SafeDownCast(output->Get(vtkDataObject::DATA_OBJECT())); |
| 108 | assert("pre: multi-block grid is nullptr" && (multiblock != nullptr)); |
| 109 | |
| 110 | // STEP 2: Get the global extent |
| 111 | int extent[6]; |
| 112 | grd->GetExtent(extent); |
| 113 | |
| 114 | // STEP 3: Setup extent partitioner |
| 115 | vtkExtentRCBPartitioner* extentPartitioner = vtkExtentRCBPartitioner::New(); |
| 116 | assert("pre: extent partitioner is nullptr" && (extentPartitioner != nullptr)); |
| 117 | extentPartitioner->SetGlobalExtent(extent); |
| 118 | extentPartitioner->SetNumberOfPartitions(this->NumberOfPartitions); |
| 119 | extentPartitioner->SetNumberOfGhostLayers(this->NumberOfGhostLayers); |
| 120 | |
| 121 | if (this->DuplicateNodes == 1) |
| 122 | { |
| 123 | extentPartitioner->DuplicateNodesOn(); |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | extentPartitioner->DuplicateNodesOff(); |
| 128 | } |
| 129 | |
| 130 | // STEP 4: Partition |
| 131 | extentPartitioner->Partition(); |
| 132 | |
| 133 | // STEP 5: Extract partitions in a multi-block |
| 134 | multiblock->SetNumberOfBlocks(extentPartitioner->GetNumExtents()); |
| 135 | |
| 136 | // Set the whole extent of the grid |
| 137 | multiblock->GetInformation()->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), extent, 6); |
| 138 | |
| 139 | int subext[6]; |
| 140 | unsigned int blockIdx = 0; |
| 141 | for (; blockIdx < multiblock->GetNumberOfBlocks(); ++blockIdx) |
| 142 | { |
| 143 | if (this->CheckAbort()) |
| 144 | { |
| 145 | break; |
| 146 | } |
| 147 | extentPartitioner->GetPartitionExtent(blockIdx, subext); |
| 148 | |
| 149 | vtkStructuredGrid* subgrid = vtkStructuredGrid::New(); |
| 150 | subgrid->SetExtent(subext); |
| 151 |
nothing calls this directly
no test coverage detected