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()
193 const auto* instPtr =
times_.get(
io.time().path());
201 instant(
io.instance())
204 if (newInstancePath.size() && newInstancePath !=
io.instance())
207 for (
const dirIndex& dirIdx : pDirs)
209 const fileName& pDir = dirIdx.first();
218 switch (dirIdx.second().first())
248 io.rootPath()/
io.caseName()
249 /newInstancePath/
io.db().dbDir()/
io.local()/
io.name()
270 const pathType& searchType,
272 const word& instancePath
281 return io.instance()/
io.name();
287 return io.path()/
io.name();
293 return objectPath(
io,
io.headerClassName());
323 processorsPath(
io,
io.instance(), procDir)
332 processorsPath(
io,
io.instance(), processorsDir(
io))
340 io.rootPath()/
io.globalCaseName()
341 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
348 io.rootPath()/
io.caseName()
349 /instancePath/
io.db().dbDir()/
io.local()/
io.name();
380 processorsPath(
io, instancePath, procDir)
389 processorsPath(
io, instancePath, processorsDir(
io))
411 const fileName& filePath,
413 PstreamBuffers& pBufs
416 if (recvProcs.empty())
return;
423 <<
"Cannot open file " << filePath
432 Info<<
"masterUncollatedFileOperation::readAndSend :"
434 <<
" (compressed:" << bool(ifs.compression())
435 <<
") : " <<
" bytes" <<
endl;
438 for (
const label proci : recvProcs)
441 os.write(buf.cdata_bytes(), buf.size_bytes());
466 if (filePaths[0].empty())
469 <<
"Cannot find file " <<
io.objectPath()
470 <<
" fileHandler : comm:" << comm
478 if (readOnProcs[proci])
480 recvProcs.push_back(proci);
488 Pout<<
"masterUncollatedFileOperation::readStream :"
489 <<
" For uniform file " << filePaths[0]
490 <<
" sending to " << recvProcs
491 <<
" in comm:" << comm <<
endl;
493 readAndSend(filePaths[0], recvProcs, pBufs);
500 if (filePaths[0].empty())
503 <<
"Cannot find file " <<
io.objectPath()
504 <<
" fileHandler : comm:" << comm
510 isPtr.
reset(
new IFstream(filePaths[0]));
513 if (!
io.readHeader(*isPtr))
516 <<
"problem while reading header for object "
518 <<
" fileHandler : comm:" << comm
529 Pout<<
"masterUncollatedFileOperation::readStream :"
530 <<
" For processor " << proci
531 <<
" opening " << filePaths[proci] <<
endl;
534 const fileName& fPath = filePaths[proci];
536 if (readOnProcs[proci] && !fPath.empty())
540 readAndSend(fPath,
labelList(one{}, proci), pBufs);
546 pBufs.finishedScatters();
562 is.read(buf.data(), buf.size());
567 Pout<<
"masterUncollatedFileOperation::readStream :"
568 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
575 isPtr.
reset(
new ICharStream(std::move(buf)));
580 if (!
io.readHeader(*isPtr))
583 <<
"problem while reading header for object "
585 <<
" fileHandler : comm:" << comm
625 return commAndIORanks;
633void Foam::fileOperations::masterUncollatedFileOperation::init(
bool verbose)
640 <<
"I/O : " << typeName
641 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
645 if (IOobject::fileModificationChecking == IOobject::timeStampMaster)
650 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
652 IOobject::fileModificationChecking = IOobject::timeStamp;
654 else if (IOobject::fileModificationChecking == IOobject::inotifyMaster)
659 <<
"Resetting fileModificationChecking to inotify"
677 managedComm_(getManagedComm(comm_))
704 const bool distributedRoots,
756 return masterOp<bool>
772 return masterOp<bool>
785 const bool followLink
788 return masterOp<mode_t>
801 const bool followLink
820 const bool checkGzip,
821 const bool followLink
824 return masterOp<bool>
837 const bool followLink
840 return masterOp<bool>
853 const bool checkGzip,
854 const bool followLink
857 return masterOp<bool>
870 const bool followLink
881 fileSizeOp(followLink),
892 const bool followLink
898 if constexpr (std::is_integral_v<time_t>)
907 lastModifiedOp(followLink),
915 return masterOp<time_t>
918 lastModifiedOp(followLink),
929 const bool followLink
932 return masterOp<double>
945 const std::string& ext
948 return masterOp<bool>
963 return masterOp<bool>
980 return masterOp<bool>
995 const bool followLink
998 return masterOp<fileNameList>
1012 const bool followLink
1015 return masterOp<bool>
1032 return masterOp<bool>
1047 const bool followLink
1050 return masterOp<bool>
1065 const bool checkGlobal,
1073 Pout<<
"masterUncollatedFileOperation::filePath :"
1074 <<
" objectPath:" <<
io.objectPath()
1075 <<
" checkGlobal:" << checkGlobal
1085 if (cacheLevel() > 0)
1087 (void)findTimes(
io.time().path(),
io.time().constant());
1093 pathType searchType = NOTFOUND;
1095 word newInstancePath;
1118 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
1124 Pout<<
"masterUncollatedFileOperation::filePath :"
1125 <<
" master objPath:" << objPath
1127 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1138 int masterType(searchType);
1140 searchType = pathType(masterType);
1149 ||
io.local() ==
"uniform"
1181 objPath = localObjectPath
1197 objPath = masterOp<fileName>
1211 Pout<<
"masterUncollatedFileOperation::filePath :"
1212 <<
" Returning from file searching using type "
1215 <<
" filePath :" << objPath <<
endl <<
endl;
1223 const bool checkGlobal,
1230 Pout<<
"masterUncollatedFileOperation::dirPath :"
1231 <<
" objectPath:" <<
io.objectPath()
1232 <<
" checkGlobal:" << checkGlobal
1239 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1242 if (cacheLevel() > 0)
1244 (void)findTimes(
io.time().path(),
io.time().constant());
1250 pathType searchType = NOTFOUND;
1252 word newInstancePath;
1261 objPath = filePathInfo
1279 Pout<<
"masterUncollatedFileOperation::dirPath :"
1280 <<
" master objPath:" << objPath
1282 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1294 int masterType(searchType);
1296 searchType = pathType(masterType);
1306 ||
io.local() ==
"uniform"
1339 objPath = localObjectPath
1355 objPath = masterOp<fileName>
1358 fileOrNullOp(
false),
1369 Pout<<
"masterUncollatedFileOperation::dirPath :"
1370 <<
" Returning from directory searching using type "
1373 <<
" filePath :" << objPath <<
endl <<
endl;
1381 const dirIndexList& pDirs,
1388 const bool isFile = !
io.name().empty();
1394 if (isFileOrDir(
isFile, writePath))
1400 if (
io.time().processorCase())
1402 for (
const dirIndex& dirIdx : pDirs)
1404 const fileName& pDir = dirIdx.first();
1406 processorsPath(
io,
io.instance(), pDir)
1408 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1416 fileName localPath =
io.objectPath();
1418 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1431 const scalar startValue,
1432 const word& stopInstance,
1433 const bool constant_fallback
1438 Pout<<
"masterUncollatedFileOperation::findInstance :"
1439 <<
" Starting searching for name:" << startIO.
name()
1440 <<
" local:" << startIO.
local()
1441 <<
" from instance:" << startIO.
instance()
1445 const Time& time = startIO.
time();
1446 IOobject
io(startIO);
1455 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1468 foundInstance =
io.instance();
1479 if (!foundInstance.empty())
1481 io.instance() = foundInstance;
1484 Pout<<
"masterUncollatedFileOperation::findInstance :"
1485 <<
" for name:" <<
io.
name() <<
" local:" <<
io.local()
1486 <<
" found starting instance:" <<
io.instance() <<
endl;
1495 enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 };
1515 label instIndex = ts.size()-1;
1518 for (; instIndex >= 0; --instIndex)
1520 if (ts[instIndex] <= startValue)
1527 for (; instIndex >= 0; --instIndex)
1531 if (ts[instIndex].
name() == time.timeName())
1536 io.instance() = ts[instIndex].name();
1539 foundInstance =
io.instance();
1542 Pout<<
"masterUncollatedFileOperation::findInstance :"
1543 <<
" for name:" <<
io.
name() <<
" local:" <<
io.local()
1544 <<
" found at:" <<
io.instance()
1551 if (
io.instance() == stopInstance)
1555 Pout<<
"masterUncollatedFileOperation::findInstance :"
1557 <<
" local:" <<
io.local()
1558 <<
" at stop-instance:" <<
io.instance() <<
endl;
1563 failed = failureCodes::FAILED_STOPINST;
1568 foundInstance =
io.instance();
1589 !failed && foundInstance.empty()
1590 && (ts.empty() || ts[0].name() != time.constant() || startValue < 0)
1598 io.instance() = time.constant();
1604 Pout<<
"masterUncollatedFileOperation::findInstance :"
1606 <<
" local:" <<
io.local()
1607 <<
" at:" <<
io.instance() <<
endl;
1609 foundInstance =
io.instance();
1613 if (!failed && foundInstance.empty())
1617 failed = failureCodes::FAILED_CONSTINST;
1619 else if (constant_fallback)
1621 foundInstance = time.constant();
1625 foundInstance.clear();
1636 io.instance() = foundInstance;
1645 if (!
io.name().empty())
1648 <<
" file \"" <<
io.name() <<
"\" in";
1653 <<
io.local() <<
" in times "
1654 << startIO.
instance() <<
" down to ";
1656 if (failed == failureCodes::FAILED_STOPINST)
1669 Pout<<
"masterUncollatedFileOperation::findInstance :"
1670 <<
" name:" <<
io.
name() <<
" local:" <<
io.local()
1671 <<
" returning instance:" <<
io.instance() <<
endl;
1688 Pout<<
"masterUncollatedFileOperation::readObjects :"
1690 <<
" local:" <<
local <<
" instance:" << instance <<
endl;
1694 newInstance.clear();
1716 if (newInstance.empty())
1736 if (!foundInst.empty())
1757 Pout<<
"masterUncollatedFileOperation::readObjects :"
1758 <<
" newInstance:" << newInstance
1759 <<
" objectNames:" << objectNames <<
endl;
1777 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl
1778 <<
" objectPath:" <<
io.objectPath() <<
endl
1779 <<
" filePath :" << fName <<
endl;
1820 io.headerClassName(),
1844 result.resize(np,
false);
1845 headerClassName.resize(np);
1850 if (!filePaths[proci].empty())
1852 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1854 result[proci] = result[proci-1];
1855 headerClassName[proci] = headerClassName[proci-1];
1856 note[proci] = note[proci-1];
1860 IFstream is(filePaths[proci]);
1866 headerClassName[proci] =
io.headerClassName();
1867 note[proci] =
io.note();
1875 PstreamBuffers pBufs(comm_);
1880 io.headerClassName() = headerClassName[0];
1881 io.note() = note[0];
1884 for (
const int proci : pBufs.subProcs())
1886 UOPstream
os(proci, pBufs);
1887 os << result[proci] << headerClassName[proci] << note[proci];
1891 pBufs.finishedScatters();
1896 is >> ok >>
io.headerClassName() >>
io.note();
1902 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1903 <<
" class:" <<
io.headerClassName()
1904 <<
" for file:" << fName <<
endl;
1916 const bool readOnProc
1921 Pout<<
"masterUncollatedFileOperation::readStream :"
1922 <<
" object : " <<
io.name()
1923 <<
" global : " <<
io.global()
1924 <<
" globalObject : " <<
io.globalObject()
1925 <<
" fName : " << fName <<
" readOnProc:" << readOnProc <<
endl;
1932 bool isCollated =
false;
1952 headerIO.readHeader(*isPtr);
1962 Pout<<
"masterUncollatedFileOperation::readStream :"
1963 <<
" For object : " <<
io.name()
1964 <<
" doing straight IFstream input from "
1969 io.IOobject::operator=(headerIO);
1988 Pout<<
"masterUncollatedFileOperation::readStream :"
1989 <<
" For object : " <<
io.
name()
1990 <<
" starting collating input from " << fName <<
endl;
1998 procRangeType
group;
2011 <<
"Could not detect processor number"
2012 <<
" from objectPath:" <<
io.objectPath()
2013 <<
" fileHandler : comm:" << comm_
2021 proci -=
group.start();
2026 Pout<<
"masterUncollatedFileOperation::readStream :"
2027 <<
" For object : " <<
io.
name()
2028 <<
" starting input from block " << proci
2029 <<
" of " << isPtr->name() <<
endl;
2038 label readComm = -1;
2046 isPtr.
reset(
new IFstream(fName));
2051 IOobject headerIO(
io);
2052 headerIO.readHeader(*isPtr);
2063 bool bigSize =
false;
2071 > off_t(maxMasterFileBufferSize)
2100 Pout<<
"masterUncollatedFileOperation::readStream :"
2101 <<
" For object : " <<
io.
name()
2102 <<
" starting separated input from " << fName <<
endl;
2105 if (
io.global() ||
io.globalObject())
2160 return read(
io, comm_, uniform, filePaths, readOnProcs);
2169 const bool masterOnly,
2176 if (
io.global() ||
io.globalObject())
2180 Pout<<
"masterUncollatedFileOperation::read :"
2181 <<
" Reading global object " <<
io.name()
2183 <<
" Pstream::myProcNo:"
2197 ok =
io.readData(is);
2212 os <<
io.headerClassName() <<
io.note();
2213 bool okWrite =
io.writeData(
os);
2220 is >>
io.headerClassName() >>
io.note();
2221 ok =
io.readData(is);
2229 Pout<<
"masterUncollatedFileOperation::read :"
2230 <<
" Reading local object " <<
io.
name() <<
endl;
2239 Pout<<
"masterUncollatedFileOperation::read :"
2240 <<
" Read object:" <<
io.
name()
2241 <<
" isGlobal:" << (
io.global() ||
io.globalObject())
2242 <<
" status:" << ok <<
endl;
2253 const bool writeOnProc
2260 Pout<<
"masterUncollatedFileOperation::writeObject :"
2261 <<
" io:" << pathName <<
" writeOnProc:" << writeOnProc <<
endl;
2278 &&
io.writeHeader(
os)
2294 const word& constantName
2297 if (
const auto* instPtr = times_.get(directory); instPtr)
2301 Pout<<
"masterUncollatedFileOperation::findTimes :"
2302 <<
" Found " << instPtr->size() <<
" cached times" <<
nl
2303 <<
" for directory:" << directory <<
endl;
2319 const_cast<masterUncollatedFileOperation&
>(*this).nProcs(oldNProcs);
2328 Pout<<
"masterUncollatedFileOperation::findTimes :"
2330 <<
" for directory:" << directory <<
endl;
2336 if (cacheLevel() > 0)
2338 auto* tPtr =
new DynamicList<instant>(std::move(times));
2339 times_.set(directory, tPtr);
2363 if (
auto iter = times_.find(tm.
path()); iter.good())
2365 DynamicList<instant>& times = *(iter.val());
2370 const label startIdx =
2381 if (times.size() <= startIdx || times.last() < timeNow)
2383 times.push_back(timeNow);
2389 Pout<<
"masterUncollatedFileOperation::setTime :"
2390 <<
" Caching time " << tm.
timeName()
2391 <<
" for case:" << tm.
path() <<
endl;
2394 times.push_back(timeNow);
2396 auto realTimes = times.slice(startIdx);
2433 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2434 <<
" Opening global file " << filePath <<
endl;
2450 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2451 <<
" Opening local file " << filePath
2452 <<
" for rank " << proci <<
endl;
2466 pBufs.finishedSends();
2477 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2478 <<
" Reading " << filePath
2487 is.read(buf.data(), buf.size());
2492 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2493 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2500 isPtr.
reset(
new ICharStream(std::move(buf)));
2503 isPtr->name() = filePath;
2509 isPtr.
reset(
new IFstream(filePath));
2521 const bool writeOnProc
2544 const bool writeOnProc
2573 Pout<<
"masterUncollatedFileOperation::sync :"
2574 <<
" syncing information across processors" <<
endl;
2585 timeNames.
resize(times_.size());
2586 instants.
resize(times_.size());
2592 timeNames[i] = iter.key();
2593 instants[i] = std::move(*(iter.val()));
2603 fileName dir(timeNames[i]);
2604 auto ptr = autoPtr<DynamicList<instant>>
::New(std::move(instants[i]));
2610 procRangeType
group;
2631 if (proci != -1 && proci != myProci)
2650 watchFd = monitor().addWatch(fName);
2660 const label watchIndex
2666 ok = monitor().removeWatch(watchIndex);
2686 if (monitor().getFile(watchIndices[i]) == fName)
2722 const label index = findWatch(watchIndices,
f);
2731 newWatchIndices.
push_back(watchIndices[index]);
2732 removedWatches.erase(index);
2737 for (
const label index : removedWatches)
2739 removeWatch(watchIndices[index]);
2754 const label watchIndex
2760 fName = monitor().getFile(watchIndex);
2770 const bool masterOnly,
2776 monitor().updateStates(
true,
false);
2790 state = monitor().getState(watchFd);
2805 monitor().setUnmodified(watchFd);
Input/output streams with (internal or external) character storage.
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
An ISstream with internal List storage. Always UNCOMPRESSED.
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.
bool readHeader(Istream &is)
Read header ('FoamFile' dictionary) and set the IOobject and stream characteristics.
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.
compressionType compression() const noexcept
Get the stream compression.
streamFormat
Data format (ascii | binary | coherent).
atomicType
Atomic operations (output).
@ NO_APPEND
no append (truncates existing)
bool good() const noexcept
True if next operation might succeed.
Input inter-processor communications stream using MPI broadcast.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
Output inter-processor communications stream using MPI broadcast.
Generic output stream using a standard (STL) stream.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedScatters(const bool wait=true)
Mark all sends to sub-procs as done.
label recvDataCount(const label proci) const
Number of unconsumed receive bytes for the specified processor. Must call finishedSends() or other fi...
void finishedSends(const bool wait=true)
Mark the send phase as being finished.
UPstream::rangeType subProcs() const noexcept
Range of sub-processes indices associated with PstreamBuffers.
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.
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.
fileName path() const
The path for the case = rootPath/caseName.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
const T1 & first() const noexcept
Access the first element.
const T2 & second() const noexcept
Access the second element.
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive buffer contents (contiguous types) from given processor.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T * data() noexcept
Return pointer to the underlying array serving as data storage.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
void size(const label n)
Older name for setAddressableSize.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
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...
static List< int > & procID(int communicator)
The list of ranks within a given communicator.
commsTypes
Communications types.
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm)
Gather individual values into list locations.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
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 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 label newCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Create new communicator with sub-ranks on the parent communicator.
@ gatherList
gatherList [manual algorithm]
@ broadcast
broadcast [MPI]
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
static bool & parRun() noexcept
Test if this a parallel run.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void clear() noexcept
Same as reset(nullptr).
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 readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &localData, const UPstream::commsTypes commsType)
Read data (on master) and transmit.
static bool readHeader(IOobject &io, Istream &is)
Read header as per IOobject with additional handling of decomposedBlockData.
const Type & value() const noexcept
Return const reference to value.
static autoPtr< ISstream > New()
Return a dummyISstream.
fileState
Enumeration defining the file state.
A class for handling file names.
Type
Enumerations to handle directory entry types.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
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.
static label getManagedComm(const label communicator)
Construction helper: check for locally allocated communicator.
virtual instantList findTimes(const fileName &directory, const word &constantName="constant") const
Get sorted list of times.
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.
const labelList ioRanks_
The list of IO ranks (global ranks).
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 refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
List< dirIndex > dirIndexList
static label splitProcessorPath(const fileName &objectPath, fileName &path, fileName &procDir, fileName &local, procRangeType &group, label &nProcs)
Split objectPath into part before 'processor' and part after.
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE).
static label detectProcessorPath(const fileName &objPath)
Detect processor number from '/aa/bb/processorDDD/cc'.
virtual void setTime(const Time &) const
Callback for time change.
pathType
Enumeration for the location of an IOobject.
@ 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...
label comm() const noexcept
Communicator to use.
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.
fileOperation(const label comm, const labelUList &ioRanks=labelUList::null(), const bool distributedRoots=false)
Construct from communicator, optionally with specified io-ranks and/or distributed roots.
static const Enum< pathType > pathTypeNames_
virtual void sync()
Forcibly parallel sync.
fileMonitor & monitor() const
Get or create fileMonitor singleton.
UPstream::rangeType procRangeType
For addressing a range of processors (an int range).
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.
const HashPtrTable< DynamicList< instant > > & times() const noexcept
Return cached times.
virtual instantList findTimes(const fileName &directory, const word &constantName="constant") const
Get sorted list of times.
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.
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.
Type masterOp(const fileName &fName, const FileOp &fop, const int tag, const label comm) const
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.
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 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 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 bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Writes a regIOobject (so header, contents and divider).
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.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Master-only drop-in replacement for OFstream.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
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.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
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)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
#define WarningInFunction
Report a warning using Foam::Warning.
constexpr const char *const group
Group name for atomic constants.
Namespace for handling debugging switches.
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
Namespace for implementations of a fileOperation.
List< word > wordList
List of word.
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.
bool read(const char *buf, int32_t &val)
Same as readInt32.
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.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
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.
List< string > stringList
List of string.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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...
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 ...
List< bool > boolList
A List of bools.
int infoDetailLevel
Global for selective suppression of Info output.
UList< bool > boolUList
A UList of bools.
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.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
static Tuple2< label, labelList > getCommPattern()
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 registerOptSwitch(Name, Type, SwitchVar)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Extract type (as a word) from an object, typically using its type() method.