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

Method RedistributePTD

Filters/ParallelDIY2/vtkRedistributeDataSetFilter.cxx:680–863  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

678
679//------------------------------------------------------------------------------
680bool 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

Callers 1

RedistributeMethod · 0.95

Calls 15

AssignGlobalCellIdsMethod · 0.95
RedistributeDataSetMethod · 0.95
MarkValidDimensionsMethod · 0.95
ClipDataSetMethod · 0.95
MarkGhostCellsMethod · 0.95
GhostArrayNameFunction · 0.85
GetNumberOfProcessesMethod · 0.80
AddInputDataObjectMethod · 0.80
GetInputDataObjectMethod · 0.80
GetBoundaryModeMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected