------------------------------------------------------------------------------
| 138 | |
| 139 | //------------------------------------------------------------------------------ |
| 140 | int vtkRedistributeDataSetToSubCommFilter::RequestData( |
| 141 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 142 | { |
| 143 | auto inputDO = vtkDataObject::GetData(inputVector[0], 0); |
| 144 | auto outputDO = vtkDataObject::GetData(outputVector, 0); |
| 145 | |
| 146 | if (inputDO == nullptr) |
| 147 | { |
| 148 | vtkErrorMacro("ERROR! inputDO in RequestData is null!"); |
| 149 | return -1; |
| 150 | } |
| 151 | |
| 152 | const int nProcs = this->Controller->GetNumberOfProcesses(); |
| 153 | const int myRank = this->Controller->GetLocalProcessId(); |
| 154 | |
| 155 | const int nTargetProcs = this->SubGroup->GetNumberOfProcessIds(); |
| 156 | |
| 157 | // redistribute onto all procs then aggregate onto target number of procs |
| 158 | vtkNew<vtkRedistributeDataSetFilter> rds; |
| 159 | vtkNew<vtkDIYAggregateDataSetFilter> aggregator; |
| 160 | rds->SetController(this->Controller); |
| 161 | rds->SetInputDataObject(inputDO); |
| 162 | rds->SetNumberOfPartitions(-1); |
| 163 | rds->UseExplicitCutsOff(); |
| 164 | |
| 165 | if (this->Internal->CutCachingEnabled && this->Internal->CacheValid) |
| 166 | { |
| 167 | rds->SetExplicitCuts(this->Internal->BoundingBoxCuts); |
| 168 | rds->UseExplicitCutsOn(); |
| 169 | } |
| 170 | |
| 171 | aggregator->SetNumberOfTargetProcesses(nTargetProcs); |
| 172 | aggregator->SetInputConnection(rds->GetOutputPort()); |
| 173 | aggregator->Update(); |
| 174 | |
| 175 | // get output |
| 176 | vtkSmartPointer<vtkPartitionedDataSet> apds = |
| 177 | vtkPartitionedDataSet::SafeDownCast(aggregator->GetOutputDataObject(0)); |
| 178 | vtkSmartPointer<vtkMultiBlockDataSet> ambds = |
| 179 | vtkMultiBlockDataSet::SafeDownCast(aggregator->GetOutputDataObject(0)); |
| 180 | vtkSmartPointer<vtkPartitionedDataSetCollection> apdsc = |
| 181 | vtkPartitionedDataSetCollection::SafeDownCast(aggregator->GetOutputDataObject(0)); |
| 182 | vtkSmartPointer<vtkUnstructuredGrid> aug = |
| 183 | vtkUnstructuredGrid::SafeDownCast(aggregator->GetOutputDataObject(0)); |
| 184 | |
| 185 | // figure out which procs have data on them |
| 186 | std::vector<vtkIdType> pointCount(nProcs, 0); |
| 187 | vtkIdType numPoints; |
| 188 | |
| 189 | if (apds) |
| 190 | { |
| 191 | numPoints = apds->GetNumberOfPoints(); |
| 192 | } |
| 193 | else if (ambds) |
| 194 | { |
| 195 | numPoints = ambds->GetNumberOfPoints(); |
| 196 | } |
| 197 | else if (apdsc) |
nothing calls this directly
no test coverage detected