Commit Graph

155 Commits

Author SHA1 Message Date
Mark Olesen
d578d48a4f ENH: improve findInstance handling for optional files
- previously would always return "constant" as the instance for
  an optional dir/file that wasn't found.
  However, this meant retesting to screen out false positives.
  Now support an additional parameter
      'bool constant_fallback = ...'
  to return "constant" or an empty word.

  The method signature changes slightly with a new optional bool
  parameter:

      //! Return \c "constant" instead of \c "" if the search failed
      const bool constant_fallback = true

ENH: code consolidation for findInstancePath

- relocate from Time to TimePaths and provide an additional static
  version that is reused in fileOperations

BUG: distributedTriSurfaceMesh:::findLocalInstance broken (#3135)

- was not checking the parent at all.

COMP: remove unused findInstancePath(const fileName&, ..) method
2024-04-10 15:55:29 +02:00
Mark Olesen
7e0acfa4ed ENH: handle 64-bit memory information (#3060)
- on large memory systems (eg, 6TB) the process information
  exceeds an 'int' range, so adjust parsing of the /proc/..
  to use int64

ENH: update/modernize OSspecific system information

ENH: minor update of profiling code

- std::string, noexcept, lazier evaluations

STYLE: use direct call of memInfo
2023-12-15 17:21:38 +01:00
mattijs
9ed0bb1e4f ENH: redistributePar: update for distribute mode
- uses read&write handlers
- fixes initialisation of partial handlers
- 'uniform' copied to wrong place
- -overwrite not deleting old processors dirs
2023-11-21 11:14:28 +00:00
Mark Olesen
269be2f4ea ENH: provide Time::NewGlobalTime factory methods (#3007)
- avoids clutter of argList::envGlobalPath() ...

ENH: allow temporary overwriting of output writeFormat

- allows switching for particular output routines

COMP: explicitly use TimePaths methods with Time

- this simplifies any overloading done at a later stage
2023-11-07 10:33:47 +01:00
Mark Olesen
dafae668d1 ENH: support user specification of ensight time format/precision (#2999)
- new format option keywords: timeFormat, timePrecision

CONFIG: default ensight output is now consistently BINARY

- this removes some uncertainty with the ensightWrite functionObject
  which was previously dependent on the simulation writeFormat
  and makes its behaviour consistent with foamToEnsight

  Note: binary Ensight output is consistent with the
  defaults for VTP output (inline binary)

ENH: minor adjustment of ensight writing methods
2023-10-19 10:28:09 +00:00
Mark Olesen
a215f94ec4 ENH: expose read option for Time construction
- Time is normally constructed with READ_MODIFIED for its controlDict
  and objectRegistry, but for certain applications (eg, redistributePar)
  it can be useful to construct without file monitoring and specifying
  MUST_READ instead.

  Example,

  Info<< "Create time\n" << Foam::endl;
  Time runTime
  (
      Time::controlDictName,
      args,
      false,   // Disallow functionObjects
      true,    // Allow controlDict "libs"
      IOobjectOption::MUST_READ  // Instead of READ_MODIFIED
  );
2023-07-04 17:25:25 +02:00
Mark Olesen
d5a0eaeeee STYLE: changes to Time and TimeState
- update TimeState access methods

- use writeTime() instead of old method name outputTime()

- use deltaTValue() instead of deltaT().value()
  to avoids pointless construct of intermediate
2023-07-04 17:25:25 +02:00
mattijs
09edb23c1d BUG: collated fails with controlDict watch files
- files might have been set during token reading so only on
  known on master processor.
  Broadcast names to all processors (even alhough they are only
  checked on master) so that the watched states remain synchronised
2023-06-21 14:56:06 +02:00
Mark Olesen
1685e8e418 INT: objectRegistry: optionally caching temporary objects (#2723)
- functionality introduced by openfoam.org to support selective
  caching of temporary fields. The purpose is two-fold: to enable
  diagnostics and to allow more places to use unregistered fields by
  default.

  For example to cache the grad(k) field in

    cacheTemporaryObjects
    (
        grad(k)
    );

  If the name of a field which in never constructed is added to the
  cacheTemporaryObjects list a waning message is generated which
  includes a useful list of ALL the temporary fields constructed
  during the time step

  Multiple regions are also supported by specifying individual region
  names in a cacheTemporaryObjects dictionary.

    cacheTemporaryObjects
    {
        porous
        (
            porosityBlockage:UNbr
        );
    }

    functions
    {
        writePorousObjects
        {
            type        writeObjects;
            libs        (utilityFunctionObjects);

            region      porous;
            writeControl writeTime;
            writeOption anyWrite;

            objects     (porosityBlockage:UNbr);
        }
    }
2023-05-09 19:30:58 +02:00
Mark Olesen
8a70c898ae STYLE: make IOobject time() noexcept. Use explicit REGISTER/NO_REGISTER 2023-01-23 14:52:29 +01:00
mattijs
286c6ce7d8 ENH: Foam::readLink(..)
- recover the target of symbolic links.
  This is needed when re-creating a file tree on another rank.

ENH: handle checkGzip, followLink flags in fileHander filePath()

- previously just relied on the backend defaults, now pass through
- separate init(...) for common constructor init steps
2022-11-26 01:13:53 +01:00
Mark Olesen
d938e01d7a ENH: refactor IOobject options
- IOobjectOption class encapsulates read/write, storage flags for
  lightweight handling, independent of objectRegistry etc.

ENH: add IOobject isReadRequired() and isReadOptional() queries

- encapsulates test of MUST_READ, MUST_READ_IF_MODIFIED,
  READ_IF_PRESENT for convenience / less clutter.

Example,

    if (isReadRequired() || (isReadOptional() && headerOk()))
    {
        ...
    }

Instead of

    if
    (
        (
            readOpt() == IOobject::MUST_READ
         || readOpt() == IOobject::MUST_READ_IF_MODIFIED
        )
     || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        ...
    }
2022-10-04 15:51:26 +02:00
Mark Olesen
88061f3b28 ENH: improved argList handling of libs, functionObjects
- include -no-libs option by default, similar to '-lib',
  which makes it available to all solvers/utilities.
  Add argList allowLibs() method to query it.

- relocate with/no functionObjects logic from Time to argList
  itself as argList allowFunctionObjects()

- add libs/functionObjects override handling to decomposePar etc

ENH: report the stream relativeName for IOerrors (see c9333a5ac8)
2022-09-22 16:08:52 +02:00
Mark Olesen
3d892ace29 STYLE: set readOpt(..), writeOpt(..) by parameter, not by assignment
STYLE: qualify format/version/compression with IOstreamOption not IOstream

STYLE: reduce number of lookups when scanning {fa,fv}Solution

STYLE: call IOobject::writeEndDivider as static
2022-07-19 11:17:47 +02:00
Mark Olesen
430281bced ENH: align fileOperations/masterUncollatedFileOperation findInstance()
- adds handling of negative start times for masterUncollatedFileOperation
  as well (#1112).

- handle failures *after* restoring non-parRun mode.
  This ensures exit(FatalError) will exit MPI properly as well.

STYLE: replace "polyMesh" with polyMesh::meshSubDir

STYLE: adjust IOobject read/write enumerated values

- provision for possible bitwise handling
2022-04-29 11:44:28 +02:00
Ivor Clifford
0d3e84eb10 BUG: Time: correct the user-time operation for time-precision adaptations (fixes #2328) 2022-01-20 10:04:18 +00:00
Mark Olesen
9a2a22a03a ENH: provide setter methods for IOobject read/write options etc.
- simplifies local toggling.

- centralize fileModification static variables into IOobject.
  They were previously scattered between IOobject and regIOobject
2021-03-17 15:10:00 +01:00
Mark Olesen
6e3bc1f7d0 STYLE: can add compile-time deprecated message for autoPtr::set()
- deprecated Feb-2018, but not marked as such.

  The set() method originally enforce an additional run-time check
  (Fatal if pointer was already set), but this was rarely used.
  In fact, the set() method was invariably used in constructors
  where the pointer by definition was unset.

  Can now mark as deprecated to catch the last of these.
  We prefer reset() for similarity with std::unique_ptr

  Eg,
  FOAM_EXTRA_CXXFLAGS="-DFoam_autoPtr_deprecate_setMethod"  wmake
2020-11-19 16:57:45 +01:00
Mark Olesen
41d3e6f1d4 ENH: various dlLibraryTable improvements/refinements (#1737)
- libs() singleton method for global library handling

- explicit handling of empty filename for dlLibraryTable open/close.
  Largely worked before, but now be more explicit about its behaviour.

- add (key, dict) constructor and open() methods.
  More similarity to dimensionedType, Enum etc, and there is no
  ambiguity with the templated open().

- construct or open from initializer_list of names

- optional verbosity when opening with auxiliary table,
  avoid duplicate messages or spurious messages for these.

- basename and fullname methods (migrated from dynamicCode).

- centralise low-level load/unload hooks

- adjust close to also dlclose() aliased library names.
2020-07-14 11:19:05 +02:00
Mark Olesen
a088bda4d2 ENH: use unique_ptr for memory management of profiling
- makes it easier to distinguish between pointers referring to pool
  data versus pointers actually holding storage, avoids
  manual demand-driven deletion and autoPtr.

ENH: simplify/improve Pstream profiling

- times now double (not scalar) for consistency with what cpuTime
  delivers

- use bool to track suspend state
2020-07-09 16:17:33 +02:00
Mark Olesen
ddfe9ae2a3 COMP: adjustments for SPDP, int64 2020-06-16 21:30:12 +02:00
Mark Olesen
3e43edf056 ENH: unify use of dictionary method names
- previously introduced `getOrDefault` as a dictionary _get_ method,
  now complete the transition and use it everywhere instead of
  `lookupOrDefault`. This avoids mixed usage of the two methods that
  are identical in behaviour, makes for shorter names, and promotes
  the distinction between "lookup" access (ie, return a token stream,
  locate and return an entry) and "get" access (ie, the above with
  conversion to concrete types such as scalar, label etc).
2020-06-02 17:26:03 +02:00
Mark Olesen
a5a504693a ENH: support disable libs when constructing Time from argList (#1714)
- previously relied on presence/absence of command-line options.
  Can now explicitly disable individually

- provide shorter constructors for dealing with these types of cases.
  Make construction with non-default names for "system" and "constant"
  lengthier so there is no ambiguity.
2020-05-23 15:28:32 +02:00
mattijs
392d497d30 BUG: Time: check for processorsDDD. Fixes #1679. 2020-04-15 12:50:10 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
da33222970 ENH: add flexible command options for setting Debug and Info switches #1467
For example,

   $ someSolver -info-switch writeOptionalEntries

- note that values changed via the command-line are changed after the
  etc/controlDict entries, but *before* any case-local
  system/controlDict entries.

  However, in many testing cases the command-line options eliminate
  the need for such local file modifications.

ENH: cleanup handling of local debug switches in Time

- add as methods directly on simpleObjectRegistry to avoid code
  duplication

STYLE: adjust internal naming of ITstream parameters
2019-10-25 15:03:11 +02:00
Mark Olesen
4cc7bf1468 ENH: support writeControl 'none' (#1448)
- for special cases when normal writing is to be completely disabled
  and replaced with alternate means (eg, via a function object).

- support "adjustable" as "adjustableRunTime" alias to reduce typing
  for writeControl or outputControl
2019-09-27 15:46:26 +02:00
Mark Olesen
6eaa326cec ENH: support additional command-line loading of libraries (#1414)
- this can be useful for preloading of libraries, or for utilities
  that don't use system/controlDict.

  The additional libraries can be specified individually:

      myUtil -lib lib1 -lib lib2 -lib lib3

  When specified like this, the options add up.

  Or as a 'captured' list using OpenFOAM's standard arg list handling:

      myUtil -lib '(' lib1  lib2 lib3 ')'
      myUtil -lib \( lib1  lib2 lib3 \)

  or as single argument list:

      myUtil -lib '("lib1" "lib2" "lib3")'

  When specified as a single argument, would normally take advantage
  of the transparent handling of word vs fileName and omit the string
  quotes:

      myUtil -lib '(lib1 lib2 lib3)'

ENH: dlOpen error messages now propagated into dlLibraryTable

- this makes the context more relevant and also avoids the previous
  annoyance of double warnings (one from the POSIX loader, and one
  from dlLibraryTable)

STYLE: mark -noFunctionObjects and -withFunctionObjects as 'advanced'

- reduces clutter. Still visible with -help-full
2019-08-30 15:33:29 +02:00
Mark Olesen
4c91d068fa ENH: added Time::New factory method
- creates a dummy time, which is useful when a local object registry
  is needed
2019-08-02 12:44:47 +02:00
Mark Olesen
9b0ff60320 STYLE: simplify return statement 2019-06-24 09:29:56 +02:00
Kutalmis Bercin
350fe1a2d8 ENH: add query function isAdjustTimeStep() 2019-06-14 16:48:28 +01:00
Mark Olesen
805cc59543 ENH: force clearing of Time objectRegistry on destruction (#1276)
- the objectRegistry destructor seems to be called too late.
  Explicitly clear the objectRegistry within the Time destructor to
  ensure that it always happens.
2019-04-10 11:30:31 +02:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
3b74512231 ENH: cleanup of Enum class
- more dictionary-like methods, enforce keyType::LITERAL for all
  lookups to avoid any spurious keyword matching.

- new readEntry, readIfPresent methods

- The get() method replaces the now deprecate lookup() method.

- Deprecate lookupOrFailsafe()
  Failsafe behaviour is now an optional parameter for lookupOrDefault,
  which makes it easier to tailor behaviour at runtime.

- output of the names is now always flatted without line-breaks.
  Thus,

     os << flatOutput(someEnumNames.names()) << nl;
     os << someEnumNames << nl;

  both generate the same output.

- Constructor now uses C-string (const char*) directly instead of
  Foam::word in its initializer_list.

- Remove special enum + initializer_list constructor form since
  it can create unbounded lookup indices.

- Removd old hasEnum, hasName forms that were provided during initial
  transition from NamedEnum.

- Added static_assert on Enum contents to restrict to enum or
  integral values.  Should not likely be using this class to enumerate
  other things since it internally uses an 'int' for its values.

  Changed volumeType accordingly to enumerate on its type (enum),
  not the class itself.
2018-10-18 12:57:32 +02:00
Mark Olesen
c6520033c9 ENH: rationalize dictionary access methods
- use keyType::option enum to consolidate searching options.
  These enumeration names should be more intuitive to use
  and improve code readability.

    Eg,   lookupEntry(key, keyType::REGEX);
    vs    lookupEntry(key, false, true);

  or

    Eg,   lookupEntry(key, keyType::LITERAL_RECURSIVE);
    vs    lookupEntry(key, true, false);

- new findEntry(), findDict(), findScoped() methods with consolidated
  search options for shorter naming and access names more closely
  aligned with other components. Behave simliarly to the
  methods lookupEntryPtr(), subDictPtr(), lookupScopedEntryPtr(),
  respectively. Default search parameters consistent with lookupEntry().

    Eg, const entry* e = dict.findEntry(key);
    vs  const entry* e = dict.lookupEntryPtr(key, false, true);

- added '*' and '->' dereference operators to dictionary searchers.
2018-10-15 16:16:12 +02:00
Mark Olesen
f00c7a655c COMP: rename dictionary::read<T> to dictionary::readEntry<T>
- avoids compiler ambiguity when virtual methods such as
  IOdictionary::read() exist.

- the method was introduced in 1806, and was thus not yet widely used
2018-07-30 15:52:40 +02:00
Mark Olesen
2662042d49 ENH: improve controls for Time (issue #910)
- relocate some standard functionality to TimePaths to allow a lighter
  means of managing time directories without using the entire Time
  mechanism.

- optional enableLibs for Time construction (default is on)
  and a corresponding argList::noLibs() and "-no-libs" option

STYLE:

- mark Time::outputTime() as deprecated MAY-2016

- use pre-increment for runTime, although there is no difference in
  behaviour or performance.
2018-07-02 10:20:01 +02:00
Henry Weller
8959b8e00a ENH: Improvements to the fileHandler and collated IO
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
variable.

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

    processors6_0-2
    processors6_3-5

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:

    processors6_0-2/
    processors6_3-5/

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
2018-03-21 12:42:22 +00:00
Mark Olesen
dd8341f659 ENH: make format of ExecutionTime = ... output configurable (issue #788)
- controlled by the the 'printExecutionFormat' InfoSwitch in
  etc/controlDict

      // Style for "ExecutionTime = " output
      // - 0 = seconds (with trailing 's')
      // - 1 = day-hh:mm:ss

   ExecutionTime = 112135.2 s  ClockTime = 113017 s

   ExecutionTime = 1-07:08:55.20  ClockTime = 1-07:23:37

- Callable via the new Time::printExecutionTime() method,
  which also helps to reduce clutter in the applications.
  Eg,

     runTime.printExecutionTime(Info);

  vs

     Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
         << "  ClockTime = " << runTime.elapsedClockTime() << " s"
         << nl << endl;

--

ENH: return elapsedClockTime() and clockTimeIncrement as double

- previously returned as time_t, which is less portable.
2018-04-27 15:00:34 +02:00
Mark Olesen
4cf932b230 STYLE: reorder/refactor stream format options
- IOstreamOption class to encapsulate format, compression, version.
  This is ordered to avoid internal padding in the structure, which
  reduces several bytes of memory overhead for stream objects
  and other things using this combination of data.

  Byte-sizes:
      old  IOstream:48  PstreamBuffers:88  Time:928
      new  IOstream:24  PstreamBuffers:72  Time:904

====

STYLE: remove support for deprecated uncompressed/compressed selectors

In older versions, the system/controlDict used these types of
specifications:

    writeCompression uncompressed;
    writeCompression compressed;

As of DEC-2009, these were deprecated in favour of using normal switch
names:

    writeCompression true;
    writeCompression false;
    writeCompression on;
    writeCompression off;

Now removed these deprecated names and treat like any other unknown
input and issue a warning. Eg,

   Unknown compression specifier 'compressed', assuming no compression

====

STYLE: provide Enum of stream format names (ascii, binary)

====

COMP: fixed incorrect IFstream construct in FIREMeshReader

- spurious bool argument (presumably meant as uncompressed) was being
  implicitly converted to a versionNumber. Now caught by making
  IOstreamOption::versionNumber constructor explicit.

- bad version specifier in changeDictionary
2018-04-12 20:32:20 +02:00
Mark Olesen
97dc9f4029 EHN: make signal verbosity an optional calling argument. 2018-04-11 21:35:02 +02:00
Mark Olesen
d901b4f450 ENH: reduce profiling overhead (issue #764)
- avoid clockTime in favour of clockValue.

- avoid allocations when profiling is not active.

- replace hashing with manual pointer lists
2018-03-26 21:38:47 +02:00
Mark Olesen
36719bf55b STYLE: consistent lookupOrDefault template parameters
- in many cases can just use lookupOrDefault("key", bool) instead of
  lookupOrDefault<bool> or lookupOrDefault<Switch> since reading a
  bool from an Istream uses the Switch(Istream&) anyhow

STYLE: relocated Switch string names into file-local scope
2018-03-26 09:09:09 +02:00
Mark Olesen
345a2a42f1 ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
  and HashTable method names. This improves method name consistency
  between classes and also requires less typing effort:

    args.found(optName)        vs.  args.optionFound(optName)
    args.readIfPresent(..)     vs.  args.optionReadIfPresent(..)
    ...
    args.opt<scalar>(optName)  vs.  args.optionRead<scalar>(optName)
    args.read<scalar>(index)   vs.  args.argRead<scalar>(index)

- the older method names forms have been retained for code compatibility,
  but are now deprecated
2018-01-08 15:35:18 +01:00
Mark Olesen
ca5b0dcbaa ENH: improvements to Time
- expose the names of write and stopAt controls for reuse elsewhere and
  provide a stopAtControls enum for 'unknown'

- track the requested number of sub-cycles (was previously a bool)
2017-11-28 10:11:06 +01:00
Mark Olesen
fab9fb4332 STYLE: use readScalar(std::string) and readInt(std::string) wrappers 2017-11-28 10:08:36 +01:00
Mark Olesen
416a3790ea STYLE: prefer autoPtr::reset() to autoPtr::set()
- in most cases already checked valid() so don't need additional check
  for setting an existing pointer
2017-11-22 19:11:11 +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
Mark Olesen
b287d1bddd CONFIG: cpu/sys information in profiling now OFF by default (issue #526)
- since the cpu/sys information is invariant, it doesn't make much
  sense to emit by default at every time-step.
2017-07-14 16:41:15 +02:00