34 void Foam::globalIndex::reportOverflowAndExit
41 <<
"Overflow : sum of sizes exceeds labelMax (" 42 <<
labelMax <<
") after index " << idx;
44 if (!localLens.empty())
51 <<
"Please recompile with larger datatype for label." <<
nl 60 const bool checkOverflow
65 const label len = localLens.
size();
72 for (label i = 0; i < len; ++i)
75 start += localLens[i];
77 if (checkOverflow && start <
values[i])
79 reportOverflowAndExit(i, localLens);
93 const bool checkOverflow
98 const label len = localLens.
size();
105 for (label i = 0; i < len; ++i)
107 values[i].reset(start, localLens[i]);
108 start += localLens[i];
110 if (checkOverflow && start <
values[i].start())
112 reportOverflowAndExit(i, localLens);
132 Foam::globalIndex::bin
137 DynamicList<label>& validBins
143 CompactListList<label> bins;
145 if (globalIds.size())
151 binValues = UIndirectList<label>(globalIds, order);
153 const label
id = binValues[0];
156 validBins.append(proci);
159 for (label i = 1; i < order.size(); i++)
161 const label
id = binValues[i];
163 if (
id < offsets[proci+1])
170 label oldProci = proci;
174 for (label j = oldProci+1; j < proci; ++j)
176 binOffsets[j] = binOffsets[oldProci]+binSize;
178 binOffsets[proci] = i;
179 validBins.append(proci);
184 for (label j = proci+1; j < binOffsets.size(); ++j)
186 binOffsets[j] = binOffsets[proci]+binSize;
196 const label localSize,
216 localLens.resize(len,
Zero);
220 reset(localLens,
true);
233 const bool checkOverflow
236 const label len = localLens.size();
240 offsets_.resize_nocopy(len+1);
243 for (label i = 0; i < len; ++i)
246 start += localLens[i];
248 if (checkOverflow && start < offsets_[i])
250 reportOverflowAndExit(i, localLens);
253 offsets_[len] = start;
264 if (proci >= 0 && proci+1 < offsets_.size() && len >= 0)
266 const label
delta = (len - (offsets_[proci+1] - offsets_[proci]));
271 for (label i = proci+1; i < offsets_.size(); ++i)
284 const label len = (offsets_.size() - 1);
293 for (label proci=0; proci < len; ++proci)
295 values[proci] = offsets_[proci+1] - offsets_[proci];
307 const label len = (offsets_.size() - 1);
316 for (label proci=0; proci < len; ++proci)
321 (offsets_[proci+1] - offsets_[proci])
331 const label len = (offsets_.size() - 1);
340 for (label i=0; i < len; ++i)
344 const label localLen = (offsets_[i+1] - offsets_[i]);
345 maxLen =
max(maxLen, localLen);
357 return is >> gi.offsets_;
363 return os << gi.offsets_;
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...
static List< labelRange > calcRanges(const labelUList &localLens, const bool checkOverflow=false)
Calculate ranges (offset/size) from a list of local sizes, with optional check for label overflow...
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.
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< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Gather individual values into list locations.
static bool & parRun() noexcept
Test if this a parallel run.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
labelList localSizes() const
The local sizes.
UList< label > labelUList
A UList of labels.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
globalIndex() noexcept=default
Default construct (empty)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
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) is 1 for serial run.
Istream & operator>>(Istream &, directionInfo &)
void setLocalSize(const label proci, const label len)
Alter local size for given processor.
A packed storage unstructured matrix 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)
List< label > labelList
A List of labels.
static labelList calcOffsets(const labelUList &localLens, const bool checkOverflow=false)
Calculate offsets from a list of local sizes, with optional check for label overflow.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
label maxNonLocalSize() const
The max of localSizes, excluding current processor.
static constexpr const zero Zero
Global zero (0)