Foam::BitOps Namespace Reference

Various bit-wise operations, etc. More...

Classes

struct  bitInfo
 An (unsigned) integral type adapter, for output of bit values. More...
 

Functions

unsigned int count (const UList< bool > &bools, const bool val=true)
 Count number of 'true' entries. More...
 
bool all (const UList< bool > &bools)
 True if all entries are 'true' or if the set is empty. More...
 
bool any (const UList< bool > &bools)
 True if any entries are 'true'. More...
 
bool none (const UList< bool > &bools)
 True if no entries are 'true'. More...
 
void set (List< bool > &bools, const labelRange &range)
 Set the specified range 'on' in a boolList. More...
 
void set (labelHashSet &hashset, const labelRange &range)
 Set the specified range in a labelHashSet. More...
 
void set (bitSet &bitset, const labelRange &range)
 Forward to bitSet::set(labelRange) More...
 
void unset (List< bool > &bools, const labelRange &range)
 Unset the specified range 'on' in a boolList. More...
 
void unset (labelHashSet &hashset, const labelRange &range)
 Unset the specified range in a labelHashSet. More...
 
void unset (bitSet &bitset, const labelRange &range)
 Forward to bitSet::unset(labelRange) More...
 
template<class UIntType >
unsigned int bit_count (UIntType x)
 Count arbitrary number of bits (of an integral type) More...
 
template<>
unsigned int bit_count (uint32_t x)
 Count bits in a 32-bit value (Hamming weight method) More...
 
template<>
unsigned int bit_count (uint64_t x)
 Count bits in a 64-bit value (Hamming weight method) More...
 
template<class UIntType , unsigned BitWidth>
UIntType repeat_value (unsigned val)
 Repeat a value of the given BitWidth into the destination output type. More...
 
template<class UIntType >
Ostreamprint (Ostream &os, UIntType value, char off='0', char on='1')
 Print 0/1 bits in the (unsigned) integral type. More...
 

Detailed Description

Various bit-wise operations, etc.

The population count uses the Hamming weight (http://en.wikipedia.org/wiki/Hamming_weight).

Function Documentation

◆ count()

unsigned int Foam::BitOps::count ( const UList< bool > &  bools,
const bool  val = true 
)
inline

Count number of 'true' entries.

Parameters
valcan be set to false to count the number of false values instead For compatibility with bitSet::count()

Definition at line 77 of file BitOps.H.

Referenced by geometric::add(), object::addData(), triSurfaceMesh::addFaceToEdge(), IOobjectList::append(), CStringList::asList(), UOPstream::beginRawWrite(), isoSurfaceBase::blockCells(), faPatch::boundaryConnections(), faPatch::boundaryProcSizes(), faMesh::boundaryProcSizes(), probes::classifyFields(), CloudFunctionObjectList< KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::CloudFunctionObjectList(), hexRef8::consistentSlowRefinement(), Foam::stringOps::count(), cellCellStencil::count(), objectRegistry::count(), IOobjectList::count(), isoSurfaceBase::countCutType(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::countEntries(), IOobjectList::countImpl(), objectRegistry::countImpl(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::countKeys(), IOobjectList::countTypeImpl(), objectRegistry::countTypeImpl(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::countValues(), decompositionMethod::decompose(), snappyVoxelMeshDriver::doRefine(), Foam::duplicateOrder(), limitFields::execute(), NURBS3DVolume::findPointsInBox(), ISstream::getLine(), hashedWordList::hashedWordList(), Histogram< List >::Histogram(), InjectionModelList< Foam::KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::InjectionModelList(), Foam::inplaceSubset(), Foam::inplaceSubsetList(), Foam::inplaceSubsetMatchingStrings(), wordRes::matching(), scalars::matching(), regionProperties::names(), IOobjectList::namesImpl(), objectRegistry::namesImpl(), IOobjectList::namesTypeImpl(), objectRegistry::namesTypeImpl(), UOprocess::newField(), polySurface::nFaceData(), blockMesh::numZonedBlocks(), ParticleForceList< KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::ParticleForceList(), points_delaunay_naive_2d(), ParticleTracks< CloudType >::postFace(), Foam::printHostsSubscription(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::printInfo(), FIRECore::putFireLabels(), ensightReadFile::read(), UIPstream::read(), FixedValueConstraint< Type >::read(), ISstream::read(), masterUncollatedFileOperation::readAndSend(), lumpedPointState::readPlain(), UIPstream::readRaw(), ISstream::readRaw(), FIREMeshReader::readSelections(), MRFZoneList::reset(), porosityModelList::reset(), optionList::reset(), SemiImplicitSource< Type >::setFieldData(), lumpedPointDisplacementPointPatchVectorField::setInterpolators(), lumpedPointDisplacementPointPatchVectorField::setPatchControls(), Foam::ListOps::setValue(), Foam::vtk::sizeofData(), ensightFaces::sizes(), ensightCells::sizes(), snappyVoxelMeshDriver::snappyVoxelMeshDriver(), regionProperties::sortedNames(), Foam::subsetMatchingStrings(), surfaceFeatures::surfaceFeatures(), Foam::system(), bitSet::toc(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::toc(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::tocEntries(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::tocKeys(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::tocValues(), wordRes::uniq(), hashedWordList::uniq(), Foam::uniqueOrder(), trackingInverseDistance::update(), cellVolumeWeight::update(), inverseDistance::update(), PtrListDetail< const Foam::UList >::write(), prefixOSstream::write(), OSstream::write(), UOPstream::write(), ensightFile::write(), histogram::write(), Foam::writeAllAreaFields(), Foam::writeAllDimFields(), Foam::writeAllPointFields(), Foam::writeAllVolFields(), Foam::writeAreaFields(), Foam::writeChars(), Foam::ensightOutput::writeCloudField(), Foam::writeDimFields(), UList< Foam::wordRe >::writeEntry(), advancingFrontAMI::writeIntersectionOBJ(), Foam::meshTools::writeOBJ(), Foam::writePointFields(), OSstream::writeRaw(), UOPstream::writeRaw(), cellClassification::writeStats(), Foam::vtk::writeValueParallel(), vtkWrite::writeVolFields(), ensightWrite::writeVolFields(), Foam::writeVolFields(), memorybuf::in::xsgetn(), and memorybuf::out::xsputn().

◆ all()

bool Foam::BitOps::all ( const UList< bool > &  bools)
inline

True if all entries are 'true' or if the set is empty.

For compatibility with bitSet::all()

Definition at line 84 of file BitOps.H.

Referenced by decompositionMethod::decompose().

Here is the caller graph for this function:

◆ any()

bool Foam::BitOps::any ( const UList< bool > &  bools)
inline

True if any entries are 'true'.

For compatibility with bitSet::any()

Definition at line 91 of file BitOps.H.

Referenced by boolVector::none(), and bitSet::toc().

Here is the caller graph for this function:

◆ none()

bool Foam::BitOps::none ( const UList< bool > &  bools)
inline

True if no entries are 'true'.

For compatibility with bitSet::none()

Definition at line 98 of file BitOps.H.

Referenced by noiseModel::SPL().

Here is the caller graph for this function:

◆ set() [1/3]

void set ( List< bool > &  bools,
const labelRange range 
)

Set the specified range 'on' in a boolList.

For compatibility with bitSet::set(labelRange)

Definition at line 37 of file BitOps.C.

References labelRange::adjust(), labelRange::after(), Foam::HashSetOps::bools(), IntRange< IntType >::empty(), IntRange< IntType >::first(), IntRange< IntType >::last(), range, List< T >::resize(), List< T >::set(), and IntRange< IntType >::start().

Referenced by fileFieldSelection::addFromFile(), fileFieldSelection::addGeoFieldTypes(), fileFieldSelection::addInternalFieldTypes(), topoSetSource::addOrDelete(), fieldSelection::addRegistered(), volFieldSelection::addRegisteredGeoFields(), cellZoneSet::addSet(), pointZoneSet::addSet(), faceZoneSet::addSet(), topoBitSet::addSet(), topoBoolSet::addSet(), topoSet::addSet(), polyTopoChanger::addTopologyModifiers(), fileFieldSelection::addUniformFieldTypes(), triad::align(), PtrDynList< Foam::profilingInformation >::append(), IOobjectList::append(), singleProcessorFaceSets::apply(), badQualityToCell::applyToSet(), badQualityToFace::applyToSet(), regionsToCell::applyToSet(), boundaryToCell::applyToSet(), boundaryToFace::applyToSet(), nbrToCell::applyToSet(), faceZoneToFaceZone::applyToSet(), labelToPoint::applyToSet(), labelToCell::applyToSet(), labelToFace::applyToSet(), setToCellZone::applyToSet(), nearestToPoint::applyToSet(), nearestToCell::applyToSet(), setToPointZone::applyToSet(), setAndNormalToFaceZone::applyToSet(), setToFaceZone::applyToSet(), cellToCell::applyToSet(), pointToPoint::applyToSet(), patchToCell::applyToSet(), faceToFace::applyToSet(), haloToCell::applyToSet(), patchToFace::applyToSet(), normalToFace::applyToSet(), shapeToCell::applyToSet(), sphereToFace::applyToSet(), sphereToPoint::applyToSet(), sphereToCell::applyToSet(), regionToFace::applyToSet(), searchableSurfaceToFace::applyToSet(), boxToCell::applyToSet(), boxToPoint::applyToSet(), searchableSurfaceToPoint::applyToSet(), searchableSurfaceToCell::applyToSet(), boxToFace::applyToSet(), searchableSurfaceToFaceZone::applyToSet(), setsToFaceZone::applyToSet(), fieldToCell::applyToSet(), cylinderToPoint::applyToSet(), cylinderToCell::applyToSet(), targetVolumeToCell::applyToSet(), cylinderAnnulusToFace::applyToSet(), cylinderToFace::applyToSet(), rotatedBoxToCell::applyToSet(), cylinderAnnulusToCell::applyToSet(), cellToPoint::applyToSet(), faceToPoint::applyToSet(), zoneToPoint::applyToSet(), zoneToCell::applyToSet(), zoneToFace::applyToSet(), pointToCell::applyToSet(), pointToFace::applyToSet(), faceToCell::applyToSet(), planeToFaceZone::applyToSet(), regionToCell::applyToSet(), surfaceToPoint::applyToSet(), faceZoneToCell::applyToSet(), surfaceToCell::applyToSet(), bitSet::assign(), bitSet::bitSet(), primitiveMesh::cellEdges(), primitiveMesh::cellPoints(), CloudFunctionObjectList< KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::CloudFunctionObjectList(), coalCloudList::coalCloudList(), meshRefinement::collectFaces(), nearWallDist::correct(), decompositionMethod::decompose(), topoSet::deleteSet(), PtrList< transferModel >::emplace(), HashPtrTable< exprResult >::emplace(), PtrDynList< Foam::profilingInformation >::emplace(), HashPtrTable< exprResult >::emplace_set(), FieldField< Foam::Field, LUType >::FieldField(), forceList::forceList(), combineFaces::getMergeSets(), fvExprDriver::getTopoSetLabels(), graph::graph(), meshRefinement::growFaceCellFace(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::HashTable(), if(), InjectionModelList< Foam::KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::InjectionModelList(), injectionModelList::injectionModelList(), regionModel::interRegionAMI(), topoSet::invert(), Foam::max(), cellToCellStencil::merge(), cellToFaceStencil::merge(), meshRefinement::mergePatchFacesUndo(), Foam::min(), Foam::minMax(), topoSet::New(), triad::normalize(), unionEqOp::operator()(), triad::operator+=(), dictionary::operator<<=(), regExpPosix::operator=(), regExpCxx::operator=(), HashTable< Foam::autoPtr< Foam::interfaceCompositionModel > >::operator=(), triad::orthogonalize(), PackedList< 2 >::PackedList(), ParticleForceList< KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::ParticleForceList(), profileModelList::profileModelList(), GeometricField< Type, PatchField, GeoMesh >::Boundary::readField(), PtrList< transferModel >::readIstream(), regExpCxx::regExpCxx(), regExpPosix::regExpPosix(), regionModelFunctionObjectList::regionModelFunctionObjectList(), MRFZoneList::reset(), porosityModelList::reset(), optionList::reset(), searchableSurfaces::searchableSurfaces(), PtrListDictionary< phaseModel >::set(), triad::set(), PtrList< transferModel >::set(), PtrDynList< Foam::profilingInformation >::set(), HashPtrTable< exprResult >::set(), dictionary::set(), fvMatrix< Type >::setBounAndInterCoeffs(), bitSet::setMany(), PackedList< 2 >::setPair(), properties::setTrigger(), sigFpe::sigFpe(), sigInt::sigInt(), sigQuit::sigQuit(), sigSegv::sigSegv(), sigStopAtWriteNow::sigStopAtWriteNow(), sigWriteNow::sigWriteNow(), solidBodyMotionSolver::solidBodyMotionSolver(), triad::sortxyz(), dictionary::subDictOrAdd(), cellZoneSet::subset(), pointZoneSet::subset(), faceZoneSet::subset(), topoBoolSet::subset(), topoBitSet::subset(), topoSet::subset(), cellZoneSet::subtractSet(), pointZoneSet::subtractSet(), faceZoneSet::subtractSet(), topoBitSet::subtractSet(), topoBoolSet::subtractSet(), topoSet::subtractSet(), transferModelList::transferModelList(), Foam::vtk::writeCellSetFaces(), Foam::vtk::writeFaceSet(), Foam::vtk::writePointSet(), Foam::vtk::writeTopoSet(), and zoneMotion::zoneMotion().

Here is the call graph for this function:

◆ set() [2/3]

void set ( labelHashSet hashset,
const labelRange range 
)

Set the specified range in a labelHashSet.

For compatibility with bitSet::set(labelRange)

Definition at line 77 of file BitOps.C.

References labelRange::adjust(), IntRange< IntType >::first(), IntRange< IntType >::last(), range, and HashSet< Key, Hash >::set().

Here is the call graph for this function:

◆ set() [3/3]

void set ( bitSet bitset,
const labelRange range 
)

Forward to bitSet::set(labelRange)

Definition at line 89 of file BitOps.C.

References Foam::HashSetOps::bitset(), range, and bitSet::set().

Here is the call graph for this function:

◆ unset() [1/3]

void unset ( List< bool > &  bools,
const labelRange range 
)

Unset the specified range 'on' in a boolList.

For compatibility with bitSet::unset(labelRange)

Definition at line 96 of file BitOps.C.

References Foam::HashSetOps::bools(), and range.

Referenced by PrimitivePatch<::Foam::List< labelledTri >, pointField >::checkPointManifold(), Foam::debug::listDebugSwitches(), Foam::debug::listInfoSwitches(), Foam::debug::listOptimisationSwitches(), Foam::debug::listRegisteredDebugSwitches(), Foam::debug::listRegisteredInfoSwitches(), Foam::debug::listRegisteredOptimisationSwitches(), Foam::debug::listRegisteredSwitches(), Foam::debug::listSwitches(), Foam::listSwitches(), bitSet::unset(), HashSet< word, Hash< word > >::unset(), sigInt::~sigInt(), sigQuit::~sigQuit(), and sigSegv::~sigSegv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset() [2/3]

void unset ( labelHashSet hashset,
const labelRange range 
)

Unset the specified range in a labelHashSet.

For compatibility with bitSet::unset(labelRange)

Definition at line 105 of file BitOps.C.

References range, and HashSet< Key, Hash >::unset().

Here is the call graph for this function:

◆ unset() [3/3]

void unset ( bitSet bitset,
const labelRange range 
)

Forward to bitSet::unset(labelRange)

Definition at line 114 of file BitOps.C.

References Foam::HashSetOps::bitset(), range, and bitSet::unset().

Here is the call graph for this function:

◆ bit_count() [1/3]

unsigned int Foam::BitOps::bit_count ( UIntType  x)
inline

Count arbitrary number of bits (of an integral type)

Definition at line 130 of file BitOps.H.

References n, and x.

Referenced by bitSet::count().

Here is the caller graph for this function:

◆ bit_count() [2/3]

unsigned int Foam::BitOps::bit_count ( uint32_t  x)
inline

Count bits in a 32-bit value (Hamming weight method)

Definition at line 142 of file BitOps.H.

References x.

◆ bit_count() [3/3]

unsigned int Foam::BitOps::bit_count ( uint64_t  x)
inline

Count bits in a 64-bit value (Hamming weight method)

Definition at line 153 of file BitOps.H.

References x.

◆ repeat_value()

UIntType Foam::BitOps::repeat_value ( unsigned  val)
inline

Repeat a value of the given BitWidth into the destination output type.

Note
when BitWidth is 1, it is better to do directly.
(val ? ~0u : 0u)

Definition at line 170 of file BitOps.H.

◆ print()

Ostream& Foam::BitOps::print ( Ostream os,
UIntType  value,
char  off = '0',
char  on = '1' 
)
inline

Print 0/1 bits in the (unsigned) integral type.

Definition at line 199 of file BitOps.H.

References IOstreamOption::BINARY, and os().

Referenced by if(), Foam::operator<<(), dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::print(), indexedOctree< Foam::treeDataPrimitivePatch< PatchType > >::print(), PackedList< 2 >::printBits(), sampledPlane::update(), sampledPatch::update(), and seriesWriter::write().

Here is the call graph for this function:
Here is the caller graph for this function: