Go to the documentation of this file.
48 namespace fileOperations
54 masterUncollatedFileOperation,
64 "maxMasterFileBufferSize",
73 masterUncollatedFileOperationInitialise,
88 labelList mainRanks(fileOperation::ioRanks());
90 if (mainRanks.empty())
98 if (!mainRanks.found(0))
101 <<
"Rank 0 (master) should be in the IO ranks. Currently "
107 const bitSet isIOrank(
n, mainRanks);
109 for (label proci = Pstream::myProcNo(); proci >= 0; --proci)
117 label rank = proci+1;
118 rank <
n && !isIOrank[rank];
147 if (t.
equal(timeDirs[i].value()))
149 return timeDirs[i].name();
160 const bool checkGlobal,
166 word& newInstancePath
169 procsDir = word::null;
170 newInstancePath = word::null;
176 if (isFileOrDir(
isFile, objPath))
178 searchType = fileOperation::ABSOLUTE;
183 searchType = fileOperation::NOTFOUND;
184 return fileName::null;
192 if (isFileOrDir(
isFile, writePath))
194 searchType = fileOperation::WRITEOBJECT;
203 for (
const dirIndex& dirIdx : pDirs())
205 const fileName& pDir = dirIdx.first();
207 processorsPath(io, io.
instance(), pDir)
209 if (objPath != writePath && isFileOrDir(
isFile, objPath))
211 searchType = dirIdx.second().first();
223 localPath != writePath
224 && isFileOrDir(
isFile, localPath)
227 searchType = fileOperation::OBJECT;
249 if (isFileOrDir(
isFile, parentPath))
251 searchType = fileOperation::PARENTOBJECT;
258 const auto pathFnd = times_.cfind(io.
time().
path());
260 if (
search && pathFnd.found())
262 newInstancePath = findInstancePath
268 if (newInstancePath.size() && newInstancePath != io.
instance())
276 for (
const dirIndex& dirIdx : pDirs())
278 const fileName& pDir = dirIdx.first();
282 processorsPath(io, newInstancePath, pDir)
285 if (isFileOrDir(
isFile, fName))
287 switch (dirIdx.second().first())
289 case fileOperation::PROCUNCOLLATED:
292 fileOperation::PROCUNCOLLATEDINSTANCE;
295 case fileOperation::PROCBASEOBJECT:
297 searchType = fileOperation::PROCBASEINSTANCE;
300 case fileOperation::PROCOBJECT:
302 searchType = fileOperation::PROCINSTANCE;
320 if (isFileOrDir(
isFile, fName))
322 searchType = fileOperation::FINDINSTANCE;
328 searchType = fileOperation::NOTFOUND;
329 return fileName::null;
340 const word& instancePath
347 case fileOperation::ABSOLUTE:
353 case fileOperation::OBJECT:
359 case fileOperation::WRITEOBJECT:
365 case fileOperation::PROCUNCOLLATED:
370 "processor" +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
387 case fileOperation::PROCBASEOBJECT:
391 processorsPath(io, io.
instance(), procDir)
396 case fileOperation::PROCOBJECT:
400 processorsPath(io, io.
instance(), processorsDir(io))
405 case fileOperation::PARENTOBJECT:
413 case fileOperation::FINDINSTANCE:
421 case fileOperation::PROCUNCOLLATEDINSTANCE:
427 +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
444 case fileOperation::PROCBASEINSTANCE:
448 processorsPath(io, instancePath, procDir)
453 case fileOperation::PROCINSTANCE:
457 processorsPath(io, instancePath, processorsDir(io))
462 case fileOperation::NOTFOUND:
464 return fileName::null;
471 return fileName::null;
482 const fileName& object0 = filePaths[0];
484 for (label i = 1; i < filePaths.size(); i++)
486 if (filePaths[i] != object0)
502 IFstream ifs(filePath, IOstreamOption::BINARY);
507 <<
"Cannot open file " << filePath
513 Pout<<
"masterUncollatedFileOperation::readAndSend :"
518 if (ifs.
compression() == IOstreamOption::COMPRESSED)
524 const std::string buf
526 std::istreambuf_iterator<char>(ifs.
stdStream()),
527 std::istreambuf_iterator<char>()
530 for (
const label proci : procs)
533 os.write(buf.data(), buf.length());
538 Pout<<
"masterUncollatedFileOperation::readStream :"
539 <<
" From " << filePath <<
" sent " << buf.size()
551 for (
const label proci : procs)
559 Pout<<
"masterUncollatedFileOperation::readStream :"
560 <<
" From " << filePath <<
" sent " << buf.size()
583 Pstream::commsTypes::nonBlocking,
588 if (Pstream::master(comm))
594 if (filePaths[0].empty())
602 for (
const int proci : Pstream::allProcs(comm))
604 if (procValid[proci])
614 Pout<<
"masterUncollatedFileOperation::readStream :"
615 <<
" For uniform file " << filePaths[0]
616 <<
" sending to " << validProcs
617 <<
" in comm:" << comm <<
endl;
619 readAndSend(filePaths[0], validProcs, pBufs);
626 if (filePaths[0].empty())
640 <<
"problem while reading header for object "
646 for (
const int proci : Pstream::subProcs(comm))
650 Pout<<
"masterUncollatedFileOperation::readStream :"
651 <<
" For processor " << proci
652 <<
" opening " << filePaths[proci] <<
endl;
655 const fileName& fPath = filePaths[proci];
657 if (procValid[proci] && !fPath.empty())
674 if (procValid[Pstream::myProcNo(comm)])
680 UIPstream is(Pstream::masterNo(), pBufs);
682 List<char> buf(recvSizes[Pstream::masterNo()]);
683 if (recvSizes[Pstream::masterNo()] > 0)
685 is.
read(buf.data(), recvSizes[Pstream::masterNo()]);
690 Pout<<
"masterUncollatedFileOperation::readStream :"
691 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
701 isPtr->name() = filePaths[Pstream::myProcNo(comm)];
706 <<
"problem while reading header for object "
730 UPstream::allocateCommunicator
733 subRanks(Pstream::nProcs())
743 <<
"I/O : " << typeName
744 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
748 if (IOobject::fileModificationChecking == IOobject::timeStampMaster)
753 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
755 IOobject::fileModificationChecking = IOobject::timeStamp;
757 else if (IOobject::fileModificationChecking == IOobject::inotifyMaster)
762 <<
"Resetting fileModificationChecking to inotify"
765 IOobject::fileModificationChecking = IOobject::inotify;
785 <<
"I/O : " << typeName
786 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
790 if (IOobject::fileModificationChecking == IOobject::timeStampMaster)
795 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
797 IOobject::fileModificationChecking = IOobject::timeStamp;
799 else if (IOobject::fileModificationChecking == IOobject::inotifyMaster)
804 <<
"Resetting fileModificationChecking to inotify"
807 IOobject::fileModificationChecking = IOobject::inotify;
832 return masterOp<mode_t, mkDirOp>
848 return masterOp<mode_t, chModOp>
861 const bool followLink
864 return masterOp<mode_t, modeOp>
877 const bool followLink
882 masterOp<label, typeOp>
896 const bool checkGzip,
897 const bool followLink
900 return masterOp<bool, existsOp>
913 const bool followLink
916 return masterOp<bool, isDirOp>
929 const bool checkGzip,
930 const bool followLink
933 return masterOp<bool, isFileOp>
946 const bool followLink
949 return masterOp<off_t, fileSizeOp>
962 const bool followLink
965 return masterOp<time_t, lastModifiedOp>
978 const bool followLink
981 return masterOp<double, lastModifiedHROp>
994 const std::string& ext
997 return masterOp<bool, mvBakOp>
1012 return masterOp<bool, rmOp>
1028 return masterOp<bool, rmDirOp>
1042 const bool filtergz,
1043 const bool followLink
1046 return masterOp<fileNameList, readDirOp>
1060 const bool followLink
1063 return masterOp<bool, cpOp>
1080 return masterOp<bool, lnOp>
1095 const bool followLink
1098 return masterOp<bool, mvOp>
1111 const bool checkGlobal,
1113 const word& typeName,
1119 Pout<<
"masterUncollatedFileOperation::filePath :"
1121 <<
" checkGlobal:" << checkGlobal <<
endl;
1137 word newInstancePath;
1161 Pout<<
"masterUncollatedFileOperation::filePath :"
1162 <<
" master objPath:" << objPath
1164 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1174 label masterType(searchType);
1186 || io.
local() ==
"uniform"
1219 objPath = localObjectPath
1235 objPath = masterOp<fileName, fileOrNullOp>
1249 Pout<<
"masterUncollatedFileOperation::filePath :"
1250 <<
" Returning from file searching:" <<
endl
1252 <<
" filePath :" << objPath <<
endl <<
endl;
1260 const bool checkGlobal,
1267 Pout<<
"masterUncollatedFileOperation::dirPath :"
1269 <<
" checkGlobal:" << checkGlobal <<
endl;
1281 word newInstancePath;
1287 objPath = filePathInfo
1302 label masterType(searchType);
1314 || io.
local() ==
"uniform"
1347 objPath = localObjectPath
1363 objPath = masterOp<fileName, fileOrNullOp>
1377 Pout<<
"masterUncollatedFileOperation::dirPath :"
1378 <<
" Returning from file searching:" <<
endl
1380 <<
" filePath :" << objPath <<
endl <<
endl;
1401 if (isFileOrDir(
isFile, writePath))
1409 for (
const dirIndex& dirIdx : pDirs)
1411 const fileName& pDir = dirIdx.first();
1413 processorsPath(io, io.
instance(), pDir)
1415 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1425 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1438 const scalar startValue,
1439 const word& stopInstance
1444 Pout<<
"masterUncollatedFileOperation::findInstance :"
1445 <<
" Starting searching for name:" << startIO.
name()
1446 <<
" local:" << startIO.
local()
1447 <<
" from instance:" << startIO.
instance()
1481 if (!foundInstance.empty())
1486 Pout<<
"masterUncollatedFileOperation::findInstance :"
1487 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1488 <<
" found starting instance:" << io.
instance() <<
endl;
1505 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
1507 if (ts[instanceI].value() <= startValue)
1514 for (; instanceI >= 0; --instanceI)
1523 io.
instance() = ts[instanceI].name();
1529 Pout<<
"masterUncollatedFileOperation::findInstance :"
1530 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1538 if (ts[instanceI].
name() == stopInstance)
1546 if (io.
name().empty())
1549 <<
"Cannot find directory "
1551 <<
" down to " << stopInstance
1557 <<
"Cannot find file \"" << io.
name()
1558 <<
"\" in directory " << io.
local()
1560 <<
" down to " << stopInstance
1567 Pout<<
"masterUncollatedFileOperation::findInstance :"
1568 <<
" name:" << io.
name() <<
" local:" << io.
local()
1576 if (foundInstance.empty())
1583 if (!ts.size() || ts[0].name() != time.
constant())
1594 Pout<<
"masterUncollatedFileOperation::findInstance :"
1595 <<
" name:" << io.
name()
1596 <<
" local:" << io.
local()
1604 if (foundInstance.empty())
1613 <<
"Cannot find file \"" << io.
name() <<
"\" in directory "
1631 Pout<<
"masterUncollatedFileOperation::findInstance :"
1632 <<
" name:" << io.
name() <<
" local:" << io.
local()
1650 Pout<<
"masterUncollatedFileOperation::readObjects :"
1652 <<
" local:" << local <<
" instance:" << instance <<
endl;
1676 if (newInstance.empty())
1695 if (t.
equal(timeDirs[i].value()))
1717 Pout<<
"masterUncollatedFileOperation::readObjects :"
1718 <<
" newInstance:" << newInstance
1719 <<
" objectNames:" << objectNames <<
endl;
1730 const word& typeName
1737 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl
1739 <<
" filePath :" << fName <<
endl;
1746 bool uniform = uniformFile(filePaths);
1790 if (!filePaths[proci].empty())
1792 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1794 result[proci] = result[proci-1];
1795 headerClassName[proci] = headerClassName[proci-1];
1796 note[proci] = note[proci-1];
1807 note[proci] = io.
note();
1825 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1837 const word& typeName,
1843 Pout<<
"masterUncollatedFileOperation::readStream :"
1844 <<
" object : " << io.
name()
1845 <<
" global : " << io.
global()
1846 <<
" fName : " << fName <<
" valid:" << valid <<
endl;
1851 bool isCollated =
false;
1881 Pout<<
"masterUncollatedFileOperation::readStream :"
1882 <<
" For object : " << io.
name()
1883 <<
" doing straight IFstream input from "
1905 Pout<<
"masterUncollatedFileOperation::readStream :"
1906 <<
" For object : " << io.
name()
1907 <<
" starting collating input from " << fName <<
endl;
1918 splitProcessorPath(fName,
path, procDir, local,
group, nProcs);
1925 label proci = detectProcessorPath(io.
objectPath());
1930 <<
"Could not detect processor number"
1938 proci = proci -
group.start();
1943 Pout<<
"masterUncollatedFileOperation::readStream :"
1944 <<
" For object : " << io.
name()
1945 <<
" starting input from block " << proci
1946 <<
" of " << isPtr->name() <<
endl;
1955 bool bigSize = sz > off_t(maxMasterFileBufferSize);
1960 label readComm = -1;
2003 Pout<<
"masterUncollatedFileOperation::readStream :"
2004 <<
" For object : " << io.
name()
2005 <<
" starting separated input from " << fName <<
endl;
2032 const bool uniform = uniformFile(filePaths);
2034 return read(io, comm_,
uniform, filePaths, procValid);
2043 const bool masterOnly,
2045 const word& typeName
2054 Pout<<
"masterUncollatedFileOperation::read :"
2055 <<
" Reading global object " << io.
name() <<
endl;
2064 ok = io.
readData(io.readStream(typeName));
2095 if (myComm.
above() != -1)
2115 myComm.
below()[belowI],
2129 Pout<<
"masterUncollatedFileOperation::read :"
2130 <<
" Reading local object " << io.
name() <<
endl;
2133 ok = io.
readData(io.readStream(typeName));
2152 Pout<<
"masterUncollatedFileOperation::writeObject :"
2153 <<
" io:" << pathName <<
" valid:" << valid <<
endl;
2186 const word& constantName
2189 const auto iter = times_.cfind(directory);
2194 Pout<<
"masterUncollatedFileOperation::findTimes :"
2195 <<
" Found " << iter()->size() <<
" cached times" <<
endl;
2218 times_.set(directory, tPtr);
2222 Pout<<
"masterUncollatedFileOperation::findTimes :"
2223 <<
" Caching times:" << *tPtr <<
nl
2224 <<
" for directory:" << directory <<
endl;
2253 const label skipConst =
2255 (!times.empty() && times[0].name() == tm.
constant())
2272 Pout<<
"masterUncollatedFileOperation::setTime :"
2273 <<
" Caching time " << tm.
timeName()
2274 <<
" for case:" << tm.
path() <<
endl;
2280 times, times.size()-skipConst, skipConst
2316 const bool uniform = uniformFile(filePaths);
2322 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2323 <<
" Opening global file " << filePath <<
endl;
2360 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2361 <<
" Reading " << filePath
2368 is.
read(buf.data(), buf.size());
2372 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2373 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2383 isPtr->name() = filePath;
2432 watchFd = monitor().addWatch(fName);
2441 const label watchIndex
2447 ok = monitor().removeWatch(watchIndex);
2466 if (monitor().getFile(watchIndices[i]) == fName)
2491 const label index = findWatch(watchIndices,
f);
2495 newWatchIndices.
append(addWatch(
f));
2500 newWatchIndices.
append(watchIndices[index]);
2501 removedWatches.erase(index);
2506 for (
const label index : removedWatches)
2508 removeWatch(watchIndices[index]);
2517 const label watchIndex
2523 fName = monitor().getFile(watchIndex);
2532 const bool masterOnly,
2538 monitor().updateStates(
true,
false);
2552 state = monitor().getState(watchFd);
2566 monitor().setUnmodified(watchFd);
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
int debug
Static debugging option.
List< label > labelList
A List of labels.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or LINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
static const List< commsStruct > & linearCommunication(const label communicator=worldComm)
Communication schedule for linear all-to-master (proc 0)
const fileName & globalCaseName() const
Return global case name.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual void setTime(const Time &) const
Callback for time change.
static void readAndSend(const fileName &filePath, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
A class for handling words, derived from Foam::string.
An encapsulation of filesystem-related operations.
Output inter-processor communications stream operating on external buffer.
A class for handling file names.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
static bool uniformFile(const fileNameList &)
Same file?
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
constexpr const char *const group
Group name for atomic constants.
const fileName & instance() const noexcept
const labelList & watchIndices() const
Return file-monitoring handles.
Input from file stream, using an ISstream.
An interval of (signed) integers defined by a start and a size.
Output inter-processor communications stream.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
virtual bool writeData(Ostream &) const =0
Pure virtual writeData function.
Dummy input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream....
A List obtained as a section of another List.
const fileName & rootPath() const
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
bool processorCase() const noexcept
Return true if this is a processor case.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
static word timeName(const scalar t, const int precision=precision_)
static const Enum< pathType > pathTypeNames_
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
Type
Enumerations to handle directory entry types.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
static bool master(const label communicator=worldComm)
Am I the master process.
virtual bool global() const
Is object global.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
fileState
Enumeration defining the file state.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
An ISstream with internal List storage. Always UNCOMPRESSED.
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type & value() const
Return const reference to value.
bool equal(scalar val) const
True if values are equal (includes SMALL for rounding)
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
const word & headerClassName() const noexcept
Return name of the class name read from header.
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
instance is absolute directory
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const labelList & below() const noexcept
const Time & time() const
Return Time associated with the objectRegistry.
List< instant > instantList
List of instants.
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=UPstream::worldComm)
Read into given buffer from given processor.
file found in time directory
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
virtual ~masterUncollatedFileOperation()
Destructor.
#define forAll(list, i)
Loop across all elements in list.
void stableSort(UList< T > &a)
bool good() const noexcept
True if next operation might succeed.
bool readHeader(Istream &is)
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
Registry of regIOobjects.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const
Reads header for regIOobject and returns an ISstream.
word format(conversionProperties.get< word >("format"))
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolList &procValid)
Read files on comms master.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object. checkGlobal : also check undecomposed case.
const label myComm_
Any communicator allocated by me.
const fileName & local() const noexcept
void setSize(const label n)
Alias for resize()
virtual void setTime(const Time &) const
Callback for time change.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
static bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &contentChars, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
const fileName & caseName() const
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
bool globalObject() const noexcept
Is object same for all processors?
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
instantList times() const
Search the case for valid time directories.
The IOstreamOption is a simple container for options an IOstream can normally have.
objectPath exists in 'processorsNN'
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
bool good() const noexcept
True if the managed pointer is non-null.
Generic output stream using a standard (STL) stream.
label findSortedIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
void finishedSends(const bool block=true)
Mark all sends as having been done.
masterUncollatedFileOperation(bool verbose)
Default construct.
streamFormat
Data format (ascii | binary)
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
as PROCUNCOLLATED but with instance
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
virtual bool rmDir(const fileName &dir, const bool silent=false) const
Remove a directory and its contents.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
General fileOperation initialiser. Handles -ioRanks option, using it to set the FOAM_IORANKS environm...
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
int infoDetailLevel
Global for selective suppression of Info output.
Structure for communicating between processors.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
errorManipArg< error, int > exit(error &err, const int errNo=1)
readOption readOpt() const noexcept
The read option.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static int nProcsSimpleSum
objectPath exists in 'processorN'
virtual std::istream & stdStream()
Access to underlying std::istream.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
const word & name() const noexcept
Return name.
const string & note() const noexcept
Return the optional note.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
const word & system() const
Return system name.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
static int & msgType() noexcept
Message tag of standard messages.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
fileName path() const
Return path.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
as PROCOBJECT but with instance
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
void close()
Close Istream.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label worldComm
Default communicator (all processors)
static bool & parRun() noexcept
Test if this a parallel run.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
static const word null
An empty word.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
objectPath exists in 'processorsNN_first-last'
void clear() noexcept
Same as reset(nullptr)
label above() const noexcept
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
virtual bool readData(Istream &)
Virtual readData function.
Input inter-processor communications stream.
bool writeHeader(Ostream &os) const
Write header with current type()
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An instant of time. Contains the time value and name.
static const List< commsStruct > & treeCommunication(const label communicator=worldComm)
Communication schedule for tree all-to-master (proc 0)
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
Input inter-processor communications stream operating on external buffer.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
fileName objectPath() const
The complete path + object name.
compressionType compression() const noexcept
Get the stream compression.
const word & constant() const
Return constant name.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
as PROCBASEOBJECT but with instance
typename parent_type::iterator iterator
fileName path() const
The complete path.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
#define WarningInFunction
Report a warning using Foam::Warning.
static labelList subRanks(const label n)
Get the list of processors that are part of this communicator.
pathType
Enumeration for the location of an IOobject.
static bool isAbsolute(const std::string &str)
Master-only drop-in replacement for OFstream.
const Time & time() const noexcept
Return time registry.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
defineTypeNameAndDebug(collatedFileOperation, 0)
A class for managing references or pointers (no reference counting)
static bool readHeader(IOobject &io, Istream &is)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
const objectRegistry & db() const noexcept
Return the local objectRegistry.