47 namespace fileOperations
69 "maxMasterFileBufferSize",
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)
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])
477 recvProcs.push_back(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);
543 pBufs.finishedScatters();
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>
834 const bool followLink
837 return masterOp<bool>
850 const bool checkGzip,
851 const bool followLink
854 return masterOp<bool>
867 const bool followLink
878 fileSizeOp(followLink),
889 const bool followLink
895 if constexpr (std::is_integral_v<time_t>)
904 lastModifiedOp(followLink),
912 return masterOp<time_t>
915 lastModifiedOp(followLink),
926 const bool followLink
929 return masterOp<double>
942 const std::string& ext
945 return masterOp<bool>
960 return masterOp<bool>
977 return masterOp<bool>
992 const bool followLink
995 return masterOp<fileNameList>
1009 const bool followLink
1012 return masterOp<bool>
1029 return masterOp<bool>
1044 const bool followLink
1047 return masterOp<bool>
1062 const bool checkGlobal,
1064 const word& typeName,
1070 Pout<<
"masterUncollatedFileOperation::filePath :"
1071 <<
" objectPath:" <<
io.objectPath()
1072 <<
" checkGlobal:" << checkGlobal
1082 if (cacheLevel() > 0)
1084 (void)findTimes(
io.time().path(),
io.time().constant());
1090 pathType searchType = NOTFOUND;
1092 word newInstancePath;
1115 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1121 Pout<<
"masterUncollatedFileOperation::filePath :"
1122 <<
" master objPath:" << objPath
1124 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1135 int masterType(searchType);
1137 searchType = pathType(masterType);
1146 ||
io.local() ==
"uniform"
1178 objPath = localObjectPath
1194 objPath = masterOp<fileName>
1208 Pout<<
"masterUncollatedFileOperation::filePath :"
1209 <<
" Returning from file searching using type "
1212 <<
" filePath :" << objPath <<
endl <<
endl;
1220 const bool checkGlobal,
1227 Pout<<
"masterUncollatedFileOperation::dirPath :"
1228 <<
" objectPath:" <<
io.objectPath()
1229 <<
" checkGlobal:" << checkGlobal
1236 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1239 if (cacheLevel() > 0)
1241 (void)findTimes(
io.time().path(),
io.time().constant());
1247 pathType searchType = NOTFOUND;
1249 word newInstancePath;
1258 objPath = filePathInfo
1270 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1276 Pout<<
"masterUncollatedFileOperation::dirPath :"
1277 <<
" master objPath:" << objPath
1279 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1291 int masterType(searchType);
1293 searchType = pathType(masterType);
1303 ||
io.local() ==
"uniform"
1336 objPath = localObjectPath
1352 objPath = masterOp<fileName>
1355 fileOrNullOp(
false),
1366 Pout<<
"masterUncollatedFileOperation::dirPath :"
1367 <<
" Returning from directory searching using type "
1370 <<
" filePath :" << objPath <<
endl <<
endl;
1378 const dirIndexList& pDirs,
1385 const bool isFile = !
io.name().empty();
1391 if (isFileOrDir(
isFile, writePath))
1397 if (
io.time().processorCase())
1399 for (
const dirIndex& dirIdx : pDirs)
1401 const fileName& pDir = dirIdx.first();
1403 processorsPath(
io,
io.instance(), pDir)
1405 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1413 fileName localPath =
io.objectPath();
1415 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1428 const scalar startValue,
1429 const word& stopInstance,
1430 const bool constant_fallback
1435 Pout<<
"masterUncollatedFileOperation::findInstance :"
1436 <<
" Starting searching for name:" << startIO.
name()
1437 <<
" local:" << startIO.
local()
1438 <<
" from instance:" << startIO.
instance()
1442 const Time& time = startIO.
time();
1443 IOobject
io(startIO);
1452 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1465 foundInstance =
io.instance();
1467 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1476 if (!foundInstance.empty())
1478 io.instance() = foundInstance;
1481 Pout<<
"masterUncollatedFileOperation::findInstance :"
1482 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1483 <<
" found starting instance:" <<
io.instance() <<
endl;
1492 enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 };
1504 label instIndex = ts.size()-1;
1507 for (; instIndex >= 0; --instIndex)
1509 if (ts[instIndex].value() <= startValue)
1516 for (; instIndex >= 0; --instIndex)
1520 if (ts[instIndex].
name() == time.timeName())
1525 io.instance() = ts[instIndex].name();
1528 foundInstance =
io.instance();
1531 Pout<<
"masterUncollatedFileOperation::findInstance :"
1532 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1533 <<
" found at:" <<
io.instance()
1540 if (
io.instance() == stopInstance)
1544 Pout<<
"masterUncollatedFileOperation::findInstance :"
1545 <<
" name:" <<
io.name()
1546 <<
" local:" <<
io.local()
1547 <<
" at stop-instance:" <<
io.instance() <<
endl;
1552 failed = failureCodes::FAILED_STOPINST;
1557 foundInstance =
io.instance();
1578 !failed && foundInstance.empty()
1579 && (ts.empty() || ts[0].name() != time.constant() || startValue < 0)
1587 io.instance() = time.constant();
1593 Pout<<
"masterUncollatedFileOperation::findInstance :"
1594 <<
" name:" <<
io.name()
1595 <<
" local:" <<
io.local()
1596 <<
" at:" <<
io.instance() <<
endl;
1598 foundInstance =
io.instance();
1602 if (!failed && foundInstance.empty())
1606 failed = failureCodes::FAILED_CONSTINST;
1608 else if (constant_fallback)
1610 foundInstance = time.constant();
1614 foundInstance.clear();
1618 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1625 io.instance() = foundInstance;
1634 if (!
io.name().empty())
1637 <<
" file \"" <<
io.name() <<
"\" in";
1642 <<
io.local() <<
" in times "
1643 << startIO.
instance() <<
" down to ";
1645 if (failed == failureCodes::FAILED_STOPINST)
1658 Pout<<
"masterUncollatedFileOperation::findInstance :"
1659 <<
" name:" <<
io.name() <<
" local:" <<
io.local()
1660 <<
" returning instance:" <<
io.instance() <<
endl;
1677 Pout<<
"masterUncollatedFileOperation::readObjects :"
1679 <<
" local:" << local <<
" instance:" << instance <<
endl;
1683 newInstance.clear();
1705 if (newInstance.empty())
1725 if (!foundInst.empty())
1737 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1746 Pout<<
"masterUncollatedFileOperation::readObjects :"
1747 <<
" newInstance:" << newInstance
1748 <<
" objectNames:" << objectNames <<
endl;
1759 const word& typeName
1766 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl
1767 <<
" objectPath:" <<
io.objectPath() <<
endl
1768 <<
" filePath :" << fName <<
endl;
1809 io.headerClassName(),
1833 result.resize(np,
false);
1834 headerClassName.resize(np);
1839 if (!filePaths[proci].empty())
1841 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1843 result[proci] = result[proci-1];
1844 headerClassName[proci] = headerClassName[proci-1];
1845 note[proci] = note[proci-1];
1849 IFstream is(filePaths[proci]);
1855 headerClassName[proci] =
io.headerClassName();
1856 note[proci] =
io.note();
1864 PstreamBuffers pBufs(comm_);
1869 io.headerClassName() = headerClassName[0];
1870 io.note() = note[0];
1873 for (
const int proci : pBufs.subProcs())
1875 UOPstream
os(proci, pBufs);
1876 os << result[proci] << headerClassName[proci] << note[proci];
1880 pBufs.finishedScatters();
1885 is >> ok >>
io.headerClassName() >>
io.note();
1891 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1892 <<
" class:" <<
io.headerClassName()
1893 <<
" for file:" << fName <<
endl;
1904 const word& typeName,
1905 const bool readOnProc
1910 Pout<<
"masterUncollatedFileOperation::readStream :"
1911 <<
" object : " <<
io.name()
1912 <<
" global : " <<
io.global()
1913 <<
" globalObject : " <<
io.globalObject()
1914 <<
" fName : " << fName <<
" readOnProc:" << readOnProc <<
endl;
1921 bool isCollated =
false;
1941 headerIO.readHeader(*isPtr);
1951 Pout<<
"masterUncollatedFileOperation::readStream :"
1952 <<
" For object : " <<
io.name()
1953 <<
" doing straight IFstream input from "
1958 io.IOobject::operator=(headerIO);
1977 Pout<<
"masterUncollatedFileOperation::readStream :"
1978 <<
" For object : " <<
io.name()
1979 <<
" starting collating input from " << fName <<
endl;
1987 fileName
path, procDir, local;
1988 procRangeType
group;
1990 splitProcessorPath(fName,
path, procDir, local,
group, nProcs);
1997 label proci = detectProcessorPath(
io.objectPath());
2002 <<
"Could not detect processor number"
2003 <<
" from objectPath:" <<
io.objectPath()
2004 <<
" fileHandler : comm:" << comm_
2012 proci = proci -
group.start();
2017 Pout<<
"masterUncollatedFileOperation::readStream :"
2018 <<
" For object : " <<
io.name()
2019 <<
" starting input from block " << proci
2020 <<
" of " << isPtr->name() <<
endl;
2029 label readComm = -1;
2037 isPtr.
reset(
new IFstream(fName));
2042 IOobject headerIO(
io);
2043 headerIO.readHeader(*isPtr);
2054 bool bigSize =
false;
2062 > off_t(maxMasterFileBufferSize)
2091 Pout<<
"masterUncollatedFileOperation::readStream :"
2092 <<
" For object : " <<
io.name()
2093 <<
" starting separated input from " << fName <<
endl;
2096 if (
io.global() ||
io.globalObject())
2111 UPstream::listGatherValues<bool>
2138 UPstream::listGatherValues<bool>
2151 return read(
io, comm_, uniform, filePaths, readOnProcs);
2160 const bool masterOnly,
2162 const word& typeName
2167 if (
io.global() ||
io.globalObject())
2171 Pout<<
"masterUncollatedFileOperation::read :"
2172 <<
" Reading global object " <<
io.name()
2174 <<
" Pstream::myProcNo:"
2187 auto& is =
io.readStream(typeName);
2188 ok =
io.readData(is);
2191 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2203 os <<
io.headerClassName() <<
io.note();
2204 bool okWrite =
io.writeData(
os);
2211 is >>
io.headerClassName() >>
io.note();
2212 ok =
io.readData(is);
2220 Pout<<
"masterUncollatedFileOperation::read :"
2221 <<
" Reading local object " <<
io.name() <<
endl;
2224 ok =
io.readData(
io.readStream(typeName));
2230 Pout<<
"masterUncollatedFileOperation::read :"
2231 <<
" Read object:" <<
io.name()
2232 <<
" isGlobal:" << (
io.global() ||
io.globalObject())
2233 <<
" status:" << ok <<
endl;
2244 const bool writeOnProc
2251 Pout<<
"masterUncollatedFileOperation::writeObject :"
2252 <<
" io:" << pathName <<
" writeOnProc:" << writeOnProc <<
endl;
2269 &&
io.writeHeader(
os)
2285 const word& constantName
2288 const auto iter = times_.cfind(directory);
2293 Pout<<
"masterUncollatedFileOperation::findTimes :"
2294 <<
" Found " << iter.val()->size() <<
" cached times" <<
nl
2295 <<
" for directory:" << directory <<
endl;
2297 return *(iter.val());
2311 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2320 Pout<<
"masterUncollatedFileOperation::findTimes :"
2322 <<
" for directory:" << directory <<
endl;
2328 if (cacheLevel() > 0)
2330 auto* tPtr =
new DynamicList<instant>(std::move(times));
2331 times_.set(directory, tPtr);
2355 auto iter = times_.find(tm.
path());
2359 DynamicList<instant>& times = *(iter.val());
2364 const label startIdx =
2366 (times.empty() || times[0].name() != tm.
constant())
2375 if (times.size() <= startIdx || times.last() < timeNow)
2377 times.append(timeNow);
2383 SubList<instant>(times, times.size()-startIdx, startIdx),
2390 Pout<<
"masterUncollatedFileOperation::setTime :"
2391 <<
" Caching time " << tm.
timeName()
2392 <<
" for case:" << tm.
path() <<
endl;
2395 times.append(timeNow);
2397 SubList<instant> realTimes
2399 times, times.size()-startIdx, startIdx
2437 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2438 <<
" Opening global file " << filePath <<
endl;
2454 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2455 <<
" Opening local file " << filePath
2456 <<
" for rank " << proci <<
endl;
2470 pBufs.finishedSends();
2481 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2482 <<
" Reading " << filePath
2491 is.read(buf.data(), buf.size());
2496 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2497 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2504 isPtr.
reset(
new ICharStream(std::move(buf)));
2507 isPtr->name() = filePath;
2513 isPtr.
reset(
new IFstream(filePath));
2525 const bool writeOnProc
2548 const bool writeOnProc
2577 Pout<<
"masterUncollatedFileOperation::sync :"
2578 <<
" syncing information across processors" <<
endl;
2589 timeNames.
resize(times_.size());
2590 instants.
resize(times_.size());
2596 timeNames[i] = iter.key();
2597 instants[i] = std::move(*(iter.val()));
2607 fileName dir(timeNames[i]);
2608 auto ptr = autoPtr<DynamicList<instant>>
::New(std::move(instants[i]));
2616 procRangeType
group;
2618 const label proci = splitProcessorPath
2637 if (proci != -1 && proci != myProci)
2643 times_.insert(dir, ptr);
2656 watchFd = monitor().addWatch(fName);
2666 const label watchIndex
2672 ok = monitor().removeWatch(watchIndex);
2692 if (monitor().getFile(watchIndices[i]) == fName)
2728 const label index = findWatch(watchIndices,
f);
2737 newWatchIndices.
push_back(watchIndices[index]);
2738 removedWatches.erase(index);
2743 for (
const label index : removedWatches)
2745 removeWatch(watchIndices[index]);
2748 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2760 const label watchIndex
2766 fName = monitor().getFile(watchIndex);
2776 const bool masterOnly,
2782 monitor().updateStates(
true,
false);
2796 state = monitor().getState(watchFd);
2811 monitor().setUnmodified(watchFd);
Input/output streams with (internal or external) character storage.
Macros for easy insertion into run-time selection tables.
void push_back(const T &val)
Copy append an element to the end of this list.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
static DynamicList< char > readContents(const fileName &pathname)
Get file contents from specified file (compressed/uncompressed). Returns an empty list if the file ca...
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
const word & name() const noexcept
Return the object name.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
const fileName & local() const noexcept
Read access to local path component.
const fileName & instance() const noexcept
Read access to instance path component.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
fileName objectPath() const
The complete path + object name.
A simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
atomicType
Atomic operations (output)
@ NO_APPEND
no append (truncates existing)
void resize(const label len)
Adjust allocated size of list.
Generic output stream using a standard (STL) stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static void gatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate.
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel.
const word & constant() const noexcept
Return constant name.
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...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
label subCycling() const noexcept
Zero (tests as false) if time is not being sub-cycled, otherwise the current sub-cycle index or the t...
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.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
const T2 & second() const noexcept
Access the second element.
const T1 & first() const noexcept
Access the first element.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
commsTypes
Communications types.
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool & parRun() noexcept
Test if this a parallel run.
static void reduceOr(bool &value, const int communicator=worldComm)
Logical (or) reduction (MPI_AllReduce)
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static List< int > & procID(int communicator)
The list of ranks within a given communicator.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
static int & msgType() noexcept
Message tag of standard messages.
static label newCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Create new communicator with sub-ranks on the parent communicator.
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
void clear() noexcept
Same as reset(nullptr)
bool good() const noexcept
True if the managed pointer is non-null.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
static bool readHeader(IOobject &io, Istream &is)
Read header as per IOobject with additional handling of decomposedBlockData.
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.
const Type & value() const noexcept
Return const reference to value.
fileState
Enumeration defining the file state.
A class for handling file names.
Type
Enumerations to handle directory entry types.
An encapsulation of filesystem-related operations.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
label nProcs() const noexcept
Overall number of processors, from UPstream::nProcs() or detected from directories/results.
fileName processorsPath(const IOobject &io, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
virtual void setTime(const Time &) const
Callback for time change.
@ PROCUNCOLLATEDINSTANCE
as PROCUNCOLLATED but with instance
@ WRITEOBJECT
write path exists
@ OBJECT
io.objectPath() exists
@ PROCINSTANCE
as PROCOBJECT but with instance
@ FINDINSTANCE
file found in time directory
@ PROCUNCOLLATED
objectPath exists in 'processorN'
@ ABSOLUTE
instance is absolute directory
@ PROCBASEINSTANCE
as PROCBASEOBJECT but with instance
@ PARENTOBJECT
parent of object path
@ PROCOBJECT
objectPath exists in 'processorsNN_first-last'
@ PROCBASEOBJECT
objectPath exists in 'processorsNN'
label comm_
Communicator to use.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
static bool uniformFile(const fileNameList &names)
True if the file names are identical. False on an empty list.
static int cacheLevel() noexcept
Return cache level.
static const Enum< pathType > pathTypeNames_
virtual void sync()
Forcibly parallel sync.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
A fileOperation initialiser for unthreaded file handlers.
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
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.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
static void readAndSend(const fileName &filePath, const labelUList &recvProcs, PstreamBuffers &pBufs)
Read file contents and send to processors.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
virtual void setTime(const Time &) const
Callback for time change.
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.
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.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
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.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
masterUncollatedFileOperation(bool verbose=false)
Default construct.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
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 bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
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.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
HashPtrTable< DynamicList< instant > > times_
Cached times for a given directory.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual void sync()
Forcibly parallel sync.
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,...
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Writes a regIOobject (so header, contents and divider).
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolUList &readOnProcs)
Read files on comms master.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual ~masterUncollatedFileOperation()
Destructor.
Master-only drop-in replacement for OFstream.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
A class for managing references or pointers (no reference counting)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const labelList & watchIndices() const noexcept
Read access to file-monitoring handles.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
#define WarningInFunction
Report a warning using Foam::Warning.
forAllConstIters(mixture.phases(), phase)
constexpr const char *const group
Group name for atomic constants.
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
int debug
Static debugging option.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
defineTypeNameAndDebug(collatedFileOperation, 0)
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
addNamedToRunTimeSelectionTable(fileOperationInitialise, fileOperationInitialise_collated, word, collated)
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
List of word.
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 Tuple2< label, labelList > getCommPattern()
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?
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
List< fileName > fileNameList
List of fileName.
messageStream Info
Information stream (stdout output on master, null elsewhere)
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
List< instant > instantList
List of instants.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
List< string > stringList
List of string.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
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.
List< bool > boolList
A List of bools.
int infoDetailLevel
Global for selective suppression of Info output.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
UList< label > labelUList
A UList of labels.
bool read(const char *buf, int32_t &val)
Same as readInt32.
void stableSort(UList< T > &list)
Stable sort the list.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
constexpr char nl
The newline '\n' character (0x0a)
word format(conversionProperties.get< word >("format"))
#define forAll(list, i)
Loop across all elements in list.
Extract type (as a word) from an object, typically using its type() method.