------------------------------------------------------------------------------
| 305 | |
| 306 | //------------------------------------------------------------------------------ |
| 307 | int vtkHyperTreeGridRedistribute::ProcessBlock(vtkDataObject* input, vtkDataObject* outputDO) |
| 308 | { |
| 309 | // Make sure input is either a HTG or composite dataset that contains HTG pieces. |
| 310 | vtkPartitionedDataSet* inputPDS = vtkPartitionedDataSet::SafeDownCast(input); |
| 311 | this->InputHTG = vtkHyperTreeGrid::SafeDownCast(input); |
| 312 | |
| 313 | if (!inputPDS && !this->InputHTG) |
| 314 | { |
| 315 | vtkErrorMacro("Input data is neither HTG or PartitionedDataSet, cannot proceed"); |
| 316 | return 0; |
| 317 | } |
| 318 | |
| 319 | vtkHyperTreeGrid* outputHTG = vtkHyperTreeGrid::SafeDownCast(outputDO); |
| 320 | vtkPartitionedDataSet* outputPDS = vtkPartitionedDataSet::SafeDownCast(outputDO); |
| 321 | |
| 322 | if (!outputHTG && !outputPDS) |
| 323 | { |
| 324 | vtkErrorMacro("No output available. Cannot proceed with hyper tree grid algorithm."); |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | if (inputPDS && outputPDS) |
| 329 | { |
| 330 | outputPDS->CopyStructure(inputPDS); |
| 331 | |
| 332 | for (unsigned int partId = 0; partId < inputPDS->GetNumberOfPartitions(); partId++) |
| 333 | { |
| 334 | auto partHTG = vtkHyperTreeGrid::SafeDownCast(inputPDS->GetPartitionAsDataObject(partId)); |
| 335 | if (partHTG) |
| 336 | { |
| 337 | if (this->InputHTG) |
| 338 | { |
| 339 | vtkWarningMacro("Found more than one non-null HTG in the partitioned dataset for piece " |
| 340 | << this->CurrentPiece << ". Generating ghost data only for partition " << partId); |
| 341 | } |
| 342 | this->InputHTG = partHTG; |
| 343 | vtkNew<vtkHyperTreeGrid> newOutputHTG; |
| 344 | outputPDS->SetPartition(partId, newOutputHTG); |
| 345 | outputHTG = newOutputHTG; // Not dangling, outputPDS maintains a reference. |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | if (!this->InputHTG) |
| 351 | { |
| 352 | vtkWarningMacro("Incorrect HTG for piece " << this->CurrentPiece); |
| 353 | } |
| 354 | |
| 355 | // Make sure every HTG piece can be processed |
| 356 | // This way, we make sure the `ProcessTrees` function will either be executed by all ranks |
| 357 | // or by none, and avoids getting stuck on barriers. |
| 358 | int nullPiece = this->InputHTG != nullptr; |
| 359 | if (!nullPiece) |
| 360 | { |
| 361 | vtkWarningMacro("Piece " << this->CurrentPiece << " is null."); |
| 362 | } |
| 363 | |
| 364 | int allNonNull = 1; // Reduction operation cannot be done on bools |
no test coverage detected