57void Foam::labelRanges::insertBefore
60 const labelRange&
range
63 auto& list =
static_cast<StorageContainer&
>(*this);
66 label nElem = list.
size();
70 Info<<
"before insert "
71 << nElem <<
" elements, insert at " <<
insert <<
nl
79 Info<<
"copy between " << nElem <<
" and " <<
insert <<
nl;
82 for (label i = nElem-1; i >=
insert; --i)
86 Info<<
"copy from " << (i) <<
" to " << (i+1) <<
nl;
102void Foam::labelRanges::purgeEmpty()
104 auto& list =
static_cast<StorageContainer&
>(*this);
111 if (!list[elemi].empty())
115 list[nElem] = list[elemi];
142 else if (this->empty())
161 for (; elemi < this->size()-1; ++elemi)
164 if (currRange.
overlaps(nextRange,
true))
166 currRange.
join(nextRange);
180 else if (
range < currRange)
182 insertBefore(elemi,
range);
199 if (
range.empty() || this->empty())
218 Info<<
"Fragment removal ";
224 label lower = currRange.
first();
225 label upper =
range.first() - 1;
227 labelRange fragment(lower, upper - lower + 1);
230 lower =
range.last() + 1;
231 upper = currRange.
last();
233 currRange.
reset(lower, upper - lower + 1);
236 insertBefore(elemi, fragment);
250 else if (
range.first() <= currRange.
last())
256 Info<<
"RHS removal ";
261 const label lower = currRange.
first();
262 const label upper =
range.first() - 1;
264 currRange.
reset(lower, upper - lower + 1);
283 Info<<
"LHS removal ";
288 const label lower =
range.last() + 1;
289 const label upper = currRange.
last();
291 currRange.
reset(lower, upper - lower + 1);
321 os << static_cast<const labelRanges::StorageContainer&>(ranges);
Various functions to operate on Lists.
void clear() noexcept
Reset to zero start and zero size.
IntType last() const noexcept
The (inclusive) upper value of the range.
void clampSize() noexcept
Enforce non-negative size.
IntType first() const noexcept
The (inclusive) lower value of the range. Same as start()
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
unsigned int remove()
Remove and return the last element.
void size(const label n)
Older name for setAddressableSize.
Sums a given list of (at least two or more) fields and outputs the result into a new field,...
A range or interval of labels defined by a start and a size.
bool overlaps(const labelRange &range, bool touches=false) const
Return true if the ranges overlap.
static int debug
Debugging.
labelRange join(const labelRange &range) const
Return a joined range, squashing any gaps in between.
void reset(const label beg, const label end, const bool adjustStart) noexcept
Reset start and length, enforces non-negative size.
labelRanges()=default
Default construct.
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Istream & operator>>(Istream &, directionInfo &)
static Ostream & printRange(Ostream &os, const labelRange &range)
constexpr char nl
The newline '\n' character (0x0a)
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
#define forAll(list, i)
Loop across all elements in list.