1. 30 Jul, 2020 1 commit
    • Mark Olesen's avatar
      BUG: inconsistent check in non-const '->' dereference (tmp, refPtr) · 23ea498c
      Mark Olesen authored
      - old code just checked for pointer vs non-pointer.
        Should actually treat CREF and REF types differently
        Overseen in commit be058bec. Only affects develop branch
      ENH: improved naming consistency in tmp, refPtr
      - also use long-form to check for pointer type instead of the isTmp()
        method. Makes differences between PTR, CREF, REF easier to spot.
      STYLE: typeName() for tmp, refPtr is static
  2. 21 Jul, 2020 1 commit
    • 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.
  3. 16 Jul, 2020 4 commits
    • 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
  4. 19 Nov, 2019 1 commit
    • Mark Olesen's avatar
      ENH: add move reset and move assignment for tmp, tmpNrc · 83d6aa42
      Mark Olesen authored
      - improves similarity to autoPtr. Simplifies coding.
          tmp<volScalarField> tfield;
          // sometime later...
              volScalarField::New("myfield", mesh, dimensionedScalar(Zero))
      - as per tmp, disallow tmpNrc assignment from literal nullptr
      - as per autoPtr, allow explicit test as bool (same as valid).
  5. 31 Oct, 2019 1 commit
  6. 11 Feb, 2019 1 commit
  7. 06 Feb, 2019 1 commit
  8. 20 Dec, 2018 1 commit
    • Mark Olesen's avatar
      ENH: add get() accessor to tmp classes · 08335beb
      Mark Olesen authored
      - similar to autoPtr and unique_ptr. Returns the pointer value without
        any checks. This provides a simple way for use to use either
        an autoPtr or a tmp for local memory management without accidentally
        stealing the pointer.
           volVectorField* ptr;
           tmp<volVectorField> tempField;
           if (someField.valid())
               ptr = someField.get();
               tempField.reset(new volVectorField(....));
               ptr = tmpField.get();
           const volVectorField& withField = *ptr;
      STYLE: make more tmp methods noexcept
  9. 30 May, 2018 1 commit
  10. 26 Feb, 2018 1 commit
    • 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:
          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()'
          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.
              const tmp<volScalarField>& tfld;
              volScalarField& fld = const_cast<volScalarField&>(tfld());
              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).
  11. 26 Jan, 2018 1 commit
    • Mark Olesen's avatar
      ENH: minor cleanup of the Xfer class · 25339a5b
      Mark Olesen authored
      - simplify structure, removed unused constuctors.
      - transfer from base objects via '=' assignment removed as being too
      - add New factory method with perfect forwarding.
  12. 05 Nov, 2017 1 commit
    • Mark Olesen's avatar
      ENH: enhancements to behaviour of token · c4de3e0a
      Mark Olesen authored
      - improved memory alignment reduces overhead for Int32 compilation
      - added move/swap semantics
      - made the type() readonly in favour of setVariant() to allow change
        of variant within a particular storage representation.
  13. 22 Nov, 2017 2 commits
  14. 14 Jul, 2017 1 commit
  15. 05 Aug, 2016 1 commit
  16. 17 Jun, 2016 1 commit
  17. 23 May, 2016 1 commit
  18. 21 May, 2016 2 commits
  19. 28 Feb, 2016 1 commit
  20. 27 Feb, 2016 1 commit
    • Henry Weller's avatar
      tmp: Limit the number of references to a temporary object to 2 · 0830ace9
      Henry Weller authored
      which reduces the number of potential problems with the reuse of
      temporary objects.
      In order to avoid unnecessary creation of tmp's referring to temporary
      objects the assignment operator now transfers ownership of the object
      and resets the argument.
  21. 26 Feb, 2016 1 commit
    • Henry Weller's avatar
      OpenFOAM: Updated all libraries, solvers and utilities to use the new const-safe tmp · cd852be3
      Henry Weller authored
      The deprecated non-const tmp functionality is now on the compiler switch
      NON_CONST_TMP which can be enabled by adding -DNON_CONST_TMP to EXE_INC
      in the Make/options file.  However, it is recommended to upgrade all
      code to the new safer tmp by using the '.ref()' member function rather
      than the non-const '()' dereference operator when non-const access to
      the temporary object is required.
      Please report any problems on Mantis.
      Henry G. Weller
      CFD Direct.
  22. 25 Feb, 2016 1 commit
  23. 24 Feb, 2016 1 commit
    • Henry Weller's avatar
      tmp: Improved reference count checks to provide better error diagnostics · c02bf70e
      Henry Weller authored
      in case of tmp misuse.
      Simplified tmp reuse pattern in field algebra to use tmp copy and
      assignment rather than the complex delayed call to 'ptr()'.
      Removed support for unused non-const 'REF' storage of non-tmp objects due to C++
      limitation in constructor overloading: if both tmp(T&) and tmp(const T&)
      constructors are provided resolution is ambiguous.
      The turbulence libraries have been upgraded and '-DCONST_TMP' option
      specified in the 'options' file to switch to the new 'tmp' behavior.
  24. 22 Feb, 2016 1 commit
    • Henry Weller's avatar
      tmp: Updated to store and preserve the const-ness of the reference to a constant object · 15b7e87d
      Henry Weller authored
      This change requires that the de-reference operator '()' returns a
      const-reference to the object stored irrespective of the const-ness of
      object stored and the new member function 'ref()' is provided to return
      an non-const reference to stored object which throws a fatal error if the
      stored object is const.
      In order to smooth the transition to this new safer 'tmp' the now
      deprecated and unsafe non-const de-reference operator '()' is still
      provided by default but may be switched-off with the compilation switch
      The main OpenFOAM library has already been upgraded and '-DCONST_TMP'
      option specified in the 'options' file to switch to the new 'tmp'
      behavior.  The rest of OpenFOAM-dev will be upgraded over the following
      few weeks.
      Henry G. Weller
      CFD Direct
  25. 20 Feb, 2016 1 commit
    • Henry Weller's avatar
      Boundary conditions: Added extrapolatedCalculatedFvPatchField · 99a10ece
      Henry Weller authored
      To be used instead of zeroGradientFvPatchField for temporary fields for
      which zero-gradient extrapolation is use to evaluate the boundary field
      but avoiding fields derived from temporary field using field algebra
      inheriting the zeroGradient boundary condition by the reuse of the
      temporary field storage.
      zeroGradientFvPatchField should not be used as the default patch field
      for any temporary fields and should be avoided for non-temporary fields
      except where it is clearly appropriate;
      extrapolatedCalculatedFvPatchField and calculatedFvPatchField are
      generally more suitable defaults depending on the manner in which the
      boundary values are specified or evaluated.
      The entire OpenFOAM-dev code-base has been updated following the above
      Henry G. Weller
      CFD Direct
  26. 12 Feb, 2016 1 commit
  27. 17 Jul, 2015 2 commits
  28. 11 Oct, 2012 2 commits
  29. 14 Aug, 2011 1 commit
  30. 19 Jan, 2011 1 commit
  31. 14 Jan, 2011 1 commit
  32. 07 Jan, 2011 1 commit
  33. 05 Jan, 2011 1 commit