12#ifndef vtkBlockDistribution_h
13#define vtkBlockDistribution_h
15#include "vtkABINamespace.h"
18VTK_ABI_NAMESPACE_BEGIN
86 return (this->NumElements / this->NumProcessors) +
87 (rank < this->NumElements % this->NumProcessors ? 1 : 0);
94 vtkIdType smallBlockSize = this->NumElements / this->NumProcessors;
95 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
96 vtkIdType cutoffIndex = cutoffProcessor * (smallBlockSize + 1);
98 if (globalIndex < cutoffIndex)
100 return globalIndex / (smallBlockSize + 1);
104 return cutoffProcessor + (globalIndex - cutoffIndex) / smallBlockSize;
120 vtkIdType estimate = rank * (this->NumElements / this->NumProcessors + 1);
121 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
122 if (rank < cutoffProcessor)
128 return estimate - (rank - cutoffProcessor);
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.