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

Method RequestData

Filters/Parallel/vtkPConvertToMultiBlockDataSet.cxx:31–83  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

29
30//----------------------------------------------------------------------------
31int vtkPConvertToMultiBlockDataSet::RequestData(
32 vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
33{
34 vtkSmartPointer<vtkPartitionedDataSetCollection> input;
35 if (auto pdc = vtkPartitionedDataSetCollection::GetData(inputVector[0], 0))
36 {
37 input = pdc;
38 }
39 else if (auto pd = vtkPartitionedDataSet::GetData(inputVector[0], 0))
40 {
41 input = vtkSmartPointer<vtkPartitionedDataSetCollection>::New();
42 input->SetPartitionedDataSet(0, pd);
43 }
44
45 const int numRanks = this->Controller ? this->Controller->GetNumberOfProcesses() : 1;
46 if (numRanks == 1 || input == nullptr || input->GetNumberOfPartitionedDataSets() == 0)
47 {
48 // nothing to do.
49 return this->Superclass::RequestData(request, inputVector, outputVector);
50 }
51
52 auto output = vtkMultiBlockDataSet::GetData(outputVector, 0);
53
54 // ensure that we have exactly the same number of partitions on all ranks.
55 vtkNew<vtkPartitionedDataSetCollection> clone;
56 clone->CompositeShallowCopy(input);
57
58 const auto count = input->GetNumberOfPartitionedDataSets();
59 std::vector<unsigned int> piece_counts(count);
60 for (unsigned int cc = 0; cc < count; ++cc)
61 {
62 piece_counts[cc] = clone->GetPartitionedDataSet(cc)
63 ? clone->GetPartitionedDataSet(cc)->GetNumberOfPartitions()
64 : 0;
65 }
66
67 std::vector<unsigned int> result(piece_counts.size());
68 this->Controller->AllReduce(
69 piece_counts.data(), result.data(), static_cast<vtkIdType>(count), vtkCommunicator::MAX_OP);
70
71 for (unsigned int cc = 0; cc < count; ++cc)
72 {
73 if (result[cc] > 0)
74 {
75 if (clone->GetPartitionedDataSet(cc) == nullptr)
76 {
77 clone->SetPartitionedDataSet(cc, vtkNew<vtkPartitionedDataSet>{});
78 }
79 clone->GetPartitionedDataSet(cc)->SetNumberOfPartitions(result[cc]);
80 }
81 }
82 return this->Execute(clone, output) ? 1 : 0;
83}
84
85//----------------------------------------------------------------------------
86void vtkPConvertToMultiBlockDataSet::PrintSelf(ostream& os, vtkIndent indent)

Callers

nothing calls this directly

Calls 13

SetPartitionedDataSetMethod · 0.80
GetNumberOfProcessesMethod · 0.80
GetPartitionedDataSetMethod · 0.80
GetDataFunction · 0.50
NewFunction · 0.50
CompositeShallowCopyMethod · 0.45
GetNumberOfPartitionsMethod · 0.45
sizeMethod · 0.45
AllReduceMethod · 0.45
dataMethod · 0.45
SetNumberOfPartitionsMethod · 0.45

Tested by

no test coverage detected