47 namespace fileOperations
53 masterUncollatedFileOperation,
59 masterUncollatedFileOperation,
69 "maxMasterFileBufferSize",
77 fileOperationInitialise,
78 fileOperationInitialise_unthreaded,
98 const auto inputSize = ifs.
fileSize();
109 const uint64_t chunkSize =
113 : uint64_t(2*inputSize)
118 for (
int iter = 1; iter < 100000; ++iter)
125 const std::streamsize nread = iss.gcount();
134 buffer.
resize(label(beg));
139 beg += uint64_t(nread);
140 if (nread >= 0 && uint64_t(nread) < chunkSize)
143 buffer.
resize(label(beg));
157 const std::streamsize nread = iss.gcount();
170 buffer.
resize(label(nread));
198 if (t.
equal(timeDirs[i].value()))
200 return timeDirs[i].name();
211 const bool checkGlobal,
214 const dirIndexList& pDirs,
216 pathType& searchType,
218 word& newInstancePath
222 newInstancePath.clear();
224 if (
io.instance().isAbsolute())
228 if (isFileOrDir(
isFile, objPath))
242 fileName writePath(objectPath(
io,
io.headerClassName()));
244 if (isFileOrDir(
isFile, writePath))
251 if (
io.time().processorCase())
253 for (
const dirIndex& dirIdx : pDirs)
255 const fileName& pDir = dirIdx.first();
257 processorsPath(
io,
io.instance(), pDir)
259 if (objPath != writePath && isFileOrDir(
isFile, objPath))
261 searchType = dirIdx.second().first();
269 fileName localPath =
io.objectPath();
273 localPath != writePath
274 && isFileOrDir(
isFile, localPath)
288 &&
io.time().processorCase()
290 io.instance() ==
io.time().system()
291 ||
io.instance() ==
io.time().constant()
295 fileName parentPath =
296 io.rootPath()/
io.time().globalCaseName()
297 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
299 if (isFileOrDir(
isFile, parentPath))
308 const auto pathFnd = times_.cfind(
io.time().path());
310 if (
search && pathFnd.good())
312 newInstancePath = findInstancePath
315 instant(
io.instance())
318 if (newInstancePath.size() && newInstancePath !=
io.instance())
321 for (
const dirIndex& dirIdx : pDirs)
323 const fileName& pDir = dirIdx.first();
327 processorsPath(
io, newInstancePath, pDir)
330 if (isFileOrDir(
isFile, fName))
332 switch (dirIdx.second().first())
362 io.rootPath()/
io.caseName()
363 /newInstancePath/
io.db().dbDir()/
io.local()/
io.name()
365 if (isFileOrDir(
isFile, fName))
384 const pathType& searchType,
386 const word& instancePath
395 return io.instance()/
io.name();
401 return io.path()/
io.name();
407 return objectPath(
io,
io.headerClassName());
437 processorsPath(
io,
io.instance(), procDir)
446 processorsPath(
io,
io.instance(), processorsDir(
io))
454 io.rootPath()/
io.time().globalCaseName()
455 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
462 io.rootPath()/
io.caseName()
463 /instancePath/
io.db().dbDir()/
io.local()/
io.name();
494 processorsPath(
io, instancePath, procDir)
503 processorsPath(
io, instancePath, processorsDir(
io))
525 const fileName& filePath,
527 PstreamBuffers& pBufs
530 if (recvProcs.empty())
return;
537 <<
"Cannot open file " << filePath
545 Info<<
"masterUncollatedFileOperation::readAndSend :" 546 <<
" compressed:" << bool(ifs.compression()) <<
" " 553 for (
const label proci : recvProcs)
555 UOPstream
os(proci, pBufs);
556 os.write(buf.cdata_bytes(), buf.size_bytes());
561 Info<<
"masterUncollatedFileOperation::readStream :" 562 <<
" From " << filePath <<
" sent " << buf.size()
588 if (filePaths[0].empty())
591 <<
"Cannot find file " <<
io.objectPath()
592 <<
" fileHandler : comm:" << comm
600 if (readOnProcs[proci])
610 Pout<<
"masterUncollatedFileOperation::readStream :" 611 <<
" For uniform file " << filePaths[0]
612 <<
" sending to " << recvProcs
613 <<
" in comm:" << comm <<
endl;
615 readAndSend(filePaths[0], recvProcs, pBufs);
622 if (filePaths[0].empty())
625 <<
"Cannot find file " <<
io.objectPath()
626 <<
" fileHandler : comm:" << comm
632 isPtr.
reset(
new IFstream(filePaths[0]));
635 if (!
io.readHeader(*isPtr))
638 <<
"problem while reading header for object " 640 <<
" fileHandler : comm:" << comm
651 Pout<<
"masterUncollatedFileOperation::readStream :" 652 <<
" For processor " << proci
653 <<
" opening " << filePaths[proci] <<
endl;
656 const fileName& fPath = filePaths[proci];
658 if (readOnProcs[proci] && !fPath.empty())
662 readAndSend(fPath,
labelList(one{}, proci), pBufs);
684 is.read(buf.data(), buf.size());
689 Pout<<
"masterUncollatedFileOperation::readStream :" 690 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
697 isPtr.
reset(
new ICharStream(std::move(buf)));
702 if (!
io.readHeader(*isPtr))
705 <<
"problem while reading header for object " 707 <<
" fileHandler : comm:" << comm
714 isPtr.
reset(
new dummyISstream());
747 return commAndIORanks;
755 void Foam::fileOperations::masterUncollatedFileOperation::init(
bool verbose)
762 <<
"I/O : " << typeName
763 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')' 772 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
781 <<
"Resetting fileModificationChecking to inotify" 799 managedComm_(getManagedComm(comm_))
826 const bool distributedRoots,
857 managedComm_ = getManagedComm(comm_);
878 return masterOp<mode_t>
894 return masterOp<mode_t>
907 const bool followLink
910 return masterOp<mode_t>
923 const bool followLink
942 const bool checkGzip,
943 const bool followLink
946 return masterOp<bool>
949 existsOp(checkGzip, followLink),
959 const bool followLink
962 return masterOp<bool>
975 const bool checkGzip,
976 const bool followLink
979 return masterOp<bool>
982 isFileOp(checkGzip, followLink),
992 const bool followLink
995 return masterOp<off_t>
998 fileSizeOp(followLink),
1008 const bool followLink
1011 return masterOp<time_t>
1014 lastModifiedOp(followLink),
1024 const bool followLink
1027 return masterOp<double>
1030 highResLastModifiedOp(followLink),
1040 const std::string& ext
1043 return masterOp<bool>
1058 return masterOp<bool>
1072 const bool emptyOnly
1075 return masterOp<bool>
1078 rmDirOp(silent, emptyOnly),
1089 const bool filtergz,
1090 const bool followLink
1093 return masterOp<fileNameList>
1096 readDirOp(
type, filtergz, followLink),
1107 const bool followLink
1110 return masterOp<bool>
1127 return masterOp<bool>
1142 const bool followLink
1145 return masterOp<bool>
1160 const bool checkGlobal,
1162 const word& typeName,
1168 Pout<<
"masterUncollatedFileOperation::filePath :" 1169 <<
" objectPath:" <<
io.objectPath()
1170 <<
" checkGlobal:" << checkGlobal
1180 if (cacheLevel() > 0)
1182 (void)findTimes(
io.time().path(),
io.time().constant());
1188 pathType searchType = NOTFOUND;
1190 word newInstancePath;
1213 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1219 Pout<<
"masterUncollatedFileOperation::filePath :" 1220 <<
" master objPath:" << objPath
1222 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1233 int masterType(searchType);
1235 searchType = pathType(masterType);
1244 ||
io.local() ==
"uniform" 1276 objPath = localObjectPath
1292 objPath = masterOp<fileName>
1306 Pout<<
"masterUncollatedFileOperation::filePath :" 1307 <<
" Returning from file searching using type " 1309 <<
" objectPath:" <<
io.objectPath() <<
endl 1318 const bool checkGlobal,
1325 Pout<<
"masterUncollatedFileOperation::dirPath :" 1326 <<
" objectPath:" <<
io.objectPath()
1327 <<
" checkGlobal:" << checkGlobal
1334 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1337 if (cacheLevel() > 0)
1339 (void)findTimes(
io.time().path(),
io.time().constant());
1345 pathType searchType = NOTFOUND;
1347 word newInstancePath;
1356 objPath = filePathInfo
1368 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1374 Pout<<
"masterUncollatedFileOperation::dirPath :" 1375 <<
" master objPath:" << objPath
1377 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1389 int masterType(searchType);
1391 searchType = pathType(masterType);
1401 ||
io.local() ==
"uniform" 1434 objPath = localObjectPath
1450 objPath = masterOp<fileName>
1453 fileOrNullOp(
false),
1464 Pout<<
"masterUncollatedFileOperation::dirPath :" 1465 <<
" Returning from directory searching using type " 1467 <<
" objectPath:" <<
io.objectPath() <<
endl 1476 const dirIndexList& pDirs,
1483 const bool isFile = !
io.name().empty();
1489 if (isFileOrDir(
isFile, writePath))
1495 if (
io.time().processorCase())
1497 for (
const dirIndex& dirIdx : pDirs)
1499 const fileName& pDir = dirIdx.first();
1501 processorsPath(
io,
io.instance(), pDir)
1503 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1511 fileName localPath =
io.objectPath();
1513 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1526 const scalar startValue,
1527 const word& stopInstance
1532 Pout<<
"masterUncollatedFileOperation::findInstance :" 1533 <<
" Starting searching for name:" << startIO.
name()
1534 <<
" local:" << startIO.
local()
1535 <<
" from instance:" << startIO.
instance()
1562 foundInstance =
io.instance();
1564 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1573 if (!foundInstance.empty())
1575 io.instance() = foundInstance;
1578 Pout<<
"masterUncollatedFileOperation::findInstance :" 1579 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1580 <<
" found starting instance:" <<
io.instance() <<
endl;
1589 enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 };
1601 label instIndex = ts.size()-1;
1604 for (; instIndex >= 0; --instIndex)
1606 if (ts[instIndex].value() <= startValue)
1613 for (; instIndex >= 0; --instIndex)
1622 io.instance() = ts[instIndex].name();
1625 foundInstance =
io.instance();
1628 Pout<<
"masterUncollatedFileOperation::findInstance :" 1629 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1630 <<
" found at:" <<
io.instance()
1637 if (
io.instance() == stopInstance)
1641 Pout<<
"masterUncollatedFileOperation::findInstance :" 1642 <<
" name:" <<
io.name()
1643 <<
" local:" <<
io.local()
1644 <<
" at stop-instance:" <<
io.instance() <<
endl;
1649 failed = failureCodes::FAILED_STOPINST;
1653 foundInstance =
io.instance();
1674 !failed && foundInstance.empty()
1675 && (ts.empty() || ts[0].name() != time.
constant() || startValue < 0)
1689 Pout<<
"masterUncollatedFileOperation::findInstance :" 1690 <<
" name:" <<
io.name()
1691 <<
" local:" <<
io.local()
1692 <<
" at:" <<
io.instance() <<
endl;
1694 foundInstance =
io.instance();
1698 if (!failed && foundInstance.empty())
1702 failed = failureCodes::FAILED_CONSTINST;
1710 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1717 io.instance() = foundInstance;
1726 if (!
io.name().empty())
1729 <<
" file \"" <<
io.name() <<
"\" in";
1734 <<
io.local() <<
" in times " 1735 << startIO.
instance() <<
" down to ";
1737 if (failed == failureCodes::FAILED_STOPINST)
1750 Pout<<
"masterUncollatedFileOperation::findInstance :" 1751 <<
" name:" <<
io.name() <<
" local:" <<
io.local()
1752 <<
" returning instance:" <<
io.instance() <<
endl;
1769 Pout<<
"masterUncollatedFileOperation::readObjects :" 1771 <<
" local:" <<
local <<
" instance:" << instance <<
endl;
1775 newInstance.clear();
1797 if (newInstance.empty())
1813 const instant t(instance);
1816 if (t.
equal(timeDirs[i].value()))
1830 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1839 Pout<<
"masterUncollatedFileOperation::readObjects :" 1840 <<
" newInstance:" << newInstance
1841 <<
" objectNames:" << objectNames <<
endl;
1852 const word& typeName
1859 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl 1860 <<
" objectPath:" <<
io.objectPath() <<
endl 1861 <<
" filePath :" << fName <<
endl;
1902 io.headerClassName(),
1926 result.resize(np,
false);
1927 headerClassName.resize(np);
1932 if (!filePaths[proci].empty())
1934 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1936 result[proci] = result[proci-1];
1937 headerClassName[proci] = headerClassName[proci-1];
1938 note[proci] = note[proci-1];
1942 IFstream is(filePaths[proci]);
1948 headerClassName[proci] =
io.headerClassName();
1949 note[proci] =
io.note();
1962 io.headerClassName() = headerClassName[0];
1963 io.note() = note[0];
1966 for (
const int proci : pBufs.
subProcs())
1968 UOPstream
os(proci, pBufs);
1969 os << result[proci] << headerClassName[proci] << note[proci];
1978 is >> ok >>
io.headerClassName() >>
io.note();
1984 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1985 <<
" class:" <<
io.headerClassName()
1986 <<
" for file:" << fName <<
endl;
1997 const word& typeName,
1998 const bool readOnProc
2003 Pout<<
"masterUncollatedFileOperation::readStream :" 2004 <<
" object : " <<
io.name()
2005 <<
" global : " <<
io.global()
2006 <<
" globalObject : " <<
io.globalObject()
2007 <<
" fName : " << fName <<
" readOnProc:" << readOnProc <<
endl;
2014 bool isCollated =
false;
2034 headerIO.readHeader(*isPtr);
2044 Pout<<
"masterUncollatedFileOperation::readStream :" 2045 <<
" For object : " <<
io.name()
2046 <<
" doing straight IFstream input from " 2051 io.IOobject::operator=(headerIO);
2070 Pout<<
"masterUncollatedFileOperation::readStream :" 2071 <<
" For object : " <<
io.name()
2072 <<
" starting collating input from " << fName <<
endl;
2081 procRangeType
group;
2090 label proci = detectProcessorPath(
io.objectPath());
2095 <<
"Could not detect processor number" 2096 <<
" from objectPath:" <<
io.objectPath()
2097 <<
" fileHandler : comm:" << comm_
2105 proci = proci -
group.start();
2110 Pout<<
"masterUncollatedFileOperation::readStream :" 2111 <<
" For object : " <<
io.name()
2112 <<
" starting input from block " << proci
2113 <<
" of " << isPtr->name() <<
endl;
2122 label readComm = -1;
2130 isPtr.
reset(
new IFstream(fName));
2135 IOobject headerIO(
io);
2136 headerIO.readHeader(*isPtr);
2147 bool bigSize =
false;
2155 > off_t(maxMasterFileBufferSize)
2184 Pout<<
"masterUncollatedFileOperation::readStream :" 2185 <<
" For object : " <<
io.name()
2186 <<
" starting separated input from " << fName <<
endl;
2189 if (
io.global() ||
io.globalObject())
2204 UPstream::listGatherValues<bool>
2231 UPstream::listGatherValues<bool>
2244 return read(
io, comm_, uniform, filePaths, readOnProcs);
2253 const bool masterOnly,
2255 const word& typeName
2260 if (
io.global() ||
io.globalObject())
2264 Pout<<
"masterUncollatedFileOperation::read :" 2265 <<
" Reading global object " <<
io.name()
2267 <<
" Pstream::myProcNo:" 2281 auto& is =
io.readStream(typeName);
2282 ok =
io.readData(is);
2285 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2297 io.headerClassName(),
2309 bool okWrite =
io.writeData(toAll);
2314 IPBstream fromMaster
2320 ok =
io.readData(fromMaster);
2328 Pout<<
"masterUncollatedFileOperation::read :" 2329 <<
" Reading local object " <<
io.name() <<
endl;
2332 ok =
io.readData(
io.readStream(typeName));
2338 Pout<<
"masterUncollatedFileOperation::read :" 2339 <<
" Read object:" <<
io.name()
2340 <<
" isGlobal:" << (
io.global() ||
io.globalObject())
2341 <<
" status:" << ok <<
endl;
2352 const bool writeOnProc
2359 Pout<<
"masterUncollatedFileOperation::writeObject :" 2360 <<
" io:" << pathName <<
" writeOnProc:" << writeOnProc <<
endl;
2377 &&
io.writeHeader(
os)
2393 const word& constantName
2396 const auto iter = times_.cfind(directory);
2401 Pout<<
"masterUncollatedFileOperation::findTimes :" 2402 <<
" Found " << iter.val()->size() <<
" cached times" <<
nl 2403 <<
" for directory:" << directory <<
endl;
2405 return *(iter.val());
2419 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2428 Pout<<
"masterUncollatedFileOperation::findTimes :" 2430 <<
" for directory:" << directory <<
endl;
2436 if (cacheLevel() > 0)
2438 auto* tPtr =
new DynamicList<instant>(std::move(times));
2439 times_.set(directory, tPtr);
2463 auto iter = times_.find(tm.
path());
2467 DynamicList<instant>& times = *(iter.val());
2472 const label startIdx =
2474 (times.empty() || times[0].name() != tm.
constant())
2483 if (times.size() <= startIdx || times.last() < timeNow)
2491 SubList<instant>(times, times.size()-startIdx, startIdx),
2498 Pout<<
"masterUncollatedFileOperation::setTime :" 2499 <<
" Caching time " << tm.
timeName()
2500 <<
" for case:" << tm.
path() <<
endl;
2503 times.append(timeNow);
2505 SubList<instant> realTimes
2507 times, times.size()-startIdx, startIdx
2545 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2546 <<
" Opening global file " << filePath <<
endl;
2562 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2563 <<
" Opening local file " << filePath
2564 <<
" for rank " << proci <<
endl;
2589 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2590 <<
" Reading " << filePath
2599 is.
read(buf.data(), buf.size());
2604 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2605 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2615 isPtr->name() = filePath;
2633 const bool writeOnProc
2656 const bool writeOnProc
2685 Pout<<
"masterUncollatedFileOperation::sync :" 2686 <<
" syncing information across processors" <<
endl;
2697 timeNames.
resize(times_.size());
2698 instants.
resize(times_.size());
2704 timeNames[i] = iter.key();
2705 instants[i] = std::move(*(iter.val()));
2715 fileName dir(timeNames[i]);
2716 auto ptr = autoPtr<DynamicList<instant>>
::New(std::move(instants[i]));
2724 procRangeType
group;
2726 const label proci = splitProcessorPath
2745 if (proci != -1 && proci != myProci)
2751 times_.insert(dir, ptr);
2764 watchFd = monitor().addWatch(fName);
2774 const label watchIndex
2780 ok = monitor().removeWatch(watchIndex);
2800 if (monitor().getFile(watchIndices[i]) == fName)
2836 const label index = findWatch(watchIndices,
f);
2845 newWatchIndices.
push_back(watchIndices[index]);
2846 removedWatches.
erase(index);
2851 for (
const label index : removedWatches)
2853 removeWatch(watchIndices[index]);
2868 const label watchIndex
2874 fName = monitor().getFile(watchIndex);
2884 const bool masterOnly,
2890 monitor().updateStates(
true,
false);
2904 state = monitor().getState(watchFd);
2919 monitor().setUnmodified(watchFd);
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
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?
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static const Enum< pathType > pathTypeNames_
Generic output stream using a standard (STL) stream.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
const Type & value() const noexcept
Return const reference to value.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read (without possible block delimiters). Reading into a null pointer behaves li...
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.
Input/output streams with (internal or external) character storage.
A class for handling file names.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
static label read(const UPstream::commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr)
Read buffer contents from given processor.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
as PROCUNCOLLATED but with instance
masterUncollatedFileOperation(bool verbose=false)
Default construct.
void resize(const label len)
Adjust allocated size of list.
commsTypes
Communications types.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void finishedScatters(const bool wait=true)
Mark all sends to sub-procs as done.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
label nProcs() const noexcept
Overall number of processors, from UPstream::nProcs() or detected from directories/results.
void append(const T &val)
Append an element at the end of the list.
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolUList &readOnProcs)
Read files on comms master.
const word & name() const noexcept
Return the object name.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
fileState
Enumeration defining the file state.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
int infoDetailLevel
Global for selective suppression of Info output.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
constexpr char nl
The newline '\n' character (0x0a)
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
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?
label findSortedIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
Binary search to find the index of the last element in a sorted list that is less than value...
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
void clear() noexcept
Same as reset(nullptr)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (MPI_AllReduce)
file found in time directory
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const
Reads header for regIOobject and returns an ISstream to read the contents.
void stableSort(UList< T > &list)
Stable sort the list.
void setCapacity(const label len)
Alter the size of the underlying storage.
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.
static int & msgType() noexcept
Message tag of standard messages.
label subCycling() const noexcept
Zero (tests as false) if time is not being sub-cycled, otherwise the current sub-cycle index or the t...
A simple container for options an IOstream can normally have.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
List< string > stringList
List of string.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for managing references or pointers (no reference counting)
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
An encapsulation of filesystem-related operations.
fileName objectPath() const
The complete path + object name.
Macros for easy insertion into run-time selection tables.
as PROCOBJECT but with instance
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
UList< label > labelUList
A UList of labels.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
bool read(const char *buf, int32_t &val)
Same as readInt32.
label capacity() const noexcept
Size of the underlying storage.
#define forAll(list, i)
Loop across all elements in list.
constexpr const char *const group
Group name for atomic constants.
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.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Writes a regIOobject (so header, contents and divider).
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
atomicType
Atomic operations (output)
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
instance is absolute directory
"scheduled" : (MPI_Send, MPI_Recv)
bool good() const noexcept
True if the managed pointer is non-null.
objectPath exists in 'processorsNN'
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
A class for handling words, derived from Foam::string.
const Time & time() const noexcept
Return time registry.
Master-only drop-in replacement for OFstream.
objectPath exists in 'processorN'
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
void finishedSends(const bool wait=true)
Mark the send phase as being finished.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static DynamicList< char > slurpFile(IFstream &ifs)
static const word null
An empty word.
addNamedToRunTimeSelectionTable(fileOperationInitialise, fileOperationInitialise_collated, word, collated)
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?
as PROCBASEOBJECT but with instance
objectPath exists in 'processorsNN_first-last'
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
static void readAndSend(const fileName &filePath, const labelUList &recvProcs, PstreamBuffers &pBufs)
Read file contents and send to processors.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
static bool readHeader(IOobject &io, Istream &is)
Read header as per IOobject with additional handling of decomposedBlockData.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
UPstream::rangeType subProcs() const noexcept
Range of sub-processes indices associated with PstreamBuffers.
const labelList & watchIndices() const noexcept
Read access to file-monitoring handles.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
virtual void sync()
Forcibly parallel sync.
static int cacheLevel() noexcept
Return cache level.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
virtual std::istream & stdStream() override
Access to underlying std::istream.
const word & constant() const noexcept
Return constant name.
label recvDataCount(const label proci) const
Number of unconsumed receive bytes for the specified processor. Must call finishedSends() or other fi...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
static fileCheckTypes fileModificationChecking
Type of file modification checking.
compressionType compression() const noexcept
Get the stream compression.
Input from file stream, using an ISstream.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
static Tuple2< label, labelList > getCommPattern()
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void push_back(const T &val)
Copy append an element to the end of this list.
static bool uniformFile(const fileNameList &names)
True if the file names are identical. False on an empty list.
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
const fileName & instance() const noexcept
Read access to instance path component.
virtual ~masterUncollatedFileOperation()
Destructor.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel. ...
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
word format(conversionProperties.get< word >("format"))
std::streamsize fileSize() const
Return the size of the underlying file (-1 on error). This corresponds to Foam::fileSize() but with e...
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
List< word > wordList
List of word.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual void sync()
Forcibly parallel sync.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const dirIndexList &pDirs, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
instantList times() const
Search the case for valid time directories.
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
virtual void setTime(const Time &) const
Callback for time change.
#define WarningInFunction
Report a warning using Foam::Warning.
static List< int > & procID(const label communicator)
The list of ranks within a given communicator.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
const T2 & second() const noexcept
Access the second element.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
An ISstream with internal List storage. Always UNCOMPRESSED.
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
"nonBlocking" : (MPI_Isend, MPI_Irecv)
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
defineTypeNameAndDebug(collatedFileOperation, 0)
List< label > labelList
A List of labels.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
List< instant > instantList
List of instants.
Registry of regIOobjects.
bool equal(scalar val) const noexcept
True if values are equal (includes SMALL for rounding)
const T1 & first() const noexcept
Access the first element.
virtual void setTime(const Time &) const
Callback for time change.
const fileName & local() const noexcept
Read access to local path component.
List< fileName > fileNameList
List of fileName.
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Defines the attributes of an object for which implicit objectRegistry management is supported...
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is.
Type
Enumerations to handle directory entry types.
static label allocateCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Allocate new communicator with contiguous sub-ranks on the parent communicator.
Extract type (as a word) from an object, typically using its type() method.
label comm_
Communicator to use.
forAllConstIters(mixture.phases(), phase)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...