------------------------------------------------------------------------------
| 678 | |
| 679 | //------------------------------------------------------------------------------ |
| 680 | bool vtkRedistributeDataSetFilter::RedistributePTD(vtkPartitionedDataSet* inputPDS, |
| 681 | vtkPartitionedDataSet* outputPDS, |
| 682 | const std::vector<vtkPartitioningStrategy::PartitionInformation>& info, unsigned int* ptdOffset, |
| 683 | vtkIdType* mb_offset) |
| 684 | { |
| 685 | if (!inputPDS || !outputPDS) |
| 686 | { |
| 687 | vtkErrorMacro("Either input or output PartitionedDataSet is nullptr"); |
| 688 | return false; |
| 689 | } |
| 690 | |
| 691 | // assign global cell ids to inputDO, if not present. |
| 692 | // we do this assignment before distributing cells if boundary mode is not |
| 693 | // set to SPLIT_BOUNDARY_CELLS in which case we do after the split. |
| 694 | vtkSmartPointer<vtkPartitionedDataSet> xfmedInput; |
| 695 | if (this->GenerateGlobalCellIds && this->BoundaryMode != SPLIT_BOUNDARY_CELLS) |
| 696 | { |
| 697 | xfmedInput = this->AssignGlobalCellIds(inputPDS, mb_offset); |
| 698 | } |
| 699 | else |
| 700 | { |
| 701 | xfmedInput = inputPDS; |
| 702 | } |
| 703 | |
| 704 | // We are distributing a vtkPartitionedDataSet. Our strategy is simple: |
| 705 | // we split and distribute each input partition individually. |
| 706 | // We then merge corresponding parts together to form the output partitioned |
| 707 | // dataset. |
| 708 | std::vector<vtkDataSet*> input_partitions; |
| 709 | for (unsigned int cc = 0; cc < xfmedInput->GetNumberOfPartitions(); ++cc) |
| 710 | { |
| 711 | auto ds = xfmedInput->GetPartition(cc); |
| 712 | if (ds && (ds->GetNumberOfPoints() > 0 || ds->GetNumberOfCells() > 0)) |
| 713 | { |
| 714 | input_partitions.emplace_back(ds); |
| 715 | } |
| 716 | else |
| 717 | { |
| 718 | input_partitions.emplace_back(nullptr); |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | auto controller = this->GetController(); |
| 723 | if (controller && controller->GetNumberOfProcesses() > 1) |
| 724 | { |
| 725 | unsigned int mysize = static_cast<unsigned int>(input_partitions.size()); |
| 726 | unsigned int allsize = 0; |
| 727 | controller->AllReduce(&mysize, &allsize, 1, vtkCommunicator::MAX_OP); |
| 728 | assert(allsize >= mysize); |
| 729 | input_partitions.resize(allsize, nullptr); |
| 730 | } |
| 731 | |
| 732 | if (input_partitions.empty()) |
| 733 | { |
| 734 | // all ranks have empty data. |
| 735 | return true; |
| 736 | } |
| 737 |
no test coverage detected