1. 30 Jul, 2020 3 commits
  2. 29 Jul, 2020 1 commit
  3. 28 Jul, 2020 8 commits
    • sergio's avatar
      BUG: Limiting min alpha to SMALL to avoid zero transient term of turbulence model · d0737242
      sergio authored
      In certain turbulence models such as kEpsilon, kOmegaSST, etc when used
      in the multiphase context throw an error in the preconditioner. This
      is due to alpha being zero. Fixes #1789.
    • Mark Olesen's avatar
    • Mark Olesen's avatar
    • Mark Olesen's avatar
      BUG: potential memory leaks in HashPtrTable (#1787) · 65d640e5
      Mark Olesen authored
      - using HashPtrTable::set() with the same key twice did not guarantee
        proper cleanup of memory since it simply used the underlying
        HashTable::set() without doing anything about the old memory. Now
        check for pre-existing storage and delete it when it does not
        correspond to the newly stored pointer.
        This problem is independent of potential memory slicing previously
        flagged (#1286) and only partially resolved.
    • Mark Olesen's avatar
      ENH: add get() retrieval of a pointer from PtrLists, HashPtrTable · fa71840d
      Mark Olesen authored
      - naming similarity with autoPtr, unique_ptr and other containers.
        For UPtrList derivatives, this is equivalent to the existing
        operator(). The read-only variant is also equivalent to the
        single-parameter 'set(label)' method.
        With PtrList<T> list(...) :
            const T* ptr = list.get(10);
            if (ptr)
            if (list.set(10))
        For HashPtrTable there is only a read-only variant which is equivalent
        to testing for existence and for value.
        With HashPtrTable<T> hash(...) :
            const T* ptr = list.get("key");
            if (ptr)
            if (list.found("key"))
                // Fails on null pointer!!
      Use of get() is largely a matter of taste or local coding requirements
    • Mark Olesen's avatar
      ENH: support emplace methods and std::unique_ptr for PtrList-derivatives · 872c9d37
      Mark Olesen authored
      - emplace methods
            m.internalCoeffs().emplace(patchi, fc.size(), Zero);
            m.internalCoeffs().set(patchi, new Field<Type>(fc.size(), Zero));
      - handle insert/append of refPtr wherever tmp was already supported
      COMP: incorrect variable names in PtrListOpsTemplates.C
    • Mark Olesen's avatar
      ENH: HashTable::emplace_set() method, HashPtrTable support for unique_ptr · 4110699d
      Mark Olesen authored
      - forwarding like the emplace() method, but overwriting existing
        entries as required
      - propagate similar changes to HashPtrTable
        For example, with HashPtrTable<labelList> table(...) :
        With 'insert' semantics
            table.emplace("list1", 1000);
            if (!table.found("list1"))
                table.set("list1", new labelList(1000));
            table.insert("list1", autoPtr<labelList>::New(1000));
        Note that the last example invokes an unnecessary allocation/deletion
        if the insertion is unsuccessful.
        With 'set' semantics:
            table.emplace_set("list1", 15);
            table.set("list1", new labelList(15));
    • Mark Olesen's avatar
      COMP: fix sloppy (and now ambiguous) use of PtrList::set() · c77afff4
      Mark Olesen authored
      - constructs such as the following will no longer worked, but that is
        also a good thing.
           ptrlist.set(i, scalarField(nFaces, Zero));
        this called set(.., const tmp<scalarField>&), which meant under
        the hood:
           - create local temporary const scalarField&
           - wrap as const tmp&
           - use tmp::ptr(), to clone the const-ref
        This implies an additional allocation (for the const scalarField&)
        which is immediately discarded. Doubtful that compiler optimization
        would do anything.
  4. 27 Jul, 2020 7 commits
  5. 24 Jul, 2020 1 commit
  6. 23 Jul, 2020 2 commits
  7. 22 Jul, 2020 2 commits
  8. 23 Jul, 2020 3 commits
  9. 21 Jul, 2020 2 commits
    • sergio's avatar
      BUG: Correct evaluate function for ddt0 in CrankNicolson scheme. Fixes · 45982d97
      sergio authored
      The function evaluate was returning true every outer loop, triggering
      the re-calculation of ddt0 in every outer loop.
      The evaluation of the term ddt0 should be performed once per time step.
      The corrected function updates the timeIndex of ddt0 to avoid the
      re-evaluation of this term in the outer loops.
    • Mark Olesen's avatar
      ENH: support writable reference for tmp (#1775) · be058bec
      Mark Olesen authored
      - improves flexibility. Can tag a tmp as allowing non-const access to
        the reference and skip additional const_cast in following code. For
            tmp<volScalarField> tfld(nullptr);
            auto* ptr = getObjectPtr<volScalarField>("field");
            if (ptr)
            auto& fld = tfld.ref();
      ENH: renamed tmpNrc to refPtr
      - the name 'refPtr' (reference|pointer) should be easier to remember
        than tmpNrc (tmp, but non-ref-counted).
      - provide tmpNrc typedef and header for code compatibility
      - in some places refPtr and tmp can be used instead of a
        std::reference_wrapper for handling external references.
        Unlike std::reference_wrapper, it can be default constructed
        (holding nothing), whereas reference_wrapper may need a dummy
        reference. However, the lifetime extension of references _may_ be
        better with reference_wrapper.
  10. 20 Jul, 2020 2 commits
  11. 17 Jul, 2020 2 commits
  12. 16 Jul, 2020 7 commits
    • Mark Olesen's avatar
      ENH: extend nullptr check for tmp ptr() method (#1775) · 6d4928d5
      Mark Olesen authored
      - Cannot call ptr_->clone() with a null pointer!
    • Mark Olesen's avatar
      STYLE: compile-type deprecate empty() method for autoPtr/tmp (#1775) · fde93b66
      Mark Olesen authored
      - autoPtr: less clutter using plain tests with the bool operator
          (!ptr)  vs  (ptr.empty())
          (ptr)   vs  (!ptr.empty())
      - tmp: was entirely unused.
    • Mark Olesen's avatar
      ENH: reset tmp via assignment from literal nullptr (#1775) · 35a0fd3e
      Mark Olesen authored
      - previously this was marked as '= delete' for consistency with
        assignment from an empty pointer being a runtime error.
        However, these can be considered semantically different and it makes
        sense to permit this as equivalent to reset(nullptr).
        This change does not break existing code since the operator was
        previously unavailable (deleted).
      STYLE: refactor tmp operator=(T*)
      - delegate to reset() after initial checks
    • Mark Olesen's avatar
      ENH: simpler, more consistent checks for tmp validity (#1775) · 59bfbb95
      Mark Olesen authored
      - Previously considered to be valid() if it was any reference
        (null or non-null) or a non-null pointer.
        This appears to be a holdover from old code (pre-2015) where
        reinterpret_cast<..>(0) was used instead of the NullObject.
        A reference via a null pointer isn't really possible anywhere. Even
        for things like labelList::null(), they now use the NullObject,
        which has a non-zero memory location.
      - now simply check for a non-zero memory address. Regardless of
        pointer or referenced object.
    • Mark Olesen's avatar
      STYLE: minor code reduction/simplification for tmp (#1775) · d282d1a2
      Mark Olesen authored
      - combine reset() methods by adding a default parameter
      - improve top-level visibility of empty/valid/get methods for symmetry
        symmetry with autoPtr, future adjustment
    • Mark Olesen's avatar
      STYLE: check autoPtr as plain bool instead of valid() · 12c91b94
      Mark Olesen authored
      - cleaner code, more similarity with unique_ptr
            if (ptr)
            if (!ptr)
            if (ptr.valid())
            if (!ptr.valid())
    • Mark Olesen's avatar
      STYLE: simplify short-circuit involving autoPtr (#1775) · 9af3f85c
      Mark Olesen authored
      - with '&&' conditions, often better to check for non-null autoPtr
        first (it is cheap)
      - check as bool instead of valid() method for cleaner code, especially
        when the wrapped item itself has a valid/empty or good.
        Also when handling multiple checks.
            if (ptr && ptr->valid())
            if (ptr1 || ptr2)
            if (ptr.valid() && ptr->valid())
            if (ptr1.valid() || ptr2.valid())