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

Method ComputePartition

Filters/ParallelDIY2/vtkNativePartitioningStrategy.cxx:289–362  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

287
288//------------------------------------------------------------------------------
289std::vector<vtkPartitioningStrategy::PartitionInformation>
290vtkNativePartitioningStrategy::ComputePartition(vtkPartitionedDataSetCollection* collection)
291{
292 std::vector<PartitionInformation> res;
293 if (!collection)
294 {
295 vtkErrorMacro("Collection is nullptr!");
296 return res;
297 }
298
299 if (this->LoadBalanceAcrossAllBlocks)
300 {
301 // since we're load balancing across all blocks, build cuts using the whole
302 // input dataset.
303 this->InitializeCuts(collection);
304 }
305
306 for (unsigned int part = 0, max = collection->GetNumberOfPartitionedDataSets(); part < max;
307 ++part)
308 {
309 auto inputPTD = collection->GetPartitionedDataSet(part);
310 if (!inputPTD)
311 {
312 vtkWarningMacro("Found nullptr partitioned data set");
313 continue;
314 }
315
316 if (!this->LoadBalanceAcrossAllBlocks)
317 {
318 // when not load balancing globally, initialize cuts per partitioned
319 // dataset.
320 this->InitializeCuts(inputPTD);
321 }
322
323 for (unsigned int cc = 0; cc < inputPTD->GetNumberOfPartitions(); ++cc)
324 {
325 auto ds = inputPTD->GetPartition(cc);
326 if (ds && (ds->GetNumberOfPoints() > 0 || ds->GetNumberOfCells() > 0))
327 {
328 res.emplace_back(
329 ::CutsToPartition(ds, this->Cuts, this->AssignBoundaryCellsToSmallestRegionId));
330 }
331 else
332 {
333 res.emplace_back();
334 }
335 }
336 auto controller = this->GetController();
337 if (controller && controller->GetNumberOfProcesses() > 1)
338 {
339 vtkIdType locsize = static_cast<vtkIdType>(res.size());
340 vtkIdType allsize = 0;
341 controller->AllReduce(&locsize, &allsize, 1, vtkCommunicator::MAX_OP);
342 res.resize(allsize);
343 }
344 }
345
346 auto controller = this->GetController();

Callers 1

RequestDataMethod · 0.80

Calls 15

InitializeCutsMethod · 0.95
CutsToPartitionFunction · 0.85
GetPartitionedDataSetMethod · 0.80
GetNumberOfProcessesMethod · 0.80
transformFunction · 0.50
GetNumberOfPartitionsMethod · 0.45
GetPartitionMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetNumberOfCellsMethod · 0.45
emplace_backMethod · 0.45
GetControllerMethod · 0.45

Tested by

no test coverage detected