An encapsulation of filesystem-related operations. More...
Public Types | |
enum | pathType : int { NOTFOUND = 0, ABSOLUTE, OBJECT, WRITEOBJECT, PROCUNCOLLATED, PROCBASEOBJECT = PROCUNCOLLATED + 1, PROCOBJECT = PROCBASEOBJECT + 1, PARENTOBJECT, FINDINSTANCE, PROCUNCOLLATEDINSTANCE, PROCBASEINSTANCE, PROCINSTANCE } |
Enumeration for the location of an IOobject. More... | |
typedef Tuple2< fileName, Tuple2< pathType, int > > | dirIndex |
Augment fileName with pathType and local offset. More... | |
typedef List< dirIndex > | dirIndexList |
typedef IntRange< int > | procRangeType |
For addressing a range of processors, identical to UPstream::rangeType. More... | |
Public Member Functions | |
TypeName ("fileOperation") | |
Runtime type information. More... | |
fileOperation (const label comm, const labelUList &ioRanks=labelUList::null(), const bool distributedRoots=false) | |
Construct from communicator, optionally with specified io-ranks and/or distributed roots. More... | |
fileOperation (const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots=false) | |
Construct from communicator with specified io-ranks. More... | |
declareRunTimeSelectionTable (autoPtr, fileOperation, word,(bool verbose),(verbose)) | |
declareRunTimeSelectionTable (autoPtr, fileOperation, comm,(const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots, bool verbose),(commAndIORanks, distributedRoots, verbose)) | |
virtual | ~fileOperation ()=default |
Destructor. More... | |
label | comm () const noexcept |
Communicator to use. More... | |
label | comm (label communicator) const noexcept |
Set communicator to use [mutable]. Negative values are a no-op. More... | |
bool | distributed () const noexcept |
Distributed roots (parallel run) More... | |
bool | distributed (bool on) const noexcept |
Set distributed roots on/off [mutable]. More... | |
const labelList & | ioRanks () const noexcept |
The list of IO ranks (global ranks) More... | |
InfoProxy< fileOperation > | info () const noexcept |
Return info proxy, used to print information to a stream. More... | |
virtual bool | good () const |
True if the fileOperation can be considered valid. At the moment, primarily used to detect the dummy fileOperation. More... | |
virtual void | storeComm () const =0 |
Transfer ownership of communicator to this fileOperation. Use with caution. More... | |
virtual bool | mkDir (const fileName &, mode_t=0777) const =0 |
Make directory. More... | |
virtual bool | chMod (const fileName &, const mode_t) const =0 |
Set the file mode. More... | |
virtual mode_t | mode (const fileName &, const bool followLink=true) const =0 |
Return the file mode. More... | |
virtual fileName::Type | type (const fileName &, const bool followLink=true) const =0 |
Return the file type: DIRECTORY, FILE or SYMLINK. More... | |
virtual bool | exists (const fileName &, const bool checkGzip=true, const bool followLink=true) const =0 |
Does the name exist (as DIRECTORY or FILE) in the file system? More... | |
virtual bool | isDir (const fileName &, const bool followLink=true) const =0 |
Does the name exist as a DIRECTORY in the file system? More... | |
virtual bool | isFile (const fileName &, const bool checkGzip=true, const bool followLink=true) const =0 |
Does the name exist as a FILE in the file system? More... | |
virtual off_t | fileSize (const fileName &, const bool followLink=true) const =0 |
Return size of file. More... | |
virtual time_t | lastModified (const fileName &, const bool followLink=true) const =0 |
Return time of last file modification. More... | |
virtual double | highResLastModified (const fileName &, const bool followLink=true) const =0 |
Return time of last file modification. More... | |
virtual fileNameList | readDir (const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const =0 |
Read a directory and return the entries as a string list. More... | |
virtual bool | cp (const fileName &src, const fileName &dst, const bool followLink=true) const =0 |
Copy, recursively if necessary, the source to the destination. More... | |
virtual bool | ln (const fileName &src, const fileName &dst) const =0 |
Create a softlink. dst should not exist. Returns true if. More... | |
virtual bool | mv (const fileName &src, const fileName &dst, const bool followLink=false) const =0 |
Rename src to dst. More... | |
virtual bool | mvBak (const fileName &, const std::string &ext="bak") const =0 |
Rename to a corresponding backup file. More... | |
virtual bool | rm (const fileName &) const =0 |
Remove a file, returning true if successful otherwise false. More... | |
virtual bool | rmDir (const fileName &dir, const bool silent=false, const bool emptyOnly=false) const =0 |
Remove a directory and its contents. More... | |
virtual bool | broadcastCopy (const label comm, const bool writeOnProc, const fileName &src, const fileName &dst) const |
Read dir/file (recursively if necessary) on master of the communicator, send and write contents to all 'writeOnProc' processors with local file name. More... | |
virtual fileName | objectPath (const IOobject &io, const word &typeName) const |
Generate disk file name for object. Opposite of filePath. More... | |
virtual fileName | filePath (const bool checkGlobal, const IOobject &, const word &typeName, const bool search=true) const =0 |
Search for an object. checkGlobal : also check undecomposed case. More... | |
virtual fileName | dirPath (const bool checkGlobal, const IOobject &io, const bool search=true) const =0 |
Search for a directory. checkGlobal : also check undecomposed. More... | |
virtual fileNameList | readObjects (const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const |
Search directory for objects. Used in IOobjectList. More... | |
virtual bool | readHeader (IOobject &, const fileName &, const word &typeName) const =0 |
Read object header from supplied file. More... | |
virtual autoPtr< ISstream > | readStream (regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const =0 |
Reads header for regIOobject and returns an ISstream. More... | |
virtual bool | read (regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const =0 |
Top-level read. More... | |
virtual bool | writeObject (const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const |
Writes a regIOobject (so header, contents and divider). More... | |
virtual fileName | filePath (const fileName &, const bool checkGzip=true, const bool followLink=true) const |
Search for a file or directory. Use IOobject version in preference. More... | |
virtual autoPtr< ISstream > | NewIFstream (const fileName &) const =0 |
Generate an ISstream that reads a file. More... | |
virtual autoPtr< OSstream > | NewOFstream (const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const =0 |
Generate an OSstream that writes a file. More... | |
virtual autoPtr< OSstream > | NewOFstream (IOstreamOption::atomicType atomic, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const =0 |
Generate an OSstream that writes a file. More... | |
virtual label | addWatch (const fileName &) const |
Add watching of a file. Returns handle. More... | |
virtual bool | removeWatch (const label) const |
Remove watch on a file (using handle) More... | |
virtual label | findWatch (const labelList &watchIndices, const fileName &) const |
Find index (or -1) of file in list of handles. More... | |
virtual void | addWatches (regIOobject &, const fileNameList &) const |
Helper: add watches for list of regIOobjects. More... | |
virtual fileName | getFile (const label) const |
Get name of file being watched (using handle) More... | |
virtual void | updateStates (const bool masterOnly, const bool syncPar) const |
Update state of all files. More... | |
virtual fileMonitor::fileState | getState (const label) const |
Get current state of file (using handle) More... | |
virtual void | setUnmodified (const label) const |
Set current state of file (using handle) to unmodified. More... | |
virtual word | processorsDir (const IOobject &io) const |
Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE) More... | |
virtual word | processorsDir (const fileName &) const |
Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE) More... | |
label | nProcs () const noexcept |
Overall number of processors, from UPstream::nProcs() or detected from directories/results. More... | |
label | nProcs (const label numProcs) noexcept |
Set number of processor directories/results. More... | |
virtual label | nProcs (const fileName &dir, const fileName &local="", const label wantedNProcs=0) const |
Get number of processor directories/results. More... | |
virtual instantList | findTimes (const fileName &, const word &) const |
Get sorted list of times. More... | |
virtual IOobject | findInstance (const IOobject &io, const scalar startValue, const word &stopInstance, const bool constant_fallback=true) const |
Find time instance where IOobject is located. The name of the IOobject can be empty, in which case only the IOobject::local() is checked. Does not search beyond stopInstance (if set) or constant . More... | |
virtual void | setTime (const Time &) const |
Callback for time change. More... | |
virtual void | flush () const |
Forcibly wait until all output done. Flush any cached data. More... | |
virtual void | sync () |
Forcibly parallel sync. More... | |
fileName | processorsCasePath (const IOobject &io, const word &procDir) const |
Generate path (like io.path) from root+casename with any. More... | |
fileName | processorsPath (const IOobject &io, const word &instance, const word &procDir) const |
Generate path (like io.path) with provided instance and any. More... | |
fileName | processorsPath (const fileName &, const word &procDir) const |
Operating on fileName: replace processorXXX with procDir. More... | |
label | setNProcs (label numProcs) |
Same as nProcs. More... | |
Static Public Member Functions | |
static refPtr< fileOperation > | null () |
Reference to a dummy file handler. More... | |
static autoPtr< fileOperation > | New (const word &handlerType, bool verbose=false) |
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty. More... | |
static autoPtr< fileOperation > | New (const word &handlerType, const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots, bool verbose=false) |
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty. More... | |
static autoPtr< fileOperation > | New (const fileOperation &origHandler, const boolUList &useProc, bool verbose=false) |
Replicate the given fileHandler properties with a subset of (global) ranks. More... | |
static autoPtr< fileOperation > | New (const fileOperation &origHandler, const bitSet &useProc, bool verbose=false) |
Replicate the given fileHandler properties with a subset of (global) ranks. More... | |
static autoPtr< fileOperation > | NewUncollated () |
The commonly used uncollatedFileOperation. More... | |
static const fileOperation & | fileHandler () |
Return the current file handler. Will create the default file handler if necessary. More... | |
static refPtr< fileOperation > | fileHandler (std::nullptr_t) |
Delete current file handler. More... | |
static refPtr< fileOperation > | fileHandler (refPtr< fileOperation > &newHandler) |
Replace the current file handler. More... | |
static refPtr< fileOperation > | fileHandler (refPtr< fileOperation > &&newHandler) |
Replace the current file handler. More... | |
static refPtr< fileOperation > | fileHandler (autoPtr< fileOperation > &&newHandler) |
Replace the current file handler. More... | |
static int | cacheLevel () noexcept |
Return cache level. More... | |
static int | cacheLevel (int level) noexcept |
Set cache level (0 = off). More... | |
static int | nProcsFilter () noexcept |
Return collated 'processorsDDD' filtering. More... | |
static int | nProcsFilter (int level) noexcept |
Set collated 'processorsDDD' filtering (0 = off). More... | |
static instantList | sortTimes (const fileNameList &dirEntries, const word &constantName="constant") |
Sort directory entries according to time value,. More... | |
static bool | uniformFile (const fileNameList &names) |
True if the file names are identical. False on an empty list. More... | |
static bool | uniformFile (const label comm, const fileName &name) |
True if the file name is identical on all ranks. More... | |
static label | splitProcessorPath (const fileName &objectPath, fileName &path, fileName &procDir, fileName &local, procRangeType &group, label &nProcs) |
Split objectPath into part before 'processor' and part after. More... | |
static label | detectProcessorPath (const fileName &objPath) |
Detect processor number from '/aa/bb/processorDDD/cc'. More... | |
static labelRange | subRanks (const labelUList &mainIOranks) |
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks. More... | |
static labelList | getGlobalHostIORanks () |
Get list of global IO master ranks based on the hostname. It is assumed that each host range is contiguous. More... | |
static labelList | getGlobalIORanks () |
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master ranks. More... | |
Static Public Attributes | |
static const Enum< pathType > | pathTypeNames_ |
static word | processorsBaseDir = "processors" |
Return the processors directory name (usually "processors") More... | |
static word | defaultFileHandler |
Name of the default fileHandler. More... | |
static refPtr< fileOperation > | fileHandlerPtr_ |
The currently active file handler. Avoid accessing directly. More... | |
Protected Member Functions | |
fileMonitor & | monitor () const |
Get or create fileMonitor singleton. More... | |
refPtr< dirIndexList > | lookupAndCacheProcessorsPath (const fileName &objectPath, const bool syncPar) const |
Lookup name of processorsDDD using cache. More... | |
virtual refPtr< dirIndexList > | lookupProcessorsPath (const fileName &objectPath) const |
Lookup name of processorsDDD using cache. More... | |
bool | exists (IOobject &io) const |
Does IOobject exist? Is either a directory (empty name()) or a file. More... | |
bool | isIOrank (const label proci) const |
Is proci a master rank in the communicator (in parallel) or a master rank in the IO ranks (non-parallel) More... | |
void | printRanks () const |
Helper: output which ranks are IO. More... | |
Static Protected Member Functions | |
static void | mergeTimes (const instantList &extraTimes, const word &constantName, instantList ×) |
Merge two times. More... | |
static bool | isFileOrDir (const bool isFile, const fileName &) |
Helper: check for file (isFile) or directory (!isFile) More... | |
static label | getManagedComm (const label communicator) |
Construction helper: check for locally allocated communicator. More... | |
Protected Attributes | |
label | comm_ |
Communicator to use. More... | |
label | nProcs_ |
Overall number of processors. More... | |
bool | distributed_ |
Distributed roots (parallel run) More... | |
const labelList | ioRanks_ |
The list of IO ranks (global ranks) More... | |
HashTable< dirIndexList > | procsDirs_ |
Detected processors directories. More... | |
std::unique_ptr< fileMonitor > | monitorPtr_ |
File-change monitor for all registered files. More... | |
Static Protected Attributes | |
static int | cacheLevel_ |
Cache level (eg, for caching time directories). Default: 1. More... | |
An encapsulation of filesystem-related operations.
Several of the file handlers can be configured to use specific ranks for IO operations. These can either be defined from the command-line -ioRanks
option, or via the FOAM_ENV
environment variable. In either case, the list of IO ranks shall always include the value 0 (master rank). The ranks may be specified as a plain list, or as an OpenFOAM list. The special value host can be used to specify selection based on hostname.
For example,
FOAM_IORANKS='0 4 8' decomposePar -fileHandler hostCollated FOAM_IORANKS='0,4,8' decomposePar -fileHandler hostCollated FOAM_IORANKS='(0 4 8)' decomposePar -fileHandler hostCollated
will generate
processors12_0-3/ : containing data for processors 0 to 3 processors12_4-7/ : containing data for processors 4 to 7 processors12_8-11/ : containing data for processors 8 to 11
The value host can be used to specify a single IO rank for each host. For example,
decomposePar -fileHandler collated -ioRanks host decomposePar -fileHandler hostCollated
FOAM_ENV
: list of io-ranks as plain space or comma separated list or as an OpenFOAM formatted list. Eg, '(0 4 8)' Definition at line 100 of file fileOperation.H.
Augment fileName with pathType and local offset.
Definition at line 136 of file fileOperation.H.
typedef List<dirIndex> dirIndexList |
Definition at line 137 of file fileOperation.H.
typedef IntRange<int> procRangeType |
For addressing a range of processors, identical to UPstream::rangeType.
Definition at line 143 of file fileOperation.H.
enum pathType : int |
Enumeration for the location of an IOobject.
Definition at line 109 of file fileOperation.H.
|
explicit |
Construct from communicator, optionally with specified io-ranks and/or distributed roots.
Definition at line 774 of file fileOperation.C.
|
explicit |
Construct from communicator with specified io-ranks.
Definition at line 761 of file fileOperation.C.
|
virtualdefault |
Destructor.
|
protected |
Get or create fileMonitor singleton.
Definition at line 313 of file fileOperation.C.
References IOobject::fileModificationChecking, IOobject::inotify, and IOobject::inotifyMaster.
|
staticprotected |
Merge two times.
Definition at line 331 of file fileOperation.C.
References UList< T >::end(), forAll, Foam::less(), Foam::name(), List< T >::setSize(), UList< T >::size(), Foam::sort(), and List< T >::transfer().
|
staticprotected |
Helper: check for file (isFile) or directory (!isFile)
Definition at line 404 of file fileOperation.C.
References f(), Foam::isDir(), and Foam::isFile().
|
protected |
Lookup name of processorsDDD using cache.
Definition at line 412 of file fileOperation.C.
References DynamicList< T, SizeMin >::append(), Pstream::broadcast(), Foam::ensightOutput::debug, DebugInfo, UList< T >::empty(), Foam::endl(), IOobject::fileModificationChecking, Tuple2< T1, T2 >::first(), Foam::flatOutput(), Foam::constant::atomic::group, IOobject::inotifyMaster, local, UPstream::master(), Foam::max(), Foam::name(), refPtr< T >::New(), fileOperation::nProcs(), UPstream::nProcs(), UPstream::parRun(), path(), Foam::Pout, Foam::readDir(), Foam::reduce(), rp(), Tuple2< T1, T2 >::second(), UList< T >::size(), IOobject::timeStampMaster, and UPstream::worldComm.
|
protectedvirtual |
Lookup name of processorsDDD using cache.
Reimplemented in uncollatedFileOperation.
Definition at line 703 of file fileOperation.C.
|
protected |
Does IOobject exist? Is either a directory (empty name()) or a file.
Definition at line 709 of file fileOperation.C.
References io(), Foam::isDir(), Foam::isFile(), IOobject::name(), word::null, IOobject::objectPath(), and IOobject::typeHeaderOk().
|
protected |
Is proci a master rank in the communicator (in parallel) or a master rank in the IO ranks (non-parallel)
Definition at line 237 of file fileOperationRanks.C.
References UPstream::master(), and UPstream::parRun().
|
protected |
Helper: output which ranks are IO.
Definition at line 250 of file fileOperationRanks.C.
References DetailInfo, stdFoam::end(), forAll, Pstream::gatherList(), Foam::constant::atomic::group, Foam::hostName(), UPstream::master(), UPstream::msgType(), UPstream::myProcNo(), Foam::nl, UPstream::nProcs(), DynamicList< T, SizeMin >::push_back(), DynamicList< T, SizeMin >::reserve(), UList< T >::size(), and UPstream::worldComm.
|
inlinestaticprotected |
Construction helper: check for locally allocated communicator.
Definition at line 281 of file fileOperation.H.
References UPstream::commGlobal(), UPstream::commSelf(), and UPstream::commWorld().
TypeName | ( | "fileOperation" | ) |
Runtime type information.
|
static |
Reference to a dummy file handler.
Definition at line 34 of file fileOperationNew.C.
declareRunTimeSelectionTable | ( | autoPtr | , |
fileOperation | , | ||
word | , | ||
(bool verbose) | , | ||
(verbose) | |||
) |
declareRunTimeSelectionTable | ( | autoPtr | , |
fileOperation | , | ||
comm | , | ||
(const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots, bool verbose) | , | ||
(commAndIORanks, distributedRoots, verbose) | |||
) |
|
static |
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
Definition at line 145 of file fileOperationNew.C.
References Foam::abort(), DebugInFunction, fileOperation::defaultFileHandler, Foam::endl(), Foam::FatalError, FatalErrorInFunction, FatalErrorInLookup, and Foam::nl.
Referenced by fileOperation::fileHandler(), fileOperation::New(), argList::parse(), and Time::readDict().
|
static |
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
Definition at line 184 of file fileOperationNew.C.
References Foam::abort(), DebugInFunction, fileOperation::defaultFileHandler, Foam::endl(), Foam::FatalError, FatalErrorInFunction, FatalErrorInLookup, fileOperation::New(), and Foam::nl.
|
static |
Replicate the given fileHandler properties with a subset of (global) ranks.
Always includes rank 0 and constrained by the global numProcs Returns nullptr if myProcNo is not involved.
origHandler | The original file handler |
useProc | The selected sub-ranks (in comm-world) |
Definition at line 399 of file fileOperationNew.C.
References Foam::getSelectedProcs().
|
static |
Replicate the given fileHandler properties with a subset of (global) ranks.
Always includes rank 0 and constrained by the global numProcs Returns nullptr if myProcNo is not involved.
origHandler | The original file handler |
useProc | The selected sub-ranks (in comm-world). Monotonic order! |
Definition at line 413 of file fileOperationNew.C.
References Foam::getSelectedProcs().
|
static |
The commonly used uncollatedFileOperation.
Definition at line 132 of file fileOperationNew.C.
Referenced by faMeshReconstructor::writeMesh().
|
static |
Return the current file handler. Will create the default file handler if necessary.
Definition at line 46 of file fileOperationNew.C.
References fileOperation::fileHandlerPtr_, Foam::getEnv(), and fileOperation::New().
Referenced by fileOperation::fileHandler(), Foam::fileHandler(), argList::parse(), Time::readDict(), faMeshReconstructor::writeMesh(), and argList::~argList().
|
static |
Delete current file handler.
Definition at line 65 of file fileOperationNew.C.
|
static |
Replace the current file handler.
The following are considered no-ops:
nullptr
(std::nullptr_t) for thatDefinition at line 72 of file fileOperationNew.C.
References fileOperation::fileHandlerPtr_, refPtr< T >::get(), and refPtr< T >::swap().
|
static |
Replace the current file handler.
The following are considered no-ops:
nullptr
(std::nullptr_t) for thatDefinition at line 126 of file fileOperationNew.C.
References fileOperation::fileHandler().
|
static |
Replace the current file handler.
The following are considered no-ops:
nullptr
(std::nullptr_t) for thatDefinition at line 105 of file fileOperationNew.C.
References fileOperation::fileHandlerPtr_, refPtr< T >::reset(), and refPtr< T >::swap().
|
inlinestaticnoexcept |
Return cache level.
Definition at line 536 of file fileOperation.H.
References fileOperation::cacheLevel_.
Referenced by masterUncollatedFileOperation::addWatches(), masterUncollatedFileOperation::dirPath(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), masterUncollatedFileOperation::findTimes(), argList::parse(), masterUncollatedFileOperation::read(), Foam::readLagrangian(), masterUncollatedFileOperation::readObjects(), and Foam::reconstructLagrangian().
|
inlinestaticnoexcept |
Set cache level (0 = off).
Definition at line 544 of file fileOperation.H.
References fileOperation::cacheLevel_.
|
inlinestaticnoexcept |
Return collated 'processorsDDD' filtering.
Definition at line 554 of file fileOperation.H.
Referenced by argList::parse().
|
inlinestaticnoexcept |
Set collated 'processorsDDD' filtering (0 = off).
Definition at line 564 of file fileOperation.H.
|
static |
Sort directory entries according to time value,.
with "constant" appearing first (if it exists)
Definition at line 217 of file fileOperation.C.
References Foam::less(), UList< T >::size(), and Foam::sort().
|
static |
True if the file names are identical. False on an empty list.
Definition at line 275 of file fileOperation.C.
References UList< T >::empty(), Foam::PtrListOps::names(), and UList< T >::size().
Referenced by masterUncollatedFileOperation::NewIFstream(), masterUncollatedFileOperation::readHeader(), and masterUncollatedFileOperation::readStream().
|
static |
True if the file name is identical on all ranks.
Definition at line 296 of file fileOperation.C.
References Pstream::broadcast(), Foam::name(), UPstream::parRun(), and Foam::returnReduceAnd().
|
inlinenoexcept |
Communicator to use.
Definition at line 600 of file fileOperation.H.
References fileOperation::comm_.
|
inlinenoexcept |
Set communicator to use [mutable]. Negative values are a no-op.
Definition at line 610 of file fileOperation.H.
References fileOperation::comm_.
|
inlinenoexcept |
Distributed roots (parallel run)
Definition at line 620 of file fileOperation.H.
References fileOperation::distributed_.
|
inlinenoexcept |
Set distributed roots on/off [mutable].
Definition at line 630 of file fileOperation.H.
References fileOperation::distributed_.
|
inlinenoexcept |
The list of IO ranks (global ranks)
Primarily for additional bookkeeping in non-parallel
Definition at line 642 of file fileOperation.H.
References fileOperation::ioRanks_.
|
inlinenoexcept |
Return info proxy, used to print information to a stream.
Definition at line 648 of file fileOperation.H.
|
inlinevirtual |
True if the fileOperation can be considered valid. At the moment, primarily used to detect the dummy fileOperation.
Reimplemented in dummyFileOperation.
Definition at line 657 of file fileOperation.H.
|
pure virtual |
Transfer ownership of communicator to this fileOperation. Use with caution.
Implemented in masterUncollatedFileOperation, collatedFileOperation, hostCollatedFileOperation, uncollatedFileOperation, hostUncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Make directory.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Set the file mode.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Return the file mode.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Return the file type: DIRECTORY, FILE or SYMLINK.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Does the name exist (as DIRECTORY or FILE) in the file system?
Optionally enable/disable check for gzip file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Does the name exist as a DIRECTORY in the file system?
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Does the name exist as a FILE in the file system?
Optionally enable/disable check for gzip file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Return size of file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Return time of last file modification.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Return time of last file modification.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Read a directory and return the entries as a string list.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Copy, recursively if necessary, the source to the destination.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
Create a softlink. dst should not exist. Returns true if.
successful.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Rename src to dst.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Rename to a corresponding backup file.
If the backup file already exists, attempt with "01" .. "99" suffix
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Remove a file, returning true if successful otherwise false.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Remove a directory and its contents.
dir | the directory to remove |
silent | do not report missing directory |
emptyOnly | only remove empty directories (recursive) |
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
virtual |
Read dir/file (recursively if necessary) on master of the communicator, send and write contents to all 'writeOnProc' processors with local file name.
comm | the communicator for broadcasting |
writeOnProc | write on the processor |
src | the source file/directory |
dst | the target file/directory. If empty, treat as being identical to the src. |
Definition at line 354 of file fileOperationBroadcast.C.
References Foam::broadcastFile_recursive().
|
virtual |
Generate disk file name for object. Opposite of filePath.
Optional wanted typeName.
Reimplemented in collatedFileOperation.
Definition at line 790 of file fileOperation.C.
References io(), and IOobject::objectPath().
|
pure virtual |
Search for an object. checkGlobal : also check undecomposed case.
Optional wanted typeName.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Search for a directory. checkGlobal : also check undecomposed.
case
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
virtual |
Search directory for objects. Used in IOobjectList.
Reimplemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
Definition at line 1249 of file fileOperation.C.
References objectRegistry::dbDir(), Foam::ensightOutput::debug, Foam::endl(), Foam::isDir(), local, IOobject::objectPath(), objectRegistry::parent(), path(), IOobject::path(), Foam::Pout, and Foam::readDir().
Referenced by uncollatedFileOperation::readObjects(), and masterUncollatedFileOperation::readObjects().
|
pure virtual |
Read object header from supplied file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Reads header for regIOobject and returns an ISstream.
to read the contents.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Top-level read.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
virtual |
Writes a regIOobject (so header, contents and divider).
Returns success state. Default action is to write to the objectPath using writeData. If !writeOnProc the file does not need to be written (this is used e.g. to suppress empty local lagrangian data)
Reimplemented in masterUncollatedFileOperation, and collatedFileOperation.
Definition at line 800 of file fileOperation.C.
References IOstream::good(), io(), Foam::mkDir(), IOobject::objectPath(), os(), IOobject::writeEndDivider(), and IOobject::writeHeader().
|
virtual |
Search for a file or directory. Use IOobject version in preference.
Definition at line 845 of file fileOperation.C.
References Foam::ensightOutput::debug, Foam::endl(), Foam::exists(), Foam::constant::atomic::group, local, path(), Foam::Pout, and WarningInFunction.
Generate an ISstream that reads a file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Generate an OSstream that writes a file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
pure virtual |
Generate an OSstream that writes a file.
Implemented in masterUncollatedFileOperation, uncollatedFileOperation, and dummyFileOperation.
|
virtual |
Add watching of a file. Returns handle.
Reimplemented in masterUncollatedFileOperation.
Definition at line 921 of file fileOperation.C.
|
virtual |
Remove watch on a file (using handle)
Reimplemented in masterUncollatedFileOperation.
Definition at line 927 of file fileOperation.C.
Find index (or -1) of file in list of handles.
Reimplemented in masterUncollatedFileOperation.
Definition at line 934 of file fileOperation.C.
References forAll.
|
virtual |
Helper: add watches for list of regIOobjects.
Reimplemented in masterUncollatedFileOperation.
Definition at line 951 of file fileOperation.C.
References DynamicList< T, SizeMin >::append(), HashTable< T, Key, Hash >::erase(), f(), and regIOobject::watchIndices().
|
virtual |
Get name of file being watched (using handle)
Reimplemented in masterUncollatedFileOperation.
Definition at line 987 of file fileOperation.C.
|
virtual |
Update state of all files.
Reimplemented in masterUncollatedFileOperation.
Definition at line 994 of file fileOperation.C.
References UPstream::parRun().
|
virtual |
Get current state of file (using handle)
Reimplemented in masterUncollatedFileOperation.
Definition at line 1004 of file fileOperation.C.
|
virtual |
Set current state of file (using handle) to unmodified.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1012 of file fileOperation.C.
Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE)
Reimplemented in collatedFileOperation.
Definition at line 1042 of file fileOperation.H.
References fileOperation::processorsBaseDir.
Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE)
Reimplemented in collatedFileOperation.
Definition at line 1051 of file fileOperation.H.
References fileOperation::processorsBaseDir.
|
inlinenoexcept |
Overall number of processors, from UPstream::nProcs() or detected from directories/results.
Definition at line 1060 of file fileOperation.H.
References fileOperation::nProcs_.
Referenced by masterUncollatedFileOperation::addWatches(), masterUncollatedFileOperation::dirPath(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), masterUncollatedFileOperation::findTimes(), fileOperation::lookupAndCacheProcessorsPath(), masterUncollatedFileOperation::read(), masterUncollatedFileOperation::readObjects(), and fileOperation::setNProcs().
|
inlinenoexcept |
Set number of processor directories/results.
Used to cache format of e.g. processorsDDD. Returns old number of processors. Only used in decomposePar
Definition at line 1069 of file fileOperation.H.
References fileOperation::nProcs_.
|
virtual |
Get number of processor directories/results.
Used for e.g. reconstructPar, argList checking
if wanted is 2 then processor0,1 is enough if wanted is not set then return highest valid range
(processors10 in above case) if wanted cannot be matched (e.g. 37) return 0
wantedNProcs | >0 if we know in advance what we're looking for |
Definition at line 1300 of file fileOperation.C.
References Pstream::broadcast(), Foam::endl(), bitSet::find_first_not(), Foam::constant::atomic::group, Foam::isDir(), UPstream::master(), Foam::max(), Foam::nl, Foam::readDir(), PackedList< Width >::resize(), rp(), bitSet::set(), and WarningInFunction.
|
virtual |
Get sorted list of times.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1019 of file fileOperation.C.
References Foam::ensightOutput::debug, fileName::DIRECTORY, Foam::endl(), Foam::flatOutput(), Foam::Pout, and Foam::readDir().
Referenced by masterUncollatedFileOperation::findTimes(), and masterUncollatedFileOperation::readObjects().
|
virtual |
Find time instance where IOobject is located. The name of the IOobject can be empty, in which case only the IOobject::local() is checked. Does not search beyond stopInstance
(if set) or constant
.
If the instance cannot be found:
stopInstance
(if set and reached)constant
if constant_fallback is true.stopInstance | The search stop instance |
constant_fallback | Return "constant" instead of "" if the search failed |
Reimplemented in masterUncollatedFileOperation.
Definition at line 1073 of file fileOperation.C.
References TimePaths::constant(), DebugInFunction, UList< T >::empty(), Foam::endl(), Foam::exists(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, IOobject::instance(), io(), IOobjectOption::isReadRequired(), IOobject::local(), IOobject::name(), UList< T >::size(), IOobject::time(), and TimePaths::times().
|
inlinevirtual |
Callback for time change.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1120 of file fileOperation.H.
Referenced by masterUncollatedFileOperation::setTime().
|
virtual |
Forcibly wait until all output done. Flush any cached data.
Reimplemented in masterUncollatedFileOperation, and collatedFileOperation.
Definition at line 1394 of file fileOperation.C.
References Foam::ensightOutput::debug, Foam::endl(), and Foam::Pout.
Referenced by masterUncollatedFileOperation::flush().
|
virtual |
Forcibly parallel sync.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1405 of file fileOperation.C.
References Pstream::broadcasts(), Foam::ensightOutput::debug, Foam::endl(), Foam::Pout, and UPstream::worldComm.
Referenced by masterUncollatedFileOperation::sync().
Foam::fileName processorsCasePath | ( | const IOobject & | io, |
const word & | procDir | ||
) | const |
Generate path (like io.path) from root+casename with any.
'processorXXX' replaced by procDir (usually 'processsors')
Definition at line 1423 of file fileOperation.C.
References IOobject::globalCaseName(), io(), and IOobject::rootPath().
Foam::fileName processorsPath | ( | const IOobject & | io, |
const word & | instance, | ||
const word & | procDir | ||
) | const |
Generate path (like io.path) with provided instance and any.
'processorXXX' replaced by procDir (usually 'processsors')
Definition at line 1433 of file fileOperation.C.
References IOobject::db(), objectRegistry::dbDir(), io(), and IOobject::local().
Foam::fileName processorsPath | ( | const fileName & | dir, |
const word & | procDir | ||
) | const |
Operating on fileName: replace processorXXX with procDir.
Definition at line 1448 of file fileOperation.C.
References Foam::endl(), fileName::name(), fileName::path(), and WarningInFunction.
|
static |
Split objectPath into part before 'processor' and part after.
Returns -1 or processor number and optionally number of processors. Use with care.
Definition at line 1474 of file fileOperation.C.
References Foam::constant::atomic::group, string::length(), local, path(), Foam::pos(), and Foam::read().
|
static |
Detect processor number from '/aa/bb/processorDDD/cc'.
Definition at line 1634 of file fileOperation.C.
References Foam::constant::atomic::group, local, and path().
|
static |
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
Definition at line 66 of file fileOperationRanks.C.
References UList< T >::empty(), forAllReverse, UPstream::myProcNo(), UPstream::nProcs(), UList< T >::size(), and UPstream::worldComm.
Referenced by Foam::getCommPattern().
|
static |
Get list of global IO master ranks based on the hostname. It is assumed that each host range is contiguous.
Definition at line 100 of file fileOperationRanks.C.
References Pstream::broadcast(), SHA1Digest::cdata_bytes(), UList< T >::data_bytes(), Foam::hostName(), UPstream::master(), SHA1Digest::max_size(), UPstream::mpiGather(), UPstream::nProcs(), DynamicList< T, SizeMin >::push_back(), DynamicList< T, SizeMin >::reserve(), List< T >::resize(), UList< T >::size(), and UPstream::worldComm.
Referenced by Foam::getCommPattern(), and fileOperation::getGlobalIORanks().
|
static |
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master ranks.
Definition at line 154 of file fileOperationRanks.C.
References UList< T >::begin(), string::contains(), UList< T >::contains(), UList< T >::empty(), UList< T >::end(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), UList< T >::front(), Foam::getEnv(), fileOperation::getGlobalHostIORanks(), Foam::nl, UList< T >::size(), UList< T >::slice(), and Foam::sort().
Referenced by Foam::getCommPattern().
|
inline |
Same as nProcs.
Definition at line 1213 of file fileOperation.H.
References fileOperation::nProcs().
|
static |
Definition at line 131 of file fileOperation.H.
Referenced by masterUncollatedFileOperation::dirPath(), and masterUncollatedFileOperation::filePath().
|
staticprotected |
Cache level (eg, for caching time directories). Default: 1.
Caching (e.g. of time directories) - enabled by default.
Definition at line 173 of file fileOperation.H.
Referenced by fileOperation::cacheLevel().
|
mutableprotected |
Communicator to use.
Definition at line 181 of file fileOperation.H.
Referenced by fileOperation::comm().
|
protected |
Overall number of processors.
Used to synthesise processor directory naming:
Definition at line 190 of file fileOperation.H.
Referenced by fileOperation::nProcs().
|
mutableprotected |
Distributed roots (parallel run)
Definition at line 195 of file fileOperation.H.
Referenced by fileOperation::distributed().
|
protected |
The list of IO ranks (global ranks)
Primarily for additional bookkeeping in non-parallel
Definition at line 202 of file fileOperation.H.
Referenced by fileOperation::ioRanks().
|
mutableprotected |
Detected processors directories.
Definition at line 207 of file fileOperation.H.
|
mutableprotected |
File-change monitor for all registered files.
Definition at line 212 of file fileOperation.H.
|
static |
Return the processors directory name (usually "processors")
Definition at line 320 of file fileOperation.H.
Referenced by fileOperation::processorsDir().
|
static |
Name of the default fileHandler.
Definition at line 325 of file fileOperation.H.
Referenced by argList::argList(), fileOperation::New(), and argList::parse().
|
static |
The currently active file handler. Avoid accessing directly.
Definition at line 339 of file fileOperation.H.
Referenced by fileOperation::fileHandler(), and argList::parse().