54 <<
"Perform -= on self: clears all bits" <<
nl;
71 for (label blocki = 0; blocki < nblocks; ++blocki)
73 blocks_[blocki] &= ~rhs[blocki];
90 <<
"Perform &= on self: ignore" <<
nl;
100 else if (other.
none())
108 const label origSize(size());
109 const label otherSize(other.
size());
111 if (origSize > otherSize)
120 const label nblocks = num_blocks(std::min(origSize, otherSize));
123 for (label blocki = 0; blocki < nblocks; ++blocki)
125 blocks_[blocki] &=
rhs[blocki];
142 <<
"Perform |= on self: ignore" <<
nl;
147 else if (other.
none())
157 if (otherMax >= size())
165 const label nblocks = num_blocks(std::min(size(), other.
size()));
168 for (label blocki = 0; blocki < nblocks; ++blocki)
170 blocks_[blocki] |=
rhs[blocki];
187 <<
"Perform ^= on self: clears all bits" <<
nl;
193 else if (other.
none())
203 if (otherMax >= size())
211 const label nblocks = num_blocks(std::min(size(), other.
size()));
214 for (label blocki = 0; blocki < nblocks; ++blocki)
216 blocks_[blocki] ^=
rhs[blocki];
238 const label len = addr.
size();
240 for (label i = 0; i < len; ++i)
242 set(i, bitset.
get(addr[i]));
252 const label len =
range.size();
254 for (label i = 0; i < len; ++i)
283 unsigned bitIdx = 0u;
284 auto* packed = blocks_.data();
287 for (
const auto b : bools)
291 *packed |= (1u << bitIdx);
305 if (size() && other.
size())
307 const label nblocks = num_blocks(std::min(size(), other.
size()));
310 for (label blocki = 0; blocki < nblocks; ++blocki)
312 if (
bool(blocks_[blocki] &
rhs[blocki]))
355 unsigned int bblock = slice.
begin_value() / elem_per_block;
356 unsigned int bmask = slice.
begin_value() % elem_per_block;
359 unsigned int eblock = slice.
end_value() / elem_per_block;
360 unsigned int emask = slice.
end_value() % elem_per_block;
363 if (bmask) bmask = mask_lower(bmask);
364 if (emask) emask = mask_lower(emask);
366 if (bblock == eblock)
374 blocks_[bblock] |= (emask^bmask);
382 blocks_[bblock] |= (~bmask);
387 for (
unsigned blocki = bblock; blocki < eblock; ++blocki)
389 blocks_[blocki] = (~0u);
420 const label orig = size();
435 unsigned int bblock = slice.
begin_value() / elem_per_block;
436 unsigned int bmask = slice.
begin_value() % elem_per_block;
439 unsigned int eblock = slice.
end_value() / elem_per_block;
440 unsigned int emask = slice.
end_value() % elem_per_block;
443 if (bmask) bmask = mask_lower(bmask);
444 if (emask) emask = mask_lower(emask);
446 if (bblock == eblock)
455 blocks_[bblock] &= (~(emask^bmask));
463 blocks_[bblock] &= (bmask);
468 for (
unsigned blocki = bblock; blocki < eblock; ++blocki)
470 blocks_[blocki] = (0u);
486 const label total =
any() ?
count() : 0;
498 const label nblocks = num_blocks(size());
499 for (label blocki = 0; blocki < nblocks; ++blocki)
501 unsigned int blockval = blocks_[blocki];
505 for (label
pos = (blocki * elem_per_block); blockval; ++
pos)
514 if (nItem == total)
break;
528 const label nblocks = num_blocks(size());
529 for (label blocki = 0; blocki < nblocks; ++blocki)
531 label
pos = (blocki * elem_per_block);
535 unsigned int blockval = blocks_[blocki];
573 Foam::bitSet& bitset,
579 using namespace Foam;
587 bool bcastContent(
true);
591 int64_t count_size[2] = { 0, 0 };
596 count_size[0] =
static_cast<int64_t
>(
bitset.
count());
597 count_size[1] =
static_cast<int64_t
>(
bitset.
size());
610 if (count_size[0] == 0)
613 bcastContent =
false;
635 std::pair<int,int> communicator_root,
639 int comm = communicator_root.
first;
640 int root = communicator_root.second;
644 broadcast_bitSet(*
this, comm, root, syncSizes);
651 if (communicator < 0)
665 if (communicator < 0)
675 const label origSize(size());
681 int64_t commonSize(size());
701 clear_trailing_bits();
714 if (communicator < 0)
732 int64_t commonSize(size());
764 if (communicator < 0)
776 allValues.
set(0, localValue);
809 if (communicator < 0)
822 allValues.
broadcast(communicator,
false);
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Macros for easy insertion into run-time selection tables.
bool empty() const noexcept
True if range is empty (zero-sized).
IntType begin_value() const noexcept
The value at the beginning of the range - same as min(), start().
IntType end_value() const noexcept
The value 1 beyond the end of the range.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
block_type * data() noexcept
A pointer to the raw storage.
static constexpr block_type mask_lower(unsigned elementOffset)
block_container blocks_
The blocks of raw data.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void clear_trailing_bits()
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
constexpr PackedList() noexcept
static constexpr unsigned elem_per_block
The number of elements stored per data block.
static constexpr label num_blocks(label numElem) noexcept
label size() const noexcept
void clear()
Clear the list, i.e. set addressable size to zero.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static void mpiGather(const Type *sendData, Type *recvData, int count, const int communicator=UPstream::worldComm)
Receive identically-sized (contiguous) data from all ranks.
static void mpiAllReduce(T values[], int count, const UPstream::opCodes opCodeId, const int communicator)
MPI_Allreduce (blocking) for known operators.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
@ broadcast
broadcast [MPI]
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
void fill(const bool val)
Assign all entries to the given value.
void reduceAnd(int communicator=-1, bool syncSizes=true)
Inplace bit_and parallel reduction.
label find_last() const
Locate the last bit set.
static bitSet gatherValues(bool localValue, int communicator=-1)
Gather individual values into bitSet locations.
void broadcast(int communicator=-1, bool syncSizes=true)
Broadcast the contents.
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool none() const
True if no bits in this bitset are set.
constexpr bitSet() noexcept
Default construct an empty, zero-sized bitSet.
bitSet & xorEq(const bitSet &other)
The set logical XOR.
labelList toc() const
The indices of the on bits as a sorted labelList.
void reduceOr(int communicator=-1, bool syncSizes=true)
Inplace bit_or parallel reduction.
void assign(const UList< bool > &bools)
Copy assign all entries from a list of bools.
List< bool > values() const
Return the bitset values as a boolList.
bitSet & andEq(const bitSet &other)
The set logical AND.
bitSet & orEq(const bitSet &other)
The set logical OR.
static bitSet allGather(bool localValue, int communicator=-1)
Allgather individual values into bitSet locations.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
bool intersects(const bitSet &other) const
True if any bits in the other bitset intersect (are the same).
bitSet & minusEq(const bitSet &other)
The set difference.
bool any() const
True if any bits in this bitset are set.
bitSet & extend(const label minSize)
Ensure that minSize is covered by the bitSet.
A range or interval of labels defined by a start and a size.
void adjust() noexcept
Adjust the start to avoid negative indices.
labelRange subset0(label len) const
Calculate the intersection with the given 0/size range.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
patchWriters resize(patchIds.size())
#define InfoInFunction
Report an information message using Foam::Info.
bool any(const UList< bool > &bools)
True if any entries are 'true'.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
Namespace for handling debugging switches.
dimensionedScalar pos(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
triangles reserve(surf.size())
#define FOAM_UNLIKELY(cond)