Skip to content
Snippets Groups Projects
  1. May 15, 2017
  2. May 08, 2017
  3. May 05, 2017
  4. May 04, 2017
    • mattijs's avatar
    • mattijs's avatar
    • Andrew Heather's avatar
      Merge branch 'feature-improved-container-classes' into 'develop' · d2221ea5
      Andrew Heather authored
      improved container classes
      
      See merge request !108
      d2221ea5
    • Mark OLESEN's avatar
      BUG: odd table size after shrink (issue #460) · b7c1f28b
      Mark OLESEN authored
      - remove this unused method
      b7c1f28b
    • Mark OLESEN's avatar
      ENH: regex matching on std::string, not Foam::string · 72b26b70
      Mark OLESEN authored
      - avoids unneeded promotion of types.
        Easier to switch regex engines in the future.
      72b26b70
    • Mark OLESEN's avatar
      ENH: improve HashTable iterator access and management · 5d666955
      Mark OLESEN authored
      - provide key_iterator/const_key_iterator for all hashes,
        reuse directly for HashSet as iterator/const_iterator, respectively.
      
      - additional keys() method for HashTable that returns a wrapped to
        a pair of begin/end const_iterators with additional size/empty
        information that allows these to be used directly by anything else
        expecting things with begin/end/size. Unfortunately does not yet
        work with std::distance().
      
        Example,
           for (auto& k : labelHashTable.keys())
           {
              ...
           }
      5d666955
    • Mark OLESEN's avatar
    • Mark OLESEN's avatar
    • Mark OLESEN's avatar
    • Mark OLESEN's avatar
      ENH: simplify and extend labelRange · e271f07d
      Mark OLESEN authored
      - add increment/decrement, repositioning. Simplify const_iterator.
      
      - this makes is much easier to use labelRange for constructing ranges of
        sub-lists. For symmetry with setSize() it has a setStart() instead of
        simply assigning to start() directly. This would also provide the
        future possibility to imbue the labelRange with a particular policy
        (eg, no negative starts, max size etc) and ensure that they are
        enforced.
      
        A simple use case:
      
          // initialize each to zero...
          List<labelRange> subListRanges = ...;
      
          // scan and categorize
          if (condition)
             subListRanges[categoryI]++;  // increment size for that category
      
          // finally, set the starting points
          start = 0;
          for (labelRange& range : subListRanges)
          {
              range.setStart(start);
              start += range.size();
          }
      e271f07d
    • Mark OLESEN's avatar
      COMP: avoid clang compiler warnings · d0b427f8
      Mark OLESEN authored
      d0b427f8
    • Mark OLESEN's avatar
      f0ae0275
    • Mark OLESEN's avatar
      ENH: HashSet iterators operator* now return Key. · dd1f3e72
      Mark OLESEN authored
      - much more useful than returning nil. Can now use with a for range:
      
          for (auto i : myLabelHashSet)
          {
              ...
          }
      dd1f3e72
    • Mark OLESEN's avatar
      ENH: add HashTable::writeKeys and HashSet::writeList · 2da561e9
      Mark OLESEN authored
      - can use the hash-set writeList in combination with FlatOutput:
      
        Eg, flatOutput(myHashSet);
      2da561e9
    • Mark OLESEN's avatar
      ENH: improve overall consistency of the HashTable and its iterators · dd6048d3
      Mark OLESEN authored
      - previously had a mismash of const/non-const attributes on iterators
        that were confused with the attributes of the object being accessed.
      
      - use the iterator keys() and object() methods consistently for all
        internal access of the HashTable iterators. This makes the intention
        clearer, the code easier to maintain, and protects against any
        possible changes in the definition of the operators.
      
      - 'operator*': The standard form expected by STL libraries.
        However, for the std::map, this dereferences to a <key,value> pair,
        whereas OpenFOAM dereferences simply to <value>.
      
      - 'operator()': OpenFOAM treats this like the 'operator*'
      
      - adjusted the values of end() and cend() to reinterpret from nullObject
        instead of returning a static iteratorEnd() object.
        This means that C++ templates can now correctly deduce and match
        the return types from begin() and end() consistently.
        So that range-based now works.
      
        Eg,
            HashTable<label> table1 = ...;
            for (auto i : table1)
            {
                Info<< i << endl;
            }
      
        Since the 'operator*' returns hash table values, this prints all the
        values in the table.
      dd6048d3
    • Mark OLESEN's avatar
      ENH: ensure nullObject is large enough for reinterpret · bcf6e58e
      Mark OLESEN authored
      - previously occupied 1 byte. Now occupies enough to hold a pointer,
        which helps if using reinterpret_cast to something that has some
        member content.
      bcf6e58e
    • Mark OLESEN's avatar
      BUG: comparison to static end() for hashtable lookup. · 2b6b0f21
      Mark OLESEN authored
      - just use the iterator method found() as an alternative and
        convenient way to avoid the issue with less typing.
      2b6b0f21
    • Mark OLESEN's avatar
      BUG: comparison with incorrect construction tables · a09a0c57
      Mark OLESEN authored
      - previously hidden when hashtable used a static method and a
        different class for end()
      a09a0c57
    • Mark OLESEN's avatar
      ENH: support UList[labelRange] and SubList construction with labelRange · cad1059c
      Mark OLESEN authored
      This uses a concept similar to what std::valarray and std::slice do.
      A labelRange provides a convenient container for holding start/size
      and lends itself to addressing 'sliced' views of lists.
      For safety, the operations and constructors restricts the given input range
      to a valid addressible region of the underlying list, while the labelRange
      itself precludes negative sizes.
      
      The SubList version is useful for patches or other things that have a
      SubList as its parameter. Otherwise the UList [] operator will be the
      more natural solution. The slices can be done with a labelRange, or
      a {start,size} pair.
      
      Examples,
           labelList list1 = identity(20);
      
           list1[labelRange(18,10)]  = -1;
           list1[{-20,25}] = -2;
           list1[{1000,5}] = -3;
      
           const labelList list2 = identity(20);
           list2[{5,10}] = -3;  // ERROR: cannot assign to const!
      cad1059c
    • Mark OLESEN's avatar
      ENH: add labelRange comparison operators and subset methods · 3d2f66b2
      Mark OLESEN authored
      - improve interface consistency.
      3d2f66b2
    • Mark OLESEN's avatar
      f4bb33d6
    • Mark OLESEN's avatar
      ENH: HashTable improvements · a345377b
      Mark OLESEN authored
      - optimize erasure using different HashTable based on its size.
        Eg, hashtable.erase(other);
      
        If 'other' is smaller than the hashtable, it is more efficient to
        use the keys from other to remove from the hashtable.
      
        Otherwise simply iterate over the hashtable and remove it if
        that key was found in other.
      a345377b
    • Mark OLESEN's avatar
      ENH: add some standard templates and macros into stdFoam.H · da37425e
      Mark OLESEN authored
      - some functionality similar to what the standary library <iterator>
        provides.
      
        * stdFoam::begin() and stdFoam::end() do type deduction,
          which means that many cases it is possible to manage these types
          of changes.
      
          For example, when managing a number of indices:
             Map<labelHashSet> lookup;
      
          1) Longhand:
      
              for
              (
                  Map<labelHashSet>::const_iterator iter = lookup.begin();
                  iter != lookup.end();
                  ++iter
              )
              { .... }
      
          1b) The same, but wrapped via a macro:
      
              forAllConstIter(Map<labelHashSet>, lookup, iter)
              { .... }
      
          2) Using stdFoam begin/end templates directly
      
              for
              (
                  auto iter = stdFoam::begin(lookup);
                  iter != stdFoam::end(lookup);
                  ++iter
              )
              { .... }
      
          2b) The same, but wrapped via a macro:
      
              forAllConstIters(lookup, iter)
              { .... }
      
      Note that in many cases it is possible to simply use a range-based for.
      Eg,
           labelList myList;
      
           for (auto val : myList)
           { ... }
      
           for (const auto& val : myList)
           { ... }
      
      These however will not work with any of the OpenFOAM hash-tables,
      since the standard C++ concept of an iterator would return a key,value
      pair when deferencing the *iter.
      
      The deduction methods also exhibits some slightly odd behaviour with
      some PtrLists (needs some more investigation).
      da37425e
    • Mark OLESEN's avatar
      ENH: improve HashSet construction and assignment · 3be7d533
      Mark OLESEN authored
      - make construct from UList explicit and provide corresponding
        assignment operator.
      
      - add construct,insert,set,assignment from FixedList.
        This is convenient when dealing with things like edges or triFaces.
      3be7d533
    • Mark OLESEN's avatar
      ENH: support HashTable erasure via a FixedList · f0fbb241
      Mark OLESEN authored
      - propagate common erasure methods as HashSet::unset() method,
        for symmetry with HashSet::set()
      f0fbb241
    • Mark OLESEN's avatar
      STYLE: HashTable documentation · 510835d4
      Mark OLESEN authored
      - explicitly mention the value-initialized status for the operator().
        This means that the following code will properly use an initialized
        zero.
      
            HashTable<label> regionCount;
      
            if (...)
               regionCount("region1")++;
      
            ... and also this;
      
            if (regionCount("something") > 0)
            {
                ...
            }
      
        Note that the OpenFOAM HashTable uses operator[] to provide read and
        write access to *existing* entries and will provoke a FatalError if
        the entry does not exist.
      
        The operator() provides write access to *existing* entries or will
        create the new entry as required.
        The STL hashes use operator[] for this purpose.
      510835d4
    • Mark OLESEN's avatar
      ENH: further refinement to edge methods · 195a6781
      Mark OLESEN authored
      - more hash-like methods.
        Eg, insert/erase via lists, clear(), empty(),...
      
      - minVertex(), maxVertex() to return the smallest/largest label used
      
      - improved documentation, more clarification about where/how negative
        point labels are treated.
      195a6781
    • Andrew Heather's avatar
      BUG: wall/patch distance and inverseDistanceDiffusivity - updated dimensions... · 49d992a6
      Andrew Heather authored
      BUG: wall/patch distance and inverseDistanceDiffusivity - updated dimensions and use meshWave as a default method for backwards compatibility.  Fixes #462
      49d992a6