47 namespace fileOperations
53 masterUncollatedFileOperation,
59 masterUncollatedFileOperation,
69 "maxMasterFileBufferSize",
77 fileOperationInitialise,
78 fileOperationInitialise_unthreaded,
91 const bool checkGlobal,
94 const dirIndexList& pDirs,
102 newInstancePath.clear();
104 if (
io.instance().isAbsolute())
131 if (
io.time().processorCase())
133 for (
const dirIndex& dirIdx : pDirs)
135 const fileName& pDir = dirIdx.first();
141 searchType = dirIdx.second().first();
149 fileName localPath =
io.objectPath();
153 localPath != writePath
168 &&
io.time().processorCase()
170 io.instance() ==
io.time().system()
171 ||
io.instance() ==
io.time().constant()
175 fileName parentPath =
177 io.rootPath()/
io.globalCaseName()
178 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name()
190 const auto pathFnd =
times_.cfind(
io.time().path());
192 if (
search && pathFnd.good())
198 instant(
io.instance())
201 if (newInstancePath.size() && newInstancePath !=
io.instance())
204 for (
const dirIndex& dirIdx : pDirs)
206 const fileName& pDir = dirIdx.first();
215 switch (dirIdx.second().first())
245 io.rootPath()/
io.caseName()
246 /newInstancePath/
io.db().dbDir()/
io.local()/
io.name()
267 const pathType& searchType,
269 const word& instancePath
278 return io.instance()/
io.name();
284 return io.path()/
io.name();
290 return objectPath(
io,
io.headerClassName());
320 processorsPath(
io,
io.instance(), procDir)
329 processorsPath(
io,
io.instance(), processorsDir(
io))
337 io.rootPath()/
io.globalCaseName()
338 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
345 io.rootPath()/
io.caseName()
346 /instancePath/
io.db().dbDir()/
io.local()/
io.name();
377 processorsPath(
io, instancePath, procDir)
386 processorsPath(
io, instancePath, processorsDir(
io))
408 const fileName& filePath,
410 PstreamBuffers& pBufs
413 if (recvProcs.empty())
return;
420 <<
"Cannot open file " << filePath
429 Info<<
"masterUncollatedFileOperation::readAndSend :" 431 <<
" (compressed:" << bool(ifs.compression())
432 <<
") : " <<
" bytes" <<
endl;
435 for (
const label proci : recvProcs)
437 UOPstream
os(proci, pBufs);
438 os.write(buf.cdata_bytes(), buf.size_bytes());
463 if (filePaths[0].empty())
466 <<
"Cannot find file " <<
io.objectPath()
467 <<
" fileHandler : comm:" << comm
475 if (readOnProcs[proci])
485 Pout<<
"masterUncollatedFileOperation::readStream :" 486 <<
" For uniform file " << filePaths[0]
487 <<
" sending to " << recvProcs
488 <<
" in comm:" << comm <<
endl;
490 readAndSend(filePaths[0], recvProcs, pBufs);
497 if (filePaths[0].empty())
500 <<
"Cannot find file " <<
io.objectPath()
501 <<
" fileHandler : comm:" << comm
507 isPtr.
reset(
new IFstream(filePaths[0]));
510 if (!
io.readHeader(*isPtr))
513 <<
"problem while reading header for object " 515 <<
" fileHandler : comm:" << comm
526 Pout<<
"masterUncollatedFileOperation::readStream :" 527 <<
" For processor " << proci
528 <<
" opening " << filePaths[proci] <<
endl;
531 const fileName& fPath = filePaths[proci];
533 if (readOnProcs[proci] && !fPath.empty())
537 readAndSend(fPath,
labelList(one{}, proci), pBufs);
559 is.read(buf.data(), buf.size());
564 Pout<<
"masterUncollatedFileOperation::readStream :" 565 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
572 isPtr.
reset(
new ICharStream(std::move(buf)));
577 if (!
io.readHeader(*isPtr))
580 <<
"problem while reading header for object " 582 <<
" fileHandler : comm:" << comm
589 isPtr.
reset(
new dummyISstream());
622 return commAndIORanks;
630 void Foam::fileOperations::masterUncollatedFileOperation::init(
bool verbose)
637 <<
"I/O : " << typeName
638 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')' 647 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
656 <<
"Resetting fileModificationChecking to inotify" 674 managedComm_(getManagedComm(comm_))
701 const bool distributedRoots,
732 managedComm_ = getManagedComm(comm_);
753 return masterOp<bool>
769 return masterOp<bool>
782 const bool followLink
785 return masterOp<mode_t>
798 const bool followLink
817 const bool checkGzip,
818 const bool followLink
821 return masterOp<bool>
824 existsOp(checkGzip, followLink),
834 const bool followLink
837 return masterOp<bool>
850 const bool checkGzip,
851 const bool followLink
854 return masterOp<bool>
857 isFileOp(checkGzip, followLink),
867 const bool followLink
870 return masterOp<off_t>
873 fileSizeOp(followLink),
883 const bool followLink
886 return masterOp<time_t>
889 lastModifiedOp(followLink),
899 const bool followLink
902 return masterOp<double>
905 highResLastModifiedOp(followLink),
915 const std::string& ext
918 return masterOp<bool>
933 return masterOp<bool>
950 return masterOp<bool>
953 rmDirOp(silent, emptyOnly),
965 const bool followLink
968 return masterOp<fileNameList>
971 readDirOp(
type, filtergz, followLink),
982 const bool followLink
985 return masterOp<bool>
1002 return masterOp<bool>
1017 const bool followLink
1020 return masterOp<bool>
1035 const bool checkGlobal,
1037 const word& typeName,
1043 Pout<<
"masterUncollatedFileOperation::filePath :" 1044 <<
" objectPath:" <<
io.objectPath()
1045 <<
" checkGlobal:" << checkGlobal
1055 if (cacheLevel() > 0)
1057 (void)findTimes(
io.time().path(),
io.time().constant());
1063 pathType searchType = NOTFOUND;
1065 word newInstancePath;
1088 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1094 Pout<<
"masterUncollatedFileOperation::filePath :" 1095 <<
" master objPath:" << objPath
1097 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1108 int masterType(searchType);
1110 searchType = pathType(masterType);
1119 ||
io.local() ==
"uniform" 1151 objPath = localObjectPath
1167 objPath = masterOp<fileName>
1181 Pout<<
"masterUncollatedFileOperation::filePath :" 1182 <<
" Returning from file searching using type " 1184 <<
" objectPath:" <<
io.objectPath() <<
endl 1193 const bool checkGlobal,
1200 Pout<<
"masterUncollatedFileOperation::dirPath :" 1201 <<
" objectPath:" <<
io.objectPath()
1202 <<
" checkGlobal:" << checkGlobal
1209 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1212 if (cacheLevel() > 0)
1214 (void)findTimes(
io.time().path(),
io.time().constant());
1220 pathType searchType = NOTFOUND;
1222 word newInstancePath;
1231 objPath = filePathInfo
1243 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1249 Pout<<
"masterUncollatedFileOperation::dirPath :" 1250 <<
" master objPath:" << objPath
1252 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1264 int masterType(searchType);
1266 searchType = pathType(masterType);
1276 ||
io.local() ==
"uniform" 1309 objPath = localObjectPath
1325 objPath = masterOp<fileName>
1328 fileOrNullOp(
false),
1339 Pout<<
"masterUncollatedFileOperation::dirPath :" 1340 <<
" Returning from directory searching using type " 1342 <<
" objectPath:" <<
io.objectPath() <<
endl 1351 const dirIndexList& pDirs,
1358 const bool isFile = !
io.name().empty();
1364 if (isFileOrDir(
isFile, writePath))
1370 if (
io.time().processorCase())
1372 for (
const dirIndex& dirIdx : pDirs)
1374 const fileName& pDir = dirIdx.first();
1376 processorsPath(
io,
io.instance(), pDir)
1378 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1386 fileName localPath =
io.objectPath();
1388 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1401 const scalar startValue,
1402 const word& stopInstance,
1403 const bool constant_fallback
1408 Pout<<
"masterUncollatedFileOperation::findInstance :" 1409 <<
" Starting searching for name:" << startIO.
name()
1410 <<
" local:" << startIO.
local()
1411 <<
" from instance:" << startIO.
instance()
1438 foundInstance =
io.instance();
1440 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1449 if (!foundInstance.empty())
1451 io.instance() = foundInstance;
1454 Pout<<
"masterUncollatedFileOperation::findInstance :" 1455 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1456 <<
" found starting instance:" <<
io.instance() <<
endl;
1465 enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 };
1477 label instIndex = ts.size()-1;
1480 for (; instIndex >= 0; --instIndex)
1482 if (ts[instIndex].value() <= startValue)
1489 for (; instIndex >= 0; --instIndex)
1498 io.instance() = ts[instIndex].name();
1501 foundInstance =
io.instance();
1504 Pout<<
"masterUncollatedFileOperation::findInstance :" 1505 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1506 <<
" found at:" <<
io.instance()
1513 if (
io.instance() == stopInstance)
1517 Pout<<
"masterUncollatedFileOperation::findInstance :" 1518 <<
" name:" <<
io.name()
1519 <<
" local:" <<
io.local()
1520 <<
" at stop-instance:" <<
io.instance() <<
endl;
1525 failed = failureCodes::FAILED_STOPINST;
1530 foundInstance =
io.instance();
1551 !failed && foundInstance.empty()
1552 && (ts.empty() || ts[0].name() != time.
constant() || startValue < 0)
1566 Pout<<
"masterUncollatedFileOperation::findInstance :" 1567 <<
" name:" <<
io.name()
1568 <<
" local:" <<
io.local()
1569 <<
" at:" <<
io.instance() <<
endl;
1571 foundInstance =
io.instance();
1575 if (!failed && foundInstance.empty())
1579 failed = failureCodes::FAILED_CONSTINST;
1581 else if (constant_fallback)
1587 foundInstance.clear();
1591 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1598 io.instance() = foundInstance;
1607 if (!
io.name().empty())
1610 <<
" file \"" <<
io.name() <<
"\" in";
1615 <<
io.local() <<
" in times " 1616 << startIO.
instance() <<
" down to ";
1618 if (failed == failureCodes::FAILED_STOPINST)
1631 Pout<<
"masterUncollatedFileOperation::findInstance :" 1632 <<
" name:" <<
io.name() <<
" local:" <<
io.local()
1633 <<
" returning instance:" <<
io.instance() <<
endl;
1650 Pout<<
"masterUncollatedFileOperation::readObjects :" 1652 <<
" local:" <<
local <<
" instance:" << instance <<
endl;
1656 newInstance.clear();
1678 if (newInstance.empty())
1698 if (!foundInst.empty())
1710 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1719 Pout<<
"masterUncollatedFileOperation::readObjects :" 1720 <<
" newInstance:" << newInstance
1721 <<
" objectNames:" << objectNames <<
endl;
1732 const word& typeName
1739 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl 1740 <<
" objectPath:" <<
io.objectPath() <<
endl 1741 <<
" filePath :" << fName <<
endl;
1782 io.headerClassName(),
1806 result.resize(np,
false);
1807 headerClassName.resize(np);
1812 if (!filePaths[proci].empty())
1814 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1816 result[proci] = result[proci-1];
1817 headerClassName[proci] = headerClassName[proci-1];
1818 note[proci] = note[proci-1];
1822 IFstream is(filePaths[proci]);
1828 headerClassName[proci] =
io.headerClassName();
1829 note[proci] =
io.note();
1837 PstreamBuffers pBufs(comm_);
1842 io.headerClassName() = headerClassName[0];
1843 io.note() = note[0];
1846 for (
const int proci : pBufs.
subProcs())
1848 UOPstream
os(proci, pBufs);
1849 os << result[proci] << headerClassName[proci] << note[proci];
1858 is >> ok >>
io.headerClassName() >>
io.note();
1864 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1865 <<
" class:" <<
io.headerClassName()
1866 <<
" for file:" << fName <<
endl;
1877 const word& typeName,
1878 const bool readOnProc
1883 Pout<<
"masterUncollatedFileOperation::readStream :" 1884 <<
" object : " <<
io.name()
1885 <<
" global : " <<
io.global()
1886 <<
" globalObject : " <<
io.globalObject()
1887 <<
" fName : " << fName <<
" readOnProc:" << readOnProc <<
endl;
1894 bool isCollated =
false;
1914 headerIO.readHeader(*isPtr);
1924 Pout<<
"masterUncollatedFileOperation::readStream :" 1925 <<
" For object : " <<
io.name()
1926 <<
" doing straight IFstream input from " 1931 io.IOobject::operator=(headerIO);
1950 Pout<<
"masterUncollatedFileOperation::readStream :" 1951 <<
" For object : " <<
io.name()
1952 <<
" starting collating input from " << fName <<
endl;
1961 procRangeType
group;
1970 label proci = detectProcessorPath(
io.objectPath());
1975 <<
"Could not detect processor number" 1976 <<
" from objectPath:" <<
io.objectPath()
1977 <<
" fileHandler : comm:" << comm_
1985 proci = proci -
group.start();
1990 Pout<<
"masterUncollatedFileOperation::readStream :" 1991 <<
" For object : " <<
io.name()
1992 <<
" starting input from block " << proci
1993 <<
" of " << isPtr->name() <<
endl;
2002 label readComm = -1;
2010 isPtr.
reset(
new IFstream(fName));
2015 IOobject headerIO(
io);
2016 headerIO.readHeader(*isPtr);
2027 bool bigSize =
false;
2035 > off_t(maxMasterFileBufferSize)
2064 Pout<<
"masterUncollatedFileOperation::readStream :" 2065 <<
" For object : " <<
io.name()
2066 <<
" starting separated input from " << fName <<
endl;
2069 if (
io.global() ||
io.globalObject())
2084 UPstream::listGatherValues<bool>
2111 UPstream::listGatherValues<bool>
2124 return read(
io, comm_, uniform, filePaths, readOnProcs);
2133 const bool masterOnly,
2135 const word& typeName
2140 if (
io.global() ||
io.globalObject())
2144 Pout<<
"masterUncollatedFileOperation::read :" 2145 <<
" Reading global object " <<
io.name()
2147 <<
" Pstream::myProcNo:" 2160 auto& is =
io.readStream(typeName);
2161 ok =
io.readData(is);
2164 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2176 os <<
io.headerClassName() <<
io.note();
2177 bool okWrite =
io.writeData(
os);
2184 is >>
io.headerClassName() >>
io.note();
2185 ok =
io.readData(is);
2193 Pout<<
"masterUncollatedFileOperation::read :" 2194 <<
" Reading local object " <<
io.name() <<
endl;
2197 ok =
io.readData(
io.readStream(typeName));
2203 Pout<<
"masterUncollatedFileOperation::read :" 2204 <<
" Read object:" <<
io.name()
2205 <<
" isGlobal:" << (
io.global() ||
io.globalObject())
2206 <<
" status:" << ok <<
endl;
2217 const bool writeOnProc
2224 Pout<<
"masterUncollatedFileOperation::writeObject :" 2225 <<
" io:" << pathName <<
" writeOnProc:" << writeOnProc <<
endl;
2242 &&
io.writeHeader(
os)
2258 const word& constantName
2261 const auto iter = times_.cfind(directory);
2266 Pout<<
"masterUncollatedFileOperation::findTimes :" 2267 <<
" Found " << iter.val()->size() <<
" cached times" <<
nl 2268 <<
" for directory:" << directory <<
endl;
2270 return *(iter.val());
2284 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2293 Pout<<
"masterUncollatedFileOperation::findTimes :" 2295 <<
" for directory:" << directory <<
endl;
2301 if (cacheLevel() > 0)
2303 auto* tPtr =
new DynamicList<instant>(std::move(times));
2304 times_.set(directory, tPtr);
2328 auto iter = times_.find(tm.
path());
2332 DynamicList<instant>& times = *(iter.val());
2337 const label startIdx =
2339 (times.empty() || times[0].name() != tm.
constant())
2348 if (times.size() <= startIdx || times.last() < timeNow)
2356 SubList<instant>(times, times.size()-startIdx, startIdx),
2363 Pout<<
"masterUncollatedFileOperation::setTime :" 2364 <<
" Caching time " << tm.
timeName()
2365 <<
" for case:" << tm.
path() <<
endl;
2368 times.append(timeNow);
2370 SubList<instant> realTimes
2372 times, times.size()-startIdx, startIdx
2410 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2411 <<
" Opening global file " << filePath <<
endl;
2427 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2428 <<
" Opening local file " << filePath
2429 <<
" for rank " << proci <<
endl;
2454 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2455 <<
" Reading " << filePath
2464 is.
read(buf.data(), buf.size());
2469 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2470 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2480 isPtr->name() = filePath;
2498 const bool writeOnProc
2521 const bool writeOnProc
2550 Pout<<
"masterUncollatedFileOperation::sync :" 2551 <<
" syncing information across processors" <<
endl;
2562 timeNames.
resize(times_.size());
2563 instants.
resize(times_.size());
2569 timeNames[i] = iter.key();
2570 instants[i] = std::move(*(iter.val()));
2580 fileName dir(timeNames[i]);
2581 auto ptr = autoPtr<DynamicList<instant>>
::New(std::move(instants[i]));
2589 procRangeType
group;
2591 const label proci = splitProcessorPath
2610 if (proci != -1 && proci != myProci)
2616 times_.insert(dir, ptr);
2629 watchFd = monitor().addWatch(fName);
2639 const label watchIndex
2645 ok = monitor().removeWatch(watchIndex);
2665 if (monitor().getFile(watchIndices[i]) == fName)
2701 const label index = findWatch(watchIndices,
f);
2710 newWatchIndices.
push_back(watchIndices[index]);
2711 removedWatches.
erase(index);
2716 for (
const label index : removedWatches)
2718 removeWatch(watchIndices[index]);
2733 const label watchIndex
2739 fName = monitor().getFile(watchIndex);
2749 const bool masterOnly,
2755 monitor().updateStates(
true,
false);
2769 state = monitor().getState(watchFd);
2784 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.
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 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.
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
HashPtrTable< DynamicList< instant > > times_
Cached times for a given directory.
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.
fileName processorsPath(const IOobject &io, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
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.
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)
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 void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
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.
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.
#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).
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
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. ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
instance is absolute directory
"scheduled" (MPI standard) : (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.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance, const bool constant_fallback=true) const
Find time instance where IOobject is located. The name of the IOobject can be empty, in which case only the IOobject::local() is checked. Does not search beyond stopInstance (if set) or constant.
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 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 word findInstancePath(const UList< instant > &timeDirs, const instant &t)
Search instantList for matching time value, return the instance name or word::null if nothing is equa...
no append (truncates existing)
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.
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.
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
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.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
word format(conversionProperties.get< word >("format"))
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.
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.
static DynamicList< char > readContents(const fileName &pathname)
Get file contents from specified file (compressed/uncompressed). Returns an empty list if the file ca...
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" (immediate) : (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.
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.
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.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
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)
static std::streamsize 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.
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 ...