38 const labelUList& localLens
42 <<
"Overflow : sum of sizes exceeds labelMax ("
43 <<
labelMax <<
") after index " << idx;
45 if (!localLens.empty())
52 <<
"Please recompile with larger datatype for label." <<
nl
58template<
class ListListType>
61 const ListListType& lists,
62 const bool checkOverflow
67 auto& newOffsets = compact.offsets_;
68 auto& newValues = compact.values_;
71 const label len = lists.size();
75 newOffsets.resize(len+1, Zero);
77 for (label i = 0; i < len; ++i)
79 newOffsets[i] = total;
80 total += lists[i].size();
82 if (checkOverflow && total < newOffsets[i])
84 reportOverflowAndExit(i);
87 newOffsets[len] = total;
93 newValues.resize(total);
95 auto outIter = newValues.begin();
97 for (
const auto& list : lists)
112template<
class SubListType>
116 const bool checkOverflow
128template<
class SubListType,
class Addr>
132 const bool checkOverflow
148 const label len = listSizes.
size();
152 offsets_.resize(len+1);
155 for (label i = 0; i < len; ++i)
158 total += listSizes[i];
161 if (total < offsets_[i])
163 reportOverflowAndExit(i, listSizes);
168 offsets_[len] = total;
169 values_.resize(total);
181 const label len = listSizes.
size();
185 offsets_.resize(len+1);
188 for (label i = 0; i < len; ++i)
191 total += listSizes[i];
194 if (total < offsets_[i])
196 reportOverflowAndExit(i, listSizes);
201 offsets_[len] = total;
202 values_.resize(total, val);
212 const label len = (offsets_.size() - 1);
221 for (label i=0; i < len; ++i)
225 const label localLen = (offsets_[i+1] - offsets_[i]);
226 maxLen =
max(maxLen, localLen);
240 <<
"Invalid for non-contiguous data types"
243 return this->size_bytes();
250 return labelRange(offsets_[i], offsets_[i+1] - offsets_[i]);
260 const label len = (offsets_.size() - 1);
269 for (label i=0; i < len; ++i)
271 values[i].reset(offsets_[i], (offsets_[i+1] - offsets_[i]));
281 const label len = listSizes.
size();
285 offsets_.resize(len+1);
288 for (label i = 0; i < len; ++i)
291 total += listSizes[i];
293 if (checkOverflow && total < offsets_[i])
295 reportOverflowAndExit(i, listSizes);
300 offsets_[len] = total;
301 values_.resize(total);
313 if (rowi >= 0 && rowi+1 < offsets_.size() && len >= 0)
315 const label
delta = (len - (offsets_[rowi+1] - offsets_[rowi]));
320 for (label i = rowi+1; i < offsets_.size(); ++i)
322 offsets_[i] +=
delta;
334 const label len = (offsets_.size() - 1);
343 for (label i=0; i < len; ++i)
345 values[i] = offsets_[i+1] - offsets_[i];
363 offsets_.swap(other.offsets_);
364 values_.swap(other.values_);
380 values_.transfer(list.values_);
385template<
class SubListType>
393 lists[i] = SubListType(this->localList(i));
401template<
class SubListType>
407 auto outIter = lists.
begin();
409 for (
const label i :
range)
411 *outIter = SubListType(this->localList(i));
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
List< SubListType > unpack() const
Return non-compact list of lists.
List< labelRange > ranges() const
Return start/size ranges for all sub-lists.
static CompactListList< T > pack(const UList< SubListType > &lists, const bool checkOverflow=false)
Construct by packing together the list of lists.
std::streamsize byteSize() const
void setLocalSize(const label rowi, const label len)
Alter local addressing size for given row, does not change content.
labelList localSizes() const
The local row sizes.
void swap(CompactListList< T > &other)
Swap contents.
CompactListList() noexcept=default
Default construct.
virtual bool resize()
Resize the ODE solver.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void size(const label n)
Older name for setAddressableSize.
label maxNonLocalSize() const
The max of localSizes, excluding current processor.
A range or interval of labels defined by a start and a size.
transferModelList & transfer()
Transfer.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
A template class to specify that a data type can be considered as being contiguous in memory.