34 void Foam::globalIndex::reportOverflowAndExit
37 const label prevOffset,
48 <<
"Overflow : sum of sizes exceeds labelMax (" 49 <<
labelMax <<
") after index " << idx;
51 if (prevOffset >= 0 &&
count >= 0)
54 <<
" while trying to add (" <<
count 55 <<
") to offset (" << prevOffset <<
")";
60 <<
"Please recompile with larger datatype for label." <<
nl 68 const label localSize,
70 const bool checkOverflow
86 const label len = counts.size();
90 for (label i = 0; i < len; ++i)
92 const label
count = counts[i];
96 myRange.start() = start;
99 const label prev = start;
104 reportOverflowAndExit(i, prev,
count);
119 for (label i = 0; i < myProci; ++i)
123 myRange.start() = start;
133 const label localSize,
135 const bool checkOverflow
151 const label len = counts.size();
155 for (label i = 0; i < len; ++i)
157 const label
count = counts[i];
163 const label prev = start;
168 reportOverflowAndExit(i, prev,
count);
183 for (label i = 0; i < myProci; ++i)
198 const bool checkOverflow
203 const label len = counts.
size();
210 for (label i = 0; i < len; ++i)
212 const label
count = counts[i];
216 if (checkOverflow && start <
values[i])
232 const bool checkOverflow
237 const label len = counts.
size();
244 for (label i = 0; i < len; ++i)
246 const label
count = counts[i];
253 && (start <
values[i].start())
257 reportOverflowAndExit(i,
values[i].start(),
count);
277 Foam::globalIndex::bin
282 DynamicList<label>& validBins
288 CompactListList<label> bins;
290 if (!globalIds.empty())
296 binValues = UIndirectList<label>(globalIds, order);
298 const label
id = binValues[0];
301 validBins.push_back(proci);
304 for (label i = 1; i < order.size(); i++)
306 const label
id = binValues[i];
308 if (
id < offsets[proci+1])
315 const label oldProci = proci;
319 for (label j = oldProci+1; j < proci; ++j)
321 binOffsets[j] = binOffsets[oldProci]+binSize;
323 binOffsets[proci] = i;
324 validBins.push_back(proci);
329 for (label j = proci+1; j < binOffsets.size(); ++j)
331 binOffsets[j] = binOffsets[proci]+binSize;
347 offsets_.resize(
n+1, end_value());
354 const label localSize,
376 counts[proci] = localSize;
392 const bool checkOverflow
395 const label len = counts.size();
399 offsets_.resize_nocopy(len+1);
402 for (label i = 0; i < len; ++i)
404 const label
count = counts[i];
408 if (checkOverflow && start < offsets_[i])
410 reportOverflowAndExit(i, offsets_[i],
count);
413 offsets_[len] = start;
424 if (proci >= 0 && proci+1 < offsets_.size() && len >= 0)
426 const label
delta = (len - (offsets_[proci+1] - offsets_[proci]));
431 for (label i = proci+1; i < offsets_.size(); ++i)
444 const label len = (offsets_.size() - 1);
453 for (label proci=0; proci < len; ++proci)
455 values[proci] = offsets_[proci+1] - offsets_[proci];
467 const label len = (offsets_.size() - 1);
476 for (label proci=0; proci < len; ++proci)
481 (offsets_[proci+1] - offsets_[proci])
491 const label len = (offsets_.size() - 1);
500 for (label i=0; i < len; ++i)
504 const label
count = (offsets_[i+1] - offsets_[i]);
517 (offsets_.size() < 2)
528 (offsets_.size() < 2)
534 offsets_[offsets_.size()-2],
535 offsets_[offsets_.size()-1]
552 return os << gi.offsets();
static labelList calcOffsets(const labelUList &counts, const bool checkOverflow=false)
Calculate offsets from a list of local sizes, with optional check for label overflow.
void reset(const label localSize, const label comm=UPstream::worldComm, const bool parallel=UPstream::parRun())
Reset from local size, using gather/broadcast with default/specified communicator if parallel...
void size(const label n)
Older name for setAddressableSize.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value...
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
List< labelRange > ranges() const
Return start/size ranges for all data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A range or interval of labels defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
static List< labelRange > calcRanges(const labelUList &counts, const bool checkOverflow=false)
Calculate ranges (offset/size) from a list of local sizes, with optional check for label overflow...
static bool & parRun() noexcept
Test if this a parallel run.
static List< T > allGatherValues(const T &localValue, const label communicator=worldComm)
Allgather individual values into list locations.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
labelList localSizes() const
The local sizes.
UList< label > labelUList
A UList of labels.
globalIndex() noexcept=default
Default construct (empty)
const labelList & offsets() const noexcept
Const-access to the offsets.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Istream & operator>>(Istream &, directionInfo &)
void setLocalSize(const label proci, const label len)
Alter local size for given processor.
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
A packed storage of objects of type <T> using an offset table for access.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
static labelRange calcRange(const label localSize, const label comm=UPstream::worldComm, const bool checkOverflow=false)
Calculate globally-consistent local range (offset/size) based on the local input size(s).
List< label > labelList
A List of labels.
labelRange back() const
The last offset range. It is (0,0) if globalIndex is empty.
static label calcOffset(const label localSize, const label comm=UPstream::worldComm, const bool checkOverflow=false)
Calculate globally-consistent local start offset based on the local input size(s).
label maxNonLocalSize() const
The max of localSizes, excluding current (myProcNo) rank.
void resize(const label n)
Change the number of entries (nProcs) in the offsets table. Extending will fill with empty local size...
labelRange front() const
The first offset range. It is (0,0) if globalIndex is empty.