Commit Graph

33 Commits

Author SHA1 Message Date
OpenFOAM bot
01ec92fd35 GIT: remove leading/trailing blank lines, trailing whitespace 2020-06-17 10:46:26 +02:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
35facb8208 ENH: add PackedList::unpack() method
- allows for simpler unpacking of a full list, or list range into any
  sufficiently large integral type.

  For example,
    processorPolyPatch pp = ...;

    UOPstream toNbr(pp.neighbProcNo(), pBufs);
    toNbr << faceValues.unpack<char>(pp.range());
2018-08-01 12:48:35 +02:00
Mark Olesen
b76d6b5cb5 STYLE: adjust tests for some updates in methods (issue #876) 2018-06-14 17:17:17 +02:00
mattijs
3b6027d1be ENH: test: make test apps compile. Fixes #876. 2018-06-14 15:14:14 +01:00
Mark Olesen
bac943e6fc ENH: new bitSet class and improved PackedList class (closes #751)
- 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());
      }
2018-03-07 11:21:48 +01:00
Mark Olesen
345a2a42f1 ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
  and HashTable method names. This improves method name consistency
  between classes and also requires less typing effort:

    args.found(optName)        vs.  args.optionFound(optName)
    args.readIfPresent(..)     vs.  args.optionReadIfPresent(..)
    ...
    args.opt<scalar>(optName)  vs.  args.optionRead<scalar>(optName)
    args.read<scalar>(index)   vs.  args.argRead<scalar>(index)

- the older method names forms have been retained for code compatibility,
  but are now deprecated
2018-01-08 15:35:18 +01:00
Mark Olesen
f2ba618c19 STYLE: consistency in using argList::addArgument, argList::addOption 2017-11-22 12:54:28 +01:00
Mark Olesen
4ba4899660 ENH: minor update of PackedList methods
- additional convenience constructors
2017-10-07 16:10:35 +02:00
Henry
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
andy
eaef8d482b STYLE: Updated 1991 start copyright year to 2004 2011-01-14 16:08:00 +00:00
andy
099cc39e2e Revert "STYLE: 2011 copyright date."
This reverts commit b18f6cc1ce.
2011-01-05 18:24:29 +00:00
graham
b18f6cc1ce STYLE: 2011 copyright date. 2011-01-05 11:14:26 +00:00
Mark Olesen
499d48cfdb STYLE: uniform 'Test-' prefix for all applications/test
- easier to clean, avoid confusion with 'real' applications, etc.
2010-11-23 16:26:04 +01:00
Mark Olesen
b7c85357d5 ENH: added binary IO for PackedList and compact ASCII format
The compact ASCII format is a block of index/value tuples for the
non-zero entries:

    { (index1 value1) (index2 value2) (index3 value3) }

For PackedList<1>, and thus PackedBoolList, the compact ASCII format is
a block of indices for the non-zero entries:

    { index1 index2 index3 }

Thus either of the following could be used - for PackedList<2>:

  - a list of all values:
        16(0 3 0 2 0 0 3 1 0 0 0 0 0 0 0 1)

  - a block of index/value tuples:
        {(1 3) (3 2) (7 3) (8 1) (15 1)}

For PackedList<1> and PackedBoolList, either of the following could be
used:

  - a list of all values, using any valid bool representation:
        16(0 1 0 true 0 0 t 1 0 n n 0 0 0 0 yes)

  - a block of the indices for non-zero entries:
        {1 3 7 8 15}
2010-09-15 10:20:39 +02:00
graham
28345247a7 STYLE: Fixing code style requirements for more files - those not
picked up by a copyright change.
2010-07-29 11:28:44 +01:00
Mark Olesen
d29c438657 STYLE: use url for FSF license instead of postal address, switch to GPL v3 2010-03-29 14:07:56 +02:00
Mark Olesen
d857d671ac STYLE: use new argList argRead() method and operator[] for cleaner code.
- deprecate argList::additionalArgs() method and remove uses of it
2010-02-16 17:57:49 +01:00
Mark Olesen
063d8edea1 PackedBoolList specializaton for operator=
- now that I re-examined the code, the note in commit 51fd6327a6
  can be mostly ignored

  PackedList isMaster(nPoints, 1u);
  is not really inefficient at all, since the '1u' is packed into
  32/64-bits before the subsequent assignment and doesn't involve
  shifts/masking for each index

  The same misinformation applies to the PackedList(size, 0u) form.
  It isn't much slower at all.

  Nonetheless, add bool specialization so that it is a simple assign.
2009-12-03 16:33:58 +01:00
Mark Olesen
58b7e64185 Use argList::addOption, argList::addBoolOption (almost) everywhere
- ensure that the standard options (eg, from timeSelector) also have
  some usage information
2009-12-03 13:32:12 +01:00
Mark Olesen
ceaaabab56 bugfix PackedList for non-optimized compilation
- use shift-right instead of shift-left formulation to avoid wrong behaviour
  with non-optimized compilation when the packed items fit exactly in the
  available number of bits.
2009-07-23 22:46:52 +02:00
Mark Olesen
6c9f2520e1 added another PackedListTest 2009-07-23 15:36:46 +02:00
Mark Olesen
106d417de0 StaticAssert added
- catch people using silly template sizes for FixedList, PackedList
2009-02-27 16:41:51 +01:00
Mark Olesen
dbc9b7427a PackedList iterator bugfix
- compare iteratorBase == iteratorBase by value, not position
  thus this works
      list[a] == list[b] ...

- compare iterator == iteratorBase and const_iterator == iteratorBase
  by position, not value. The inheritance rules means that this works:
      iter == list.end() ...
  this will compare positions:
      iter == list[5];
  Of course, this will still compare values:
      *iter == list[5];
2009-02-27 13:43:43 +01:00
Mark Olesen
69918f23c5 consistency update
- OSspecific: chmod() -> chMod(), even although it's not used anywhere

- ListOps get subset() and inplaceSubset() templated on BoolListType

- added UList<bool>::operator[](..) const specialization.
  Returns false (actually pTraits<bool>::zero) for out-of-range elements.
  This lets us use List<bool> with lazy evaluation and no noticeable
  change in performance.

- use rcIndex() and fcIndex() wherever possible.
  Could check if branching or modulus is faster for fcIndex().

- UList and FixedList get 'const T* cdata() const' and 'T* data()' members.
  Similar to the STL front() and std::string::data() methods, they return a
  pointer to the first element without needing to write '&myList[0]', recast
  begin() or violate const-ness.
2009-02-06 20:43:09 +01:00
Mark Olesen
1f6733d91d PackedList - activated lazy evaluation
- moving back to original flat addressing in iterators means there is no
  performance issue with using lazy evaluation
- set() method now has ~0 for a default value.
  We can thus simply write 'set(i) to trun on all of the bits.
  This means we can use it just like labelHashSet::set(i)
- added flip() method for inverting bits. I don't know where we might need
  it, but the STL has it so we might as well too.
2009-01-30 00:07:53 +01:00
Mark Olesen
4e56643efe PackedList improvements
- dropped auto-vivification for now (performance issue), but reworked to
  allow easy reinstatement
- derived both iterator and const_iterator from iteratorBase and use
  iteratorBase as our proxy for non-const access to the list elements.
  This allows properly chaining assignments:
     list[1] = list[2];
     list[1] = list[2] = 10;
- assigning iterators from iteratorBase or other iterators works:
     iterator iter = list[20];
- made template parameter nBits=1 the default
2009-01-29 14:03:53 +01:00
Mark Olesen
7c739978b1 PackedList gets count() and trim() methods
- the bit counting is relatively fast:
  under 0.2 seconds for 1M bits counted 1000 times

- trim()'ing the final zero elements tested for a few cases,
  but might need more attention
2009-01-28 16:32:47 +01:00
Mark Olesen
84ec272d23 PackedList changes
- added Mattijs' speed tests
- optimized resize() and assignment operators to avoid set() method
- add const_iterator and re-did the proxy handling.

Reading/writing by looping across iterators is still somewhat slow, but
might be acceptable.
2009-01-26 00:33:28 +01:00
Mark Olesen
cc4cd0a171 PackedList: encapsulate calculations in an iterator
- eliminated previous PackedBitRef class, the iterator does all of that and
  can also be used to (forward) traverse the list
- no const_iterator yet

- Note that PackedList is also a bit like DynamicList in terms of storage
  management and the append() method. Since the underlying storage in
  integer, any auto-vivified elements will also flood-fill the gaps with
  zero.
2009-01-23 01:40:55 +01:00
Mark Olesen
173607fd2d PackedList gets functionality akin to DynamicList 2009-01-22 16:24:05 +01:00
Mark Olesen
6d57bb4e7b added PackedBoolList typedef (used everywhere) and improved PackedList
- new members:  capacity(), two-argument resize()/setSize(), const storage()
- new static members: max_value(), packing(), etc.
2009-01-21 11:30:10 +01:00