Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O OpenFOAM-plus
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 339
    • Issues 339
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • OpenFOAM-plus
  • Merge requests
  • !200

Merged
Created Apr 23, 2018 by Mark Olesen@markMaintainer

ENH: new bitSet class and improved PackedList class (closes #751)

  • Overview 2
  • Commits 1
  • Changes 192
  • The bitSet class replaces the old PackedBoolList class. The redesign provides better block-wise access and reduced method calls. This helps both in cases where the bitSet may be relatively sparse, and in cases where advantage of contiguous operations can be made. This makes it easier to work with a bitSet as top-level object.

    In addition to the previously available count() method to determine if a bitSet is being used, now have simpler queries:

    • all() - true if all bits in the addressable range are empty
    • any() - true if any bits are set at all.
    • none() - true if no bits are set.

    These are faster than count() and allow early termination.

    The new test() method tests the value of a single bit position and returns a bool without any ambiguity caused by the return type (like the get() method), nor the const/non-const access (like operator[] has). The name corresponds to what std::bitset uses.

    The new find_first(), find_last(), find_next() methods provide a faster means of searching for bits that are set.

    This can be especially useful when using a bitSet to control an conditional:

    OLD (with macro):

    forAll(selected, celli)
    {
        if (selected[celli])
        {
            sumVol += mesh_.cellVolumes()[celli];
        }
    }

    NEW (with const_iterator):

    for (const label celli : selected)
    {
        sumVol += mesh_.cellVolumes()[celli];
    }
    
    or manually
    
    for
    (
        label celli = selected.find_first();
        celli != -1;
        celli = selected.find_next()
    )
    {
        sumVol += mesh_.cellVolumes()[celli];
    }
  • When marking up contiguous parts of a bitset, an interval can be represented more efficiently as a labelRange of start/size. For example,

    OLD:

    if (isA<processorPolyPatch>(pp))
    {
        forAll(pp, i)
        {
            ignoreFaces.set(i);
        }
    }

    NEW:

    if (isA<processorPolyPatch>(pp))
    {
        ignoreFaces.set(pp.range());
    }
Edited Apr 24, 2018 by Mark Olesen
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: feature-bitset