Skip to content
Snippets Groups Projects
  1. Mar 13, 2018
    • Mark OLESEN's avatar
      ENH: code reduction in PackedList, PackedBoolList (issue #751) · 5d1fb235
      Mark OLESEN authored
      - eliminate iterators from PackedList since they were unused, had
        lower performance than direct access and added unneeded complexity.
      
      - eliminate auto-vivify for the PackedList '[] operator.
        The set() method provides any required auto-vivification and
        removing this ability from the '[]' operator allows for a lower
        when accessing the values. Replaced the previous cascade of iterators
        with simpler reference class.
      
      PackedBoolList:
      
      - (temporarily) eliminate logic and addition operators since
        these contained partially unclear semantics.
      
      - 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.
      
      - more consistent use of PackedBoolList test(), set(), unset() methods
        for fewer operation and clearer code. Eg,
      
            if (list.test(index)) ...    |  if (list[index]) ...
            if (!list.test(index)) ...   |  if (list[index] == 0u) ...
            list.set(index);             |  list[index] = 1u;
            list.unset(index);           |  list[index] = 0u;
      
      - deleted the operator=(const labelUList&) and replaced with a setMany()
        method for more clarity about the intended operation and to avoid any
        potential inadvertent behaviour.
      5d1fb235
  2. Mar 07, 2018
  3. Mar 15, 2018
    • Mark OLESEN's avatar
      ENH: reduce overhead for clockTime, cpuTime · 77338c8b
      Mark OLESEN authored
      - clockValue class for managing the clock values only, with a null
        constructor that does not query the system clock (can defer to later).
        Can also be used directly for +/- operations.
      
      - refactor clockTime, cpuTime, clock to reduce storage.
      77338c8b
  4. Mar 14, 2018
  5. Mar 16, 2018
  6. Feb 23, 2018
  7. Mar 15, 2018
  8. Mar 14, 2018
  9. Mar 12, 2018
  10. Mar 08, 2018
  11. Feb 21, 2018
  12. Mar 07, 2018
  13. Mar 06, 2018
  14. Mar 05, 2018
  15. Feb 28, 2018
  16. Feb 27, 2018
  17. Feb 26, 2018
    • Mark OLESEN's avatar
    • Mark OLESEN's avatar
      ENH: cleanup tmp class (issue #639) · 52b36f84
      Mark OLESEN authored
      Improve alignment of its behaviour with std::shared_ptr
      
        - element_type typedef
        - swap, reset methods
      
      * additional reference access methods:
      
      cref()
          returns a const reference, synonymous with operator().
          This provides a more verbose alternative to using the '()' operator
          when that is desired.
      
              Mnemonic: a const form of 'ref()'
      
      constCast()
          returns a non-const reference, regardless if the underlying object
          itself is a managed pointer or a const object.
          This is similar to ref(), but more permissive.
      
              Mnemonic: const_cast<>
      
          Using the constCast() method greatly reduces the amount of typing
          and reading. And since the data type is already defined via the tmp
          template parameter, the type deduction is automatically known.
      
          Previously,
      
              const tmp<volScalarField>& tfld;
      
              const_cast<volScalarField&>(tfld()).rename("name");
              volScalarField& fld = const_cast<volScalarField&>(tfld());
      
          Now,
      
              tfld.constCast().rename("name");
              auto& fld = tfld.constCast();
      
      --
      
      BUG: attempts to move tmp value that may still be shared.
      
      - old code simply checked isTmp() to decide if the contents could be
        transfered. However, this means that the content of a shared tmp
        would be removed, leaving other instances without content.
      
      * movable() method checks that for a non-null temporary that is
        unique (not shared).
      52b36f84
    • Mark OLESEN's avatar
      ENH: cleanup autoPtr class (issue #639) · 660f3e54
      Mark OLESEN authored
      Improve alignment of its behaviour with std::unique_ptr
      
        - element_type typedef
        - release() method - identical to ptr() method
        - get() method to get the pointer without checking and without releasing it.
        - operator*() for dereferencing
      
      Method name changes
      
        - renamed rawPtr() to get()
        - renamed rawRef() to ref(), removed unused const version.
      
      Removed methods/operators
      
        - assignment from a raw pointer was deleted (was rarely used).
          Can be convenient, but uncontrolled and potentially unsafe.
          Do allow assignment from a literal nullptr though, since this
          can never leak (and also corresponds to the unique_ptr API).
      
      Additional methods
      
        - clone() method: forwards to the clone() method of the underlying
          data object with argument forwarding.
      
        - reset(autoPtr&&) as an alternative to operator=(autoPtr&&)
      
      STYLE: avoid implicit conversion from autoPtr to object type in many places
      
      - existing implementation has the following:
      
           operator const T&() const { return operator*(); }
      
        which means that the following code works:
      
             autoPtr<mapPolyMesh> map = ...;
             updateMesh(*map);    // OK: explicit dereferencing
             updateMesh(map());   // OK: explicit dereferencing
             updateMesh(map);     // OK: implicit dereferencing
      
        for clarity it may preferable to avoid the implicit dereferencing
      
      - prefer operator* to operator() when deferenced a return value
        so it is clearer that a pointer is involve and not a function call
        etc    Eg,   return *meshPtr_;  vs.  return meshPtr_();
      660f3e54
  18. Mar 04, 2018
    • Mark OLESEN's avatar
      ENH: improvements for labelRange · fc92d30e
      Mark OLESEN authored
      - constexpr, noexcept.
        Added an 'at()' method for returning an iterator within the range
        and changed operator()(label) to have behaviour as per found().
        This makes the labelRange usable as a unary predicate.
      
      - added templated conversion class 'toLabelRange'
      
      - add range() method to polyPatch and surfZone classes, and corresponding
        templated conversion functors.
        For example,
      
            auto patchDims = ListOps::create<labelRange>
            (
                mesh.boundaryMesh(),
                toLabelRange<polyPatch>()
            );
      
        to create a List<labelRange> representing the patch extents.
      fc92d30e
  19. Mar 06, 2018
    • Mark OLESEN's avatar
      ENH: dedicated HashSetOps, HashTableOps namespaces · bcabe827
      Mark OLESEN authored
      - relocated HashSetPlusEqOp and HashTablePlusEqOp to
        HashSetOps::plusEqOp and HashTableOps::plusEqOp, respectively
      
      - additional functions for converting between a labelHashSet
        and a PackedBoolList or List<bool>:
      
        From lists selections to labelHashSet indices:
      
            HashSetOps::used(const PackedBoolList&);
            HashSetOps::used(const UList<bool>&);
      
        From labelHashSet to list forms:
      
            PackedBoolList bitset(const labelHashSet&);
            List<bool> bools(const labelHashSet&);
      bcabe827