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;
205 const fileName& pDir = pDirs()[i].first();
207 processorsPath(io, io.
instance(), pDir)
209 if (objPath != writePath && isFileOrDir(
isFile, objPath))
211 searchType = pDirs()[i].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())
277 const fileName& pDir = pDirs()[i].first();
281 processorsPath(io, newInstancePath, pDir)
284 if (isFileOrDir(
isFile, fName))
286 switch (pDirs()[i].second().first())
288 case fileOperation::PROCUNCOLLATED:
291 fileOperation::PROCUNCOLLATEDINSTANCE;
294 case fileOperation::PROCBASEOBJECT:
296 searchType = fileOperation::PROCBASEINSTANCE;
299 case fileOperation::PROCOBJECT:
301 searchType = fileOperation::PROCINSTANCE;
319 if (isFileOrDir(
isFile, fName))
321 searchType = fileOperation::FINDINSTANCE;
327 searchType = fileOperation::NOTFOUND;
328 return fileName::null;
339 const word& instancePath
346 case fileOperation::ABSOLUTE:
352 case fileOperation::OBJECT:
358 case fileOperation::WRITEOBJECT:
364 case fileOperation::PROCUNCOLLATED:
369 "processor" +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
386 case fileOperation::PROCBASEOBJECT:
390 processorsPath(io, io.
instance(), procDir)
395 case fileOperation::PROCOBJECT:
399 processorsPath(io, io.
instance(), processorsDir(io))
404 case fileOperation::PARENTOBJECT:
412 case fileOperation::FINDINSTANCE:
420 case fileOperation::PROCUNCOLLATEDINSTANCE:
426 +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
443 case fileOperation::PROCBASEINSTANCE:
447 processorsPath(io, instancePath, procDir)
452 case fileOperation::PROCINSTANCE:
456 processorsPath(io, instancePath, processorsDir(io))
461 case fileOperation::NOTFOUND:
463 return fileName::null;
470 return fileName::null;
481 const fileName& object0 = filePaths[0];
483 for (
label i = 1; i < filePaths.size(); i++)
485 if (filePaths[i] != object0)
502 if (cmp == IOstream::compressionType::COMPRESSED)
506 Pout<<
"masterUncollatedFileOperation::readAndSend :"
507 <<
" Opening compressed " << filePath <<
endl;
510 IFstream is(filePath, IOstream::streamFormat::BINARY);
518 std::ostringstream stringStr;
520 string buf(stringStr.str());
525 os.
write(&buf[0], buf.size());
531 IFstream is(filePath, IOstream::streamFormat::BINARY);
542 Pout<<
"masterUncollatedFileOperation::readStream :"
543 <<
" From " << filePath <<
" reading " <<
label(
count)
570 IOstream::compressionType::COMPRESSED,
580 IOstream::compressionType::UNCOMPRESSED,
604 Pstream::commsTypes::nonBlocking,
609 if (Pstream::master(comm))
615 if (filePaths[0].empty())
626 proci < Pstream::nProcs(comm);
630 if (procValid[proci])
640 Pout<<
"masterUncollatedFileOperation::readStream :"
641 <<
" For uniform file " << filePaths[0]
642 <<
" sending to " << validProcs
643 <<
" in comm:" << comm <<
endl;
645 readAndSend(filePaths[0], validProcs, pBufs);
652 if (filePaths[0].empty())
665 <<
"problem while reading header for object "
677 proci < Pstream::nProcs(comm);
683 Pout<<
"masterUncollatedFileOperation::readStream :"
684 <<
" For processor " << proci
685 <<
" opening " << filePaths[proci] <<
endl;
688 const fileName& fPath = filePaths[proci];
690 if (procValid[proci] && !fPath.empty())
694 readAndSend(fPath,
labelList(1, proci), pBufs);
707 if (procValid[Pstream::myProcNo(comm)])
713 UIPstream is(Pstream::masterNo(), pBufs);
715 List<char> buf(recvSizes[Pstream::masterNo()]);
716 if (recvSizes[Pstream::masterNo()] > 0)
718 is.
read(buf.begin(), recvSizes[Pstream::masterNo()]);
723 Pout<<
"masterUncollatedFileOperation::readStream :"
724 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
726 const fileName& fName = filePaths[Pstream::myProcNo(comm)];
733 IOstream::currentVersion,
741 <<
"problem while reading header for object "
765 UPstream::allocateCommunicator
768 subRanks(Pstream::nProcs())
778 <<
"I/O : " << typeName
779 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
783 if (regIOobject::fileModificationChecking == regIOobject::timeStampMaster)
788 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
790 regIOobject::fileModificationChecking = regIOobject::timeStamp;
794 regIOobject::fileModificationChecking
795 == regIOobject::inotifyMaster
801 <<
"Resetting fileModificationChecking to inotify"
804 regIOobject::fileModificationChecking = regIOobject::inotify;
824 <<
"I/O : " << typeName
825 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
829 if (regIOobject::fileModificationChecking == regIOobject::timeStampMaster)
834 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
836 regIOobject::fileModificationChecking = regIOobject::timeStamp;
840 regIOobject::fileModificationChecking
841 == regIOobject::inotifyMaster
847 <<
"Resetting fileModificationChecking to inotify"
850 regIOobject::fileModificationChecking = regIOobject::inotify;
861 const string s(
"-ioRanks");
864 for (
int i=1; i<argc-1; i++)
869 setEnv(
"FOAM_IORANKS", argv[i+1],
true);
876 for (
int i=index+2; i<argc; i++)
905 return masterOp<mode_t, mkDirOp>
921 return masterOp<mode_t, chModOp>
934 const bool followLink
937 return masterOp<mode_t, modeOp>
950 const bool followLink
955 masterOp<label, typeOp>
969 const bool checkGzip,
970 const bool followLink
973 return masterOp<bool, existsOp>
986 const bool followLink
989 return masterOp<bool, isDirOp>
1002 const bool checkGzip,
1003 const bool followLink
1006 return masterOp<bool, isFileOp>
1019 const bool followLink
1022 return masterOp<off_t, fileSizeOp>
1035 const bool followLink
1038 return masterOp<time_t, lastModifiedOp>
1051 const bool followLink
1054 return masterOp<double, lastModifiedHROp>
1067 const std::string& ext
1070 return masterOp<bool, mvBakOp>
1085 return masterOp<bool, rmOp>
1101 return masterOp<bool, rmDirOp>
1115 const bool filtergz,
1116 const bool followLink
1119 return masterOp<fileNameList, readDirOp>
1133 const bool followLink
1136 return masterOp<bool, cpOp>
1153 return masterOp<bool, lnOp>
1168 const bool followLink
1171 return masterOp<bool, mvOp>
1184 const bool checkGlobal,
1186 const word& typeName,
1192 Pout<<
"masterUncollatedFileOperation::filePath :"
1194 <<
" checkGlobal:" << checkGlobal <<
endl;
1210 word newInstancePath;
1230 Pout<<
"masterUncollatedFileOperation::filePath :"
1231 <<
" master objPath:" << objPath
1233 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1243 label masterType(searchType);
1255 || io.
local() ==
"uniform"
1288 objPath = localObjectPath
1304 objPath = masterOp<fileName, fileOrNullOp>
1318 Pout<<
"masterUncollatedFileOperation::filePath :"
1319 <<
" Returning from file searching:" <<
endl
1321 <<
" filePath :" << objPath <<
endl <<
endl;
1329 const bool checkGlobal,
1336 Pout<<
"masterUncollatedFileOperation::dirPath :"
1338 <<
" checkGlobal:" << checkGlobal <<
endl;
1350 word newInstancePath;
1354 objPath = filePathInfo
1367 label masterType(searchType);
1379 || io.
local() ==
"uniform"
1412 objPath = localObjectPath
1427 objPath = masterOp<fileName, fileOrNullOp>
1441 Pout<<
"masterUncollatedFileOperation::dirPath :"
1442 <<
" Returning from file searching:" <<
endl
1444 <<
" filePath :" << objPath <<
endl <<
endl;
1465 if (isFileOrDir(
isFile, writePath))
1475 const fileName& pDir = pDirs[i].first();
1477 processorsPath(io, io.
instance(), pDir)
1479 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1489 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1502 const scalar startValue,
1503 const word& stopInstance
1508 Pout<<
"masterUncollatedFileOperation::findInstance :"
1509 <<
" Starting searching for name:" << startIO.
name()
1510 <<
" local:" << startIO.
local()
1511 <<
" from instance:" << startIO.
instance()
1543 if (!foundInstance.empty())
1548 Pout<<
"masterUncollatedFileOperation::findInstance :"
1549 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1550 <<
" found starting instance:" << io.
instance() <<
endl;
1565 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
1567 if (ts[instanceI].value() <= startValue)
1574 for (; instanceI >= 0; --instanceI)
1583 io.
instance() = ts[instanceI].name();
1589 Pout<<
"masterUncollatedFileOperation::findInstance :"
1590 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1598 if (ts[instanceI].
name() == stopInstance)
1606 if (io.
name().empty())
1609 <<
"Cannot find directory "
1611 <<
" down to " << stopInstance
1617 <<
"Cannot find file \"" << io.
name()
1618 <<
"\" in directory " << io.
local()
1620 <<
" down to " << stopInstance
1627 Pout<<
"masterUncollatedFileOperation::findInstance :"
1628 <<
" name:" << io.
name() <<
" local:" << io.
local()
1636 if (foundInstance.empty())
1643 if (!ts.size() || ts[0].name() != time.
constant())
1654 Pout<<
"masterUncollatedFileOperation::findInstance :"
1655 <<
" name:" << io.
name()
1656 <<
" local:" << io.
local()
1664 if (foundInstance.empty())
1673 <<
"Cannot find file \"" << io.
name() <<
"\" in directory "
1690 Pout<<
"masterUncollatedFileOperation::findInstance :"
1691 <<
" name:" << io.
name() <<
" local:" << io.
local()
1709 Pout<<
"masterUncollatedFileOperation::readObjects :"
1711 <<
" local:" << local <<
" instance:" << instance <<
endl;
1736 if (newInstance.empty())
1755 if (t.
equal(timeDirs[i].value()))
1777 Pout<<
"masterUncollatedFileOperation::readObjects :"
1778 <<
" newInstance:" << newInstance
1779 <<
" objectNames:" << objectNames <<
endl;
1790 const word& typeName
1797 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl
1799 <<
" fName :" << fName <<
endl;
1806 bool uniform = uniformFile(filePaths);
1854 if (!filePaths[proci].empty())
1856 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1858 result[proci] = result[proci-1];
1859 headerClassName[proci] = headerClassName[proci-1];
1860 note[proci] = note[proci-1];
1872 == decomposedBlockData::typeName
1885 note[proci] = io.
note();
1903 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1915 const word& typeName,
1921 Pout<<
"masterUncollatedFileOperation::readStream :"
1922 <<
" object : " << io.
name()
1923 <<
" global : " << io.
global()
1924 <<
" fName : " << fName <<
" valid:" << valid <<
endl;
1929 bool isCollated =
false;
1961 Pout<<
"masterUncollatedFileOperation::readStream :"
1962 <<
" For object : " << io.
name()
1963 <<
" doing straight IFstream input from "
1985 Pout<<
"masterUncollatedFileOperation::readStream :"
1986 <<
" For object : " << io.
name()
1987 <<
" starting collating input from " << fName <<
endl;
1993 label groupStart, groupSize, nProcs;
2016 <<
"Could not detect processor number"
2024 if (groupStart != -1 && groupSize > 0)
2026 proci = proci-groupStart;
2031 Pout<<
"masterUncollatedFileOperation::readStream :"
2032 <<
" For object : " << io.
name()
2033 <<
" starting input from block " << proci
2034 <<
" of " << isPtr().name() <<
endl;
2042 string versionString;
2043 string formatString;
2046 versionString = isPtr().version().str();
2048 os << isPtr().format();
2049 formatString = (os.
str());
2057 bool bigSize = sz > off_t(maxMasterFileBufferSize);
2062 label readComm = -1;
2063 if (groupStart != -1 && groupSize > 0)
2105 Pout<<
"masterUncollatedFileOperation::readStream :"
2106 <<
" For object : " << io.
name()
2107 <<
" starting separated input from " << fName <<
endl;
2134 bool uniform = uniformFile(filePaths);
2136 return read(io, comm_,
uniform, filePaths, procValid);
2145 const bool masterOnly,
2147 const word& typeName
2156 Pout<<
"masterUncollatedFileOperation::read :"
2157 <<
" Reading global object " << io.
name() <<
endl;
2167 ok = io.
readData(io.readStream(typeName));
2198 if (myComm.
above() != -1)
2218 myComm.
below()[belowI],
2232 Pout<<
"masterUncollatedFileOperation::read :"
2233 <<
" Reading local object " << io.
name() <<
endl;
2236 ok = io.
readData(io.readStream(typeName));
2257 Pout<<
"masterUncollatedFileOperation::writeObject :"
2258 <<
" io:" << pathName <<
" valid:" << valid <<
endl;
2303 const word& constantName
2306 const auto iter = times_.cfind(directory);
2311 Pout<<
"masterUncollatedFileOperation::findTimes :"
2312 <<
" Found " << iter()->size() <<
" cached times" <<
endl;
2334 times_.set(directory, tPtr);
2338 Pout<<
"masterUncollatedFileOperation::findTimes :"
2339 <<
" Caching times:" << *tPtr <<
nl
2340 <<
" for directory:" << directory <<
endl;
2366 if (times.size() > 0 && times[0].name() == tm.
constant())
2382 Pout<<
"masterUncollatedFileOperation::setTime :"
2383 <<
" Caching time " << tm.
timeName()
2384 <<
" for case:" << tm.
path() <<
endl;
2398 Pout<<
"masterUncollatedFileOperation::setTime :"
2399 <<
" Caching time " << tm.
timeName()
2400 <<
" for case:" << tm.
path() <<
endl;
2436 const bool uniform = uniformFile(filePaths);
2442 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2443 <<
" Opening global file " << filePath <<
endl;
2449 ? IOstream::compressionType::COMPRESSED
2450 : IOstream::compressionType::UNCOMPRESSED
2461 procs[proci-1] = proci;
2464 readAndSend(filePath, cmp, procs, pBufs);
2478 ? IOstream::compressionType::COMPRESSED
2479 : IOstream::compressionType::UNCOMPRESSED
2509 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2510 <<
" Reading " << filePath
2517 is.
read(buf.begin(), buf.size());
2521 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2522 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2588 watchFd = monitor().addWatch(fName);
2597 const label watchIndex
2603 ok = monitor().removeWatch(watchIndex);
2622 if (monitor().getFile(watchIndices[i]) == fName)
2647 const label index = findWatch(watchIndices,
f);
2651 newWatchIndices.
append(addWatch(
f));
2656 newWatchIndices.
append(watchIndices[index]);
2657 removedWatches.
erase(index);
2662 for (
const label index : removedWatches)
2664 removeWatch(watchIndices[index]);
2673 const label watchIndex
2679 fName = monitor().getFile(watchIndex);
2688 const bool masterOnly,
2694 monitor().updateStates(
true,
false);
2708 state = monitor().getState(watchFd);
2722 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)
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 constexpr int masterNo() noexcept
Process index of the master.
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.
const labelList & watchIndices() const
Return file-monitoring handles.
Input from file stream, using an ISstream.
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 stream for input. Aborts at any attempt to read from it.
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.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
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()
Is this a parallel run?
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.
static const versionNumber currentVersion
The current version number.
Type
Enumerations to handle directory entry types.
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.
bool valid() const noexcept
True if the managed pointer is non-null.
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
An Ostream wrapper for parallel output to std::cout.
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.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
Representation of a major/minor version number.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
messageStream Info
Information stream (uses stdout - output is on the master only)
A class for managing temporary objects without reference counting.
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.
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.
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
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.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static bool master(const label communicator=0)
Am I the master process.
static int nProcsSimpleSum
virtual std::istream & stdStream()
Access to underlying std::istream.
Foam::string str() const
Get the string - as Foam::string rather than std::string.
const string & note() const
Return the optional note.
static void readAndSend(const fileName &filePath, const IOstream::compressionType cmp, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
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.
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.
Output to string buffer, using a OSstream.
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 writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
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
Delete managed object and set pointer to 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.
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Input inter-processor communications stream operating on external buffer.
static const List< commsStruct > & linearCommunication(const label communicator=0)
Communication schedule for linear all-to-master (proc 0)
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.
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.
virtual autoPtr< Ostream > NewOFstream(const fileName &pathname, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
Generate an Ostream that writes a file.
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.
Database for solution data, solver performance and other reduced data.
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
Master-only drop-in replacement for OFstream.
defineTypeNameAndDebug(collatedFileOperation, 0)
const labelList & below() const
static const List< commsStruct > & treeCommunication(const label communicator=0)
Communication schedule for tree all-to-master (proc 0)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.