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. 22 Jul, 2020 1 commit
  3. 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.
  4. 16 Jul, 2020 5 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
  5. 25 Mar, 2020 1 commit
  6. 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).
  7. 31 Oct, 2019 1 commit
  8. 05 Nov, 2019 1 commit
  9. 22 Aug, 2019 1 commit
  10. 12 Jul, 2019 1 commit
  11. 13 Jun, 2019 1 commit
  12. 03 May, 2019 1 commit
  13. 11 Feb, 2019 1 commit
  14. 06 Feb, 2019 1 commit
  15. 25 Jan, 2019 1 commit
  16. 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
  17. 11 Nov, 2018 1 commit
  18. 30 Jul, 2018 1 commit
  19. 30 May, 2018 1 commit
  20. 19 Mar, 2018 1 commit
  21. 28 Feb, 2018 1 commit
    • Mark Olesen's avatar
      ENH: add Xfer rvalue(), valid() methods · 081783db
      Mark Olesen authored
      - rvalue() is a (transitional) means of converting Xfer content to a
        reference for move construct, move assign semantics.
      - valid() method for consistency with autoPtr and tmp classes
  22. 26 Feb, 2018 2 commits
    • 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).
    • 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_();
  23. 04 Mar, 2018 1 commit
    • Mark Olesen's avatar
      ENH: pre-cleanup of Xfer class (issue #639) · b4703f4a
      Mark Olesen authored
      - This class is largely a pre-C++11 holdover, prior to having movable
      - align internals with autoPtr instead of always unconditionally
        allocating memory. The valid() method can be used to check for a null
      - Consolidate into a single file, in anticipation of future removal.
  24. 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.
  25. 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.
  26. 22 Nov, 2017 2 commits
  27. 28 May, 2018 1 commit
  28. 21 Mar, 2018 1 commit
    • Henry Weller's avatar
      ENH: Improvements to the fileHandler and collated IO · 8959b8e0
      Henry Weller authored
      Improvements to existing functionality
        - MPI is initialised without thread support if it is not needed e.g. uncollated
        - Use native c++11 threading; avoids problem with static destruction order.
        - etc/cellModels now only read if needed.
        - etc/controlDict can now be read from the environment variable FOAM_CONTROLDICT
        - Uniform files (e.g. '0/uniform/time') are now read only once on the master only
          (with the masterUncollated or collated file handlers)
        - collated format writes to 'processorsNNN' instead of 'processors'.  The file
          format is unchanged.
        - Thread buffer and file buffer size are no longer limited to 2Gb.
      The global controlDict file contains parameters for file handling.  Under some
      circumstances, e.g. running in parallel on a system without NFS, the user may
      need to set some parameters, e.g. fileHandler, before the global controlDict
      file is read from file.  To support this, OpenFOAM now allows the global
      controlDict to be read as a string set to the FOAM_CONTROLDICT environment
      The FOAM_CONTROLDICT environment variable can be set to the content the global
      controlDict file, e.g. from a sh/bash shell:
          export FOAM_CONTROLDICT=$(foamDictionary $FOAM_ETC/controlDict)
      FOAM_CONTROLDICT can then be passed to mpirun using the -x option, e.g.:
          mpirun -np 2 -x FOAM_CONTROLDICT simpleFoam -parallel
      Note that while this avoids the need for NFS to read the OpenFOAM configuration
      the executable still needs to load shared libraries which must either be copied
      locally or available via NFS or equivalent.
      New: Multiple IO ranks
      The masterUncollated and collated fileHandlers can now use multiple ranks for
      writing e.g.:
          mpirun -np 6 simpleFoam -parallel -ioRanks '(0 3)'
      In this example ranks 0 ('processor0') and 3 ('processor3') now handle all the
      I/O.  Rank 0 handles 0,1,2 and rank 3 handles 3,4,5.  The set of IO ranks should always
      include 0 as first element and be sorted in increasing order.
      The collated fileHandler uses the directory naming processorsNNN_XXX-YYY where
      NNN is the total number of processors and XXX and YYY are first and last
      processor in the rank, e.g. in above example the directories would be
      and each of the collated files in these contains data of the local ranks
      only. The same naming also applies when e.g. running decomposePar:
      decomposePar -fileHandler collated -ioRanks '(0 3)'
      New: Distributed data
      The individual root directories can be placed on different hosts with different
      paths if necessary.  In the current framework it is necessary to specify the
      root per slave process but this has been simplified with the option of specifying
      the root per host with the -hostRoots command line option:
          mpirun -np 6 simpleFoam -parallel -ioRanks '(0 3)' \
              -hostRoots '("machineA" "/tmp/" "machineB" "/tmp")'
      The hostRoots option is followed by a list of machine name + root directory, the
      machine name can contain regular expressions.
      New: hostCollated
      The new hostCollated fileHandler automatically sets the 'ioRanks' according to
      the host name with the lowest rank e.g. to run simpleFoam on 6 processors with
      ranks 0-2 on machineA and ranks 3-5 on machineB with the machines specified in
      the hostfile:
          mpirun -np 6 --hostfile hostfile simpleFoam -parallel -fileHandler hostCollated
      This is equivalent to
          mpirun -np 6 --hostfile hostfile simpleFoam -parallel -fileHandler collated -ioRanks '(0 3)'
      This example will write directories:
      A typical example would use distributed data e.g. no two nodes, machineA and
      machineB, each with three processes:
          decomposePar -fileHandler collated -case cavity
          # Copy case (constant/*, system/*, processors6/) to master:
          rsync -a cavity machineA:/tmp/
          # Create root on slave:
          ssh machineB mkdir -p /tmp/cavity
          # Run
          mpirun --hostfile hostfile icoFoam \
              -case /tmp/cavity -parallel -fileHandler hostCollated \
              -hostRoots '("machineA" "/tmp" "machineB" "/tmp")'
      Contributed by Mattijs Janssens
  29. 14 Jul, 2017 2 commits
  30. 13 Jul, 2017 1 commit
  31. 25 Apr, 2017 1 commit
  32. 16 Mar, 2017 1 commit
  33. 03 Dec, 2016 1 commit