Go to the documentation of this file.
48 namespace fileOperations
54 masterUncollatedFileOperation,
64 "maxMasterFileBufferSize",
73 masterUncollatedFileOperationInitialise,
88 string ioRanksString(
getEnv(
"FOAM_IORANKS"));
89 if (ioRanksString.empty())
100 if (!ioRanks.found(0))
103 <<
"Rank 0 (master) should be in the IO ranks. Currently "
108 const bitSet isIOrank(
n, ioRanks);
110 for (label proci = Pstream::myProcNo(); proci >= 0; --proci)
118 label rank = proci+1;
119 rank <
n && !isIOrank[rank];
148 if (t.
equal(timeDirs[i].value()))
150 return timeDirs[i].name();
161 const bool checkGlobal,
167 word& newInstancePath
170 procsDir = word::null;
171 newInstancePath = word::null;
177 if (isFileOrDir(
isFile, objPath))
179 searchType = fileOperation::ABSOLUTE;
184 searchType = fileOperation::NOTFOUND;
185 return fileName::null;
193 if (isFileOrDir(
isFile, writePath))
195 searchType = fileOperation::WRITEOBJECT;
204 for (
const dirIndex& dirIdx : pDirs())
206 const fileName& pDir = dirIdx.first();
208 processorsPath(io, io.
instance(), pDir)
210 if (objPath != writePath && isFileOrDir(
isFile, objPath))
212 searchType = dirIdx.second().first();
224 localPath != writePath
225 && isFileOrDir(
isFile, localPath)
228 searchType = fileOperation::OBJECT;
250 if (isFileOrDir(
isFile, parentPath))
252 searchType = fileOperation::PARENTOBJECT;
259 const auto pathFnd = times_.cfind(io.
time().
path());
261 if (
search && pathFnd.found())
263 newInstancePath = findInstancePath
269 if (newInstancePath.size() && newInstancePath != io.
instance())
277 for (
const dirIndex& dirIdx : pDirs())
279 const fileName& pDir = dirIdx.first();
283 processorsPath(io, newInstancePath, pDir)
286 if (isFileOrDir(
isFile, fName))
288 switch (dirIdx.second().first())
290 case fileOperation::PROCUNCOLLATED:
293 fileOperation::PROCUNCOLLATEDINSTANCE;
296 case fileOperation::PROCBASEOBJECT:
298 searchType = fileOperation::PROCBASEINSTANCE;
301 case fileOperation::PROCOBJECT:
303 searchType = fileOperation::PROCINSTANCE;
321 if (isFileOrDir(
isFile, fName))
323 searchType = fileOperation::FINDINSTANCE;
329 searchType = fileOperation::NOTFOUND;
330 return fileName::null;
341 const word& instancePath
348 case fileOperation::ABSOLUTE:
354 case fileOperation::OBJECT:
360 case fileOperation::WRITEOBJECT:
366 case fileOperation::PROCUNCOLLATED:
371 "processor" +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
388 case fileOperation::PROCBASEOBJECT:
392 processorsPath(io, io.
instance(), procDir)
397 case fileOperation::PROCOBJECT:
401 processorsPath(io, io.
instance(), processorsDir(io))
406 case fileOperation::PARENTOBJECT:
414 case fileOperation::FINDINSTANCE:
422 case fileOperation::PROCUNCOLLATEDINSTANCE:
428 +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
445 case fileOperation::PROCBASEINSTANCE:
449 processorsPath(io, instancePath, procDir)
454 case fileOperation::PROCINSTANCE:
458 processorsPath(io, instancePath, processorsDir(io))
463 case fileOperation::NOTFOUND:
465 return fileName::null;
472 return fileName::null;
483 const fileName& object0 = filePaths[0];
485 for (label i = 1; i < filePaths.size(); i++)
487 if (filePaths[i] != object0)
503 IFstream ifs(filePath, IOstream::streamFormat::BINARY);
508 <<
"Cannot open file " << filePath
514 Pout<<
"masterUncollatedFileOperation::readAndSend :"
519 if (ifs.
compression() == IOstream::compressionType::COMPRESSED)
525 const std::string buf
527 std::istreambuf_iterator<char>(ifs.
stdStream()),
528 std::istreambuf_iterator<char>()
531 for (
const label proci : procs)
534 os.
write(buf.data(), buf.length());
539 Pout<<
"masterUncollatedFileOperation::readStream :"
540 <<
" From " << filePath <<
" sent " << buf.size()
552 for (
const label proci : procs)
560 Pout<<
"masterUncollatedFileOperation::readStream :"
561 <<
" From " << filePath <<
" sent " << buf.size()
584 Pstream::commsTypes::nonBlocking,
589 if (Pstream::master(comm))
595 if (filePaths[0].empty())
603 for (
const int proci : Pstream::allProcs(comm))
605 if (procValid[proci])
615 Pout<<
"masterUncollatedFileOperation::readStream :"
616 <<
" For uniform file " << filePaths[0]
617 <<
" sending to " << validProcs
618 <<
" in comm:" << comm <<
endl;
620 readAndSend(filePaths[0], validProcs, pBufs);
627 if (filePaths[0].empty())
641 <<
"problem while reading header for object "
647 for (
const int proci : Pstream::subProcs(comm))
651 Pout<<
"masterUncollatedFileOperation::readStream :"
652 <<
" For processor " << proci
653 <<
" opening " << filePaths[proci] <<
endl;
656 const fileName& fPath = filePaths[proci];
658 if (procValid[proci] && !fPath.empty())
675 if (procValid[Pstream::myProcNo(comm)])
681 UIPstream is(Pstream::masterNo(), pBufs);
683 List<char> buf(recvSizes[Pstream::masterNo()]);
684 if (recvSizes[Pstream::masterNo()] > 0)
686 is.
read(buf.data(), recvSizes[Pstream::masterNo()]);
691 Pout<<
"masterUncollatedFileOperation::readStream :"
692 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
702 isPtr->name() = filePaths[Pstream::myProcNo(comm)];
707 <<
"problem while reading header for object "
731 UPstream::allocateCommunicator
734 subRanks(Pstream::nProcs())
744 <<
"I/O : " << typeName
745 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
749 if (regIOobject::fileModificationChecking == regIOobject::timeStampMaster)
754 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
756 regIOobject::fileModificationChecking = regIOobject::timeStamp;
760 regIOobject::fileModificationChecking
761 == regIOobject::inotifyMaster
767 <<
"Resetting fileModificationChecking to inotify"
770 regIOobject::fileModificationChecking = regIOobject::inotify;
790 <<
"I/O : " << typeName
791 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
795 if (regIOobject::fileModificationChecking == regIOobject::timeStampMaster)
800 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
802 regIOobject::fileModificationChecking = regIOobject::timeStamp;
806 regIOobject::fileModificationChecking
807 == regIOobject::inotifyMaster
813 <<
"Resetting fileModificationChecking to inotify"
816 regIOobject::fileModificationChecking = regIOobject::inotify;
827 const string s(
"-ioRanks");
830 for (
int i=1; i<argc-1; i++)
835 setEnv(
"FOAM_IORANKS", argv[i+1],
true);
842 for (
int i=index+2; i<argc; i++)
871 return masterOp<mode_t, mkDirOp>
887 return masterOp<mode_t, chModOp>
900 const bool followLink
903 return masterOp<mode_t, modeOp>
916 const bool followLink
921 masterOp<label, typeOp>
935 const bool checkGzip,
936 const bool followLink
939 return masterOp<bool, existsOp>
952 const bool followLink
955 return masterOp<bool, isDirOp>
968 const bool checkGzip,
969 const bool followLink
972 return masterOp<bool, isFileOp>
985 const bool followLink
988 return masterOp<off_t, fileSizeOp>
1001 const bool followLink
1004 return masterOp<time_t, lastModifiedOp>
1017 const bool followLink
1020 return masterOp<double, lastModifiedHROp>
1033 const std::string& ext
1036 return masterOp<bool, mvBakOp>
1051 return masterOp<bool, rmOp>
1067 return masterOp<bool, rmDirOp>
1081 const bool filtergz,
1082 const bool followLink
1085 return masterOp<fileNameList, readDirOp>
1099 const bool followLink
1102 return masterOp<bool, cpOp>
1119 return masterOp<bool, lnOp>
1134 const bool followLink
1137 return masterOp<bool, mvOp>
1150 const bool checkGlobal,
1152 const word& typeName,
1158 Pout<<
"masterUncollatedFileOperation::filePath :"
1160 <<
" checkGlobal:" << checkGlobal <<
endl;
1176 word newInstancePath;
1196 Pout<<
"masterUncollatedFileOperation::filePath :"
1197 <<
" master objPath:" << objPath
1199 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1209 label masterType(searchType);
1221 || io.
local() ==
"uniform"
1254 objPath = localObjectPath
1270 objPath = masterOp<fileName, fileOrNullOp>
1284 Pout<<
"masterUncollatedFileOperation::filePath :"
1285 <<
" Returning from file searching:" <<
endl
1287 <<
" filePath :" << objPath <<
endl <<
endl;
1295 const bool checkGlobal,
1302 Pout<<
"masterUncollatedFileOperation::dirPath :"
1304 <<
" checkGlobal:" << checkGlobal <<
endl;
1316 word newInstancePath;
1320 objPath = filePathInfo
1333 label masterType(searchType);
1345 || io.
local() ==
"uniform"
1378 objPath = localObjectPath
1394 objPath = masterOp<fileName, fileOrNullOp>
1408 Pout<<
"masterUncollatedFileOperation::dirPath :"
1409 <<
" Returning from file searching:" <<
endl
1411 <<
" filePath :" << objPath <<
endl <<
endl;
1432 if (isFileOrDir(
isFile, writePath))
1440 for (
const dirIndex& dirIdx : pDirs)
1442 const fileName& pDir = dirIdx.first();
1444 processorsPath(io, io.
instance(), pDir)
1446 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1456 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1469 const scalar startValue,
1470 const word& stopInstance
1475 Pout<<
"masterUncollatedFileOperation::findInstance :"
1476 <<
" Starting searching for name:" << startIO.
name()
1477 <<
" local:" << startIO.
local()
1478 <<
" from instance:" << startIO.
instance()
1510 if (!foundInstance.empty())
1515 Pout<<
"masterUncollatedFileOperation::findInstance :"
1516 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1517 <<
" found starting instance:" << io.
instance() <<
endl;
1532 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
1534 if (ts[instanceI].value() <= startValue)
1541 for (; instanceI >= 0; --instanceI)
1550 io.
instance() = ts[instanceI].name();
1556 Pout<<
"masterUncollatedFileOperation::findInstance :"
1557 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1565 if (ts[instanceI].
name() == stopInstance)
1573 if (io.
name().empty())
1576 <<
"Cannot find directory "
1578 <<
" down to " << stopInstance
1584 <<
"Cannot find file \"" << io.
name()
1585 <<
"\" in directory " << io.
local()
1587 <<
" down to " << stopInstance
1594 Pout<<
"masterUncollatedFileOperation::findInstance :"
1595 <<
" name:" << io.
name() <<
" local:" << io.
local()
1603 if (foundInstance.empty())
1610 if (!ts.size() || ts[0].name() != time.
constant())
1621 Pout<<
"masterUncollatedFileOperation::findInstance :"
1622 <<
" name:" << io.
name()
1623 <<
" local:" << io.
local()
1631 if (foundInstance.empty())
1640 <<
"Cannot find file \"" << io.
name() <<
"\" in directory "
1657 Pout<<
"masterUncollatedFileOperation::findInstance :"
1658 <<
" name:" << io.
name() <<
" local:" << io.
local()
1676 Pout<<
"masterUncollatedFileOperation::readObjects :"
1678 <<
" local:" << local <<
" instance:" << instance <<
endl;
1702 if (newInstance.empty())
1721 if (t.
equal(timeDirs[i].value()))
1743 Pout<<
"masterUncollatedFileOperation::readObjects :"
1744 <<
" newInstance:" << newInstance
1745 <<
" objectNames:" << objectNames <<
endl;
1756 const word& typeName
1763 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl
1765 <<
" fName :" << fName <<
endl;
1772 bool uniform = uniformFile(filePaths);
1820 if (!filePaths[proci].empty())
1822 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1824 result[proci] = result[proci-1];
1825 headerClassName[proci] = headerClassName[proci-1];
1826 note[proci] = note[proci-1];
1838 == decomposedBlockData::typeName
1851 note[proci] = io.
note();
1869 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1881 const word& typeName,
1887 Pout<<
"masterUncollatedFileOperation::readStream :"
1888 <<
" object : " << io.
name()
1889 <<
" global : " << io.
global()
1890 <<
" fName : " << fName <<
" valid:" << valid <<
endl;
1895 bool isCollated =
false;
1927 Pout<<
"masterUncollatedFileOperation::readStream :"
1928 <<
" For object : " << io.
name()
1929 <<
" doing straight IFstream input from "
1951 Pout<<
"masterUncollatedFileOperation::readStream :"
1952 <<
" For object : " << io.
name()
1953 <<
" starting collating input from " << fName <<
endl;
1964 splitProcessorPath(fName,
path, procDir, local,
group, nProcs);
1971 label proci = detectProcessorPath(io.
objectPath());
1976 <<
"Could not detect processor number"
1984 proci = proci -
group.start();
1989 Pout<<
"masterUncollatedFileOperation::readStream :"
1990 <<
" For object : " << io.
name()
1991 <<
" starting input from block " << proci
1992 <<
" of " << isPtr->name() <<
endl;
2001 bool bigSize = sz > off_t(maxMasterFileBufferSize);
2006 label readComm = -1;
2049 Pout<<
"masterUncollatedFileOperation::readStream :"
2050 <<
" For object : " << io.
name()
2051 <<
" starting separated input from " << fName <<
endl;
2078 const bool uniform = uniformFile(filePaths);
2080 return read(io, comm_,
uniform, filePaths, procValid);
2089 const bool masterOnly,
2091 const word& typeName
2100 Pout<<
"masterUncollatedFileOperation::read :"
2101 <<
" Reading global object " << io.
name() <<
endl;
2110 ok = io.
readData(io.readStream(typeName));
2141 if (myComm.
above() != -1)
2161 myComm.
below()[belowI],
2175 Pout<<
"masterUncollatedFileOperation::read :"
2176 <<
" Reading local object " << io.
name() <<
endl;
2179 ok = io.
readData(io.readStream(typeName));
2198 Pout<<
"masterUncollatedFileOperation::writeObject :"
2199 <<
" io:" << pathName <<
" valid:" << valid <<
endl;
2234 const word& constantName
2237 const auto iter = times_.cfind(directory);
2242 Pout<<
"masterUncollatedFileOperation::findTimes :"
2243 <<
" Found " << iter()->size() <<
" cached times" <<
endl;
2266 times_.set(directory, tPtr);
2270 Pout<<
"masterUncollatedFileOperation::findTimes :"
2271 <<
" Caching times:" << *tPtr <<
nl
2272 <<
" for directory:" << directory <<
endl;
2301 const label skipConst =
2303 (!times.empty() && times[0].name() == tm.
constant())
2320 Pout<<
"masterUncollatedFileOperation::setTime :"
2321 <<
" Caching time " << tm.
timeName()
2322 <<
" for case:" << tm.
path() <<
endl;
2328 times, times.size()-skipConst, skipConst
2364 const bool uniform = uniformFile(filePaths);
2370 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2371 <<
" Opening global file " << filePath <<
endl;
2408 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2409 <<
" Reading " << filePath
2416 is.
read(buf.data(), buf.size());
2420 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2421 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2431 isPtr->name() = filePath;
2480 watchFd = monitor().addWatch(fName);
2489 const label watchIndex
2495 ok = monitor().removeWatch(watchIndex);
2514 if (monitor().getFile(watchIndices[i]) == fName)
2539 const label index = findWatch(watchIndices,
f);
2543 newWatchIndices.
append(addWatch(
f));
2548 newWatchIndices.
append(watchIndices[index]);
2549 removedWatches.
erase(index);
2554 for (
const label index : removedWatches)
2556 removeWatch(watchIndices[index]);
2565 const label watchIndex
2571 fName = monitor().getFile(watchIndex);
2580 const bool masterOnly,
2586 monitor().updateStates(
true,
false);
2600 state = monitor().getState(watchFd);
2614 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)
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
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.
const word & name() const
Return name.
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.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
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 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.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
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
const fileName & instance() const
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const Time & time() const
Return time.
static bool & parRun()
Test if this a parallel run, or allow modify access.
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.
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.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
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.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const Time & time() const
Return time.
List< instant > instantList
List of instants.
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
masterUncollatedFileOperationInitialise(int &argc, char **&argv)
Construct from components.
string getEnv(const std::string &envName)
Get environment value for given envName.
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 readHeader(Istream &is)
Read header.
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
const objectRegistry & db() const
Return the local objectRegistry.
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.
const fileName & local() const
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
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.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
pathType
Enumeration for the location of an IOobject.
word name(const complex &c)
Return string representation of complex.
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.
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
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.
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
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. This will start receives.
masterUncollatedFileOperation(bool verbose)
Construct null.
streamFormat
Data format (ascii | binary)
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
Macros for easy insertion into run-time selection tables.
Input from string buffer, using a ISstream.
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.
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)
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
const word & headerClassName() const
Return name of the class name read from header.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static int nProcsSimpleSum
virtual std::istream & stdStream()
Access to underlying std::istream.
const string & note() const
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.
static int & msgType()
Message tag of standard messages.
#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 bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &data, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
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.
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)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
readOption readOpt() const
The read option.
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)
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?
void clear() noexcept
Same as reset(nullptr)
#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.
#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...
bool good() const
Return true if next operation might succeed.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
fileName objectPath() const
The complete path + object name.
bool processorCase() const
Return true if this is a processor case.
compressionType compression() const noexcept
Get the stream compression.
void setSize(const label newSize)
Alias for resize(const label)
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.
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.
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
Master-only drop-in replacement for OFstream.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
defineTypeNameAndDebug(collatedFileOperation, 0)
const labelList & below() const
A class for managing references or pointers (no reference counting)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.