1. 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
  2. 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).
  3. 31 Oct, 2019 1 commit
  4. 05 Nov, 2019 1 commit
  5. 13 Jun, 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. 28 May, 2018 1 commit
  15. 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
  16. 14 Jul, 2017 2 commits
  17. 13 Jul, 2017 1 commit
  18. 03 Dec, 2016 1 commit
  19. 05 Aug, 2016 1 commit
  20. 17 Jun, 2016 1 commit
  21. 23 May, 2016 1 commit
  22. 21 May, 2016 2 commits
  23. 22 Mar, 2016 1 commit
  24. 28 Feb, 2016 1 commit
  25. 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.
  26. 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.
  27. 25 Feb, 2016 2 commits
  28. 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.
  29. 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
  30. 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
  31. 12 Feb, 2016 1 commit
  32. 08 Nov, 2015 1 commit