28#ifndef vtkBlockDistribution_h
29#define vtkBlockDistribution_h
98 return (this->NumElements / this->NumProcessors) +
99 (rank < this->NumElements % this->NumProcessors ? 1 : 0);
106 vtkIdType smallBlockSize = this->NumElements / this->NumProcessors;
107 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
108 vtkIdType cutoffIndex = cutoffProcessor * (smallBlockSize + 1);
110 if (globalIndex < cutoffIndex)
112 return globalIndex / (smallBlockSize + 1);
116 return cutoffProcessor + (globalIndex - cutoffIndex) / smallBlockSize;
132 vtkIdType estimate = rank * (this->NumElements / this->NumProcessors + 1);
133 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
134 if (rank < cutoffProcessor)
140 return estimate - (rank - cutoffProcessor);
A helper class that manages a block distribution of N elements of data.
vtkIdType GetGlobalIndex(vtkIdType localIndex, vtkIdType rank)
Retrieve the global index associated with the given local index on the processor with the given rank.
vtkIdType GetNumElements()
Retrieves the number of elements for which this block distribution was built.
vtkIdType GetLocalIndexOfElement(vtkIdType globalIndex)
Retrieve the local index (offset) on the processor determined by GetProcessorOfElement that refers to...
vtkIdType GetProcessorOfElement(vtkIdType globalIndex)
Retrieve the process number in [0, GetNumProcessors()) where the element with the given global index ...
vtkIdType GetNumProcessors()
Retrieves the number of processors for which this block distribution was built.
vtkIdType GetFirstGlobalIndexOnProcessor(vtkIdType rank)
Retrieve the first global index stored on the processor with the given rank.
vtkBlockDistribution(vtkIdType N, vtkIdType P)
Create a block distribution with N elements on P processors.
vtkIdType GetBlockSize(vtkIdType rank)
Get the block size for the processor with the given rank.