Commit Graph

23 Commits

Author SHA1 Message Date
Mark Olesen
f75af788c1 ENH: add factory method readContents to IO containers
- useful when regular contents are to be read via an IOobject and
  returned.

  Eg,  dictionary propsDict(IOdictionary::readContents(dictIO));
  vs.  dictionary propsDict(static_cast<dictionary&&>(IOdictionary(dictIO)));

  Commonly these would have simply been constructed directly as the
  IO container:

  eg,  IOdictionary propsDict(dictIO);

  However, that style may not ensure proper move semantics for return
  types.

  Now,
  =====
      labelList decomp(labelIOList::readContents(io));
      ... something
      return decomp;
  =====

  Previously,
  =====
      labelIOList decomp(io);

      // Hope for the best...
      return decomp;

      // Or be explicit and ensure elision occurs...
      return labelList(std::move(static_cast<labelList&>(decomp)));
  =====

  Note:
       labelList list(labelIOList(io));

       looks like a good idea, but generally fails to compile
2023-02-28 15:43:26 +01:00
Mark Olesen
5d9456187d ENH: zero tag for constructing various IO types
- for int64 compilations this disambiguates between '0' as int32 (size)
  or as bool 'false' for local processor validity

  Eg,

     IOList list(io, 0);     <- With label-size 64: is this bool or label?
     IOList list(io, Zero);  <- Size = 0 (int32/int64), not a bool
2022-05-12 13:47:03 +02:00
Mark Olesen
33693f32b6 ENH: wrapped IOField, IOList, IOmapDistributePolyMesh
- Uses a refPtr to reference external content.
  Useful (for example) when writing data without copying.
  Reading into external locations is not implemented
  (no current requirement for that).

    * IOFieldRef -> IOField
    * IOListRef -> IOList
    * IOmapDistributePolyMeshRef -> IOmapDistributePolyMesh

  Eg,

    labelList addressing = ...;

    io.rename("cellProcAddressing");
    IOListRef<label>(io, addressing).write();

  Or,
    primitivePatch patch = ...;
    IOFieldRef<vector>(io, patch.localPoints()).write();
2022-05-10 10:47:01 +02:00
Mark Olesen
4cbe0a81ac ENH: consolidate read handling within various regIOobjects 2022-04-29 11:44:28 +02:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
3d608bf06a ENH: remove reliance on the Xfer class (issue #639)
This class is largely a pre-C++11 holdover. It is now possible to
simply use move construct/assignment directly.

In a few rare cases (eg, polyMesh::resetPrimitives) it has been
replaced by an autoPtr.
2018-03-05 13:28:53 +01:00
Andrew Heather
d8d6030ab6 INT: Integration of Mattijs' collocated parallel IO additions
Original commit message:
------------------------

Parallel IO: New collated file format

When an OpenFOAM simulation runs in parallel, the data for decomposed fields and
mesh(es) has historically been stored in multiple files within separate
directories for each processor.  Processor directories are named 'processorN',
where N is the processor number.

This commit introduces an alternative "collated" file format where the data for
each decomposed field (and mesh) is collated into a single file, which is
written and read on the master processor.  The files are stored in a single
directory named 'processors'.

The new format produces significantly fewer files - one per field, instead of N
per field.  For large parallel cases, this avoids the restriction on the number
of open files imposed by the operating system limits.

The file writing can be threaded allowing the simulation to continue running
while the data is being written to file.  NFS (Network File System) is not
needed when using the the collated format and additionally, there is an option
to run without NFS with the original uncollated approach, known as
"masterUncollated".

The controls for the file handling are in the OptimisationSwitches of
etc/controlDict:

OptimisationSwitches
{
    ...

    //- Parallel IO file handler
    //  uncollated (default), collated or masterUncollated
    fileHandler uncollated;

    //- collated: thread buffer size for queued file writes.
    //  If set to 0 or not sufficient for the file size threading is not used.
    //  Default: 2e9
    maxThreadFileBufferSize 2e9;

    //- masterUncollated: non-blocking buffer size.
    //  If the file exceeds this buffer size scheduled transfer is used.
    //  Default: 2e9
    maxMasterFileBufferSize 2e9;
}

When using the collated file handling, memory is allocated for the data in the
thread.  maxThreadFileBufferSize sets the maximum size of memory in bytes that
is allocated.  If the data exceeds this size, the write does not use threading.

When using the masterUncollated file handling, non-blocking MPI communication
requires a sufficiently large memory buffer on the master node.
maxMasterFileBufferSize sets the maximum size in bytes of the buffer.  If the
data exceeds this size, the system uses scheduled communication.

The installation defaults for the fileHandler choice, maxThreadFileBufferSize
and maxMasterFileBufferSize (set in etc/controlDict) can be over-ridden within
the case controlDict file, like other parameters.  Additionally the fileHandler
can be set by:
- the "-fileHandler" command line argument;
- a FOAM_FILEHANDLER environment variable.

A foamFormatConvert utility allows users to convert files between the collated
and uncollated formats, e.g.
    mpirun -np 2 foamFormatConvert -parallel -fileHandler uncollated

An example case demonstrating the file handling methods is provided in:
$FOAM_TUTORIALS/IO/fileHandling

The work was undertaken by Mattijs Janssens, in collaboration with Henry Weller.
2017-07-07 11:39:56 +01:00
Henry Weller
95d146ecdf Rationalized the indentation of C-preprocessor directives 2016-02-29 15:42:03 +00:00
Henry Weller
56fa7c0906 Update code to use the simpler C++11 template syntax removing spaces between closing ">"s 2016-01-10 22:41:16 +00:00
Henry
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
andy
eaef8d482b STYLE: Updated 1991 start copyright year to 2004 2011-01-14 16:08:00 +00:00
andy
099cc39e2e Revert "STYLE: 2011 copyright date."
This reverts commit b18f6cc1ce.
2011-01-05 18:24:29 +00:00
graham
b18f6cc1ce STYLE: 2011 copyright date. 2011-01-05 11:14:26 +00:00
graham
d79237597e STYLE: Fixing code style requirements for all src. 2010-07-28 13:31:46 +01:00
Mark Olesen
b6f3bd4c23 STYLE: follow coding guide recommendation for '//- Destructor' 2010-04-12 11:55:52 +02:00
Mark Olesen
d29c438657 STYLE: use url for FSF license instead of postal address, switch to GPL v3 2010-03-29 14:07:56 +02:00
Mark Olesen
19503c93e1 rename xfer<T> class to Xfer<T>
- The capitalization is consistent with most other template classes, but
  more importantly frees up xfer() for use as method name without needing
  special treatment to avoid ambiguities.

  It seems reasonable to have different names for transfer(...) and xfer()
  methods, since the transfer is occuring in different directions.
  The xfer() method can thus replace the recently introduced zero-parameter
  transfer() methods.
  Other name candidates (eg, yield, release, etc.) were deemed too abstract.
2009-01-05 12:30:19 +01:00
Mark Olesen
28b200bcd9 update copyrights for 2009 2008-12-31 19:01:56 +01:00
Mark Olesen
91cb6d2912 xfer class modifications:
- removed operator* in favour of operator() for consistency with tmp
    class. The previous use of operator() for const casting didn't work
    anyhow due to template confusion.
  - added xferCopy(), xferMove() and xferTmp() template functions instead
  - preliminary changes to IOobjects and Fields for xfer
2008-10-17 18:27:11 +02:00
Mark Olesen
7e9846a524 IOobjects - consistency fixes
- consistent constructors and consistent behaviour with MUST_READ,
    READ_IF_PRESENT
2008-10-14 16:05:21 +02:00
Mark Olesen
02cabc3cf2 updated Copyright (C) \d+-2008 OpenCFD Ltd. 2008-06-25 15:01:46 +02:00
OpenFOAM-admin
3170c7c0c9 Creation of OpenFOAM-dev repository 15/04/2008 2008-04-15 18:56:58 +01:00