48 namespace fileOperations
54 masterUncollatedFileOperation,
64 "maxMasterFileBufferSize",
72 fileOperationInitialise,
73 masterUncollatedFileOperationInitialise,
90 if (mainRanks.
empty())
98 if (!mainRanks.
found(0))
101 <<
"Rank 0 (master) should be in the IO ranks. Currently " 107 const bitSet isIOrank(
n, mainRanks);
117 label rank = proci+1;
118 rank <
n && !isIOrank[rank];
147 if (t.
equal(timeDirs[i].value()))
149 return timeDirs[i].name();
160 const bool checkGlobal,
164 pathType& searchType,
166 word& newInstancePath
172 if (
io.instance().isAbsolute())
176 if (isFileOrDir(
isFile, objPath))
190 fileName writePath(objectPath(
io,
io.headerClassName()));
192 if (isFileOrDir(
isFile, writePath))
199 if (
io.time().processorCase())
201 refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
203 for (
const dirIndex& dirIdx : pDirs())
205 const fileName& pDir = dirIdx.first();
207 processorsPath(
io,
io.instance(), pDir)
209 if (objPath != writePath && isFileOrDir(
isFile, objPath))
211 searchType = dirIdx.second().first();
219 fileName localPath =
io.objectPath();
223 localPath != writePath
224 && isFileOrDir(
isFile, localPath)
238 &&
io.time().processorCase()
240 io.instance() ==
io.time().system()
241 ||
io.instance() ==
io.time().constant()
245 fileName parentPath =
246 io.rootPath()/
io.time().globalCaseName()
247 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
249 if (isFileOrDir(
isFile, parentPath))
258 const auto pathFnd = times_.cfind(
io.time().path());
260 if (
search && pathFnd.found())
262 newInstancePath = findInstancePath
265 instant(
io.instance())
268 if (newInstancePath.size() && newInstancePath !=
io.instance())
271 refPtr<dirIndexList> pDirs
273 lookupProcessorsPath(
io.objectPath())
276 for (
const dirIndex& dirIdx : pDirs())
278 const fileName& pDir = dirIdx.first();
282 processorsPath(
io, newInstancePath, pDir)
285 if (isFileOrDir(
isFile, fName))
287 switch (dirIdx.second().first())
317 io.rootPath()/
io.caseName()
318 /newInstancePath/
io.db().dbDir()/
io.local()/
io.name()
320 if (isFileOrDir(
isFile, fName))
338 const pathType& searchType,
340 const word& instancePath
349 return io.instance()/
io.name();
355 return io.path()/
io.name();
361 return objectPath(
io,
io.headerClassName());
391 processorsPath(
io,
io.instance(), procDir)
400 processorsPath(
io,
io.instance(), processorsDir(
io))
408 io.rootPath()/
io.time().globalCaseName()
409 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
416 io.rootPath()/
io.caseName()
417 /instancePath/
io.db().dbDir()/
io.local()/
io.name();
448 processorsPath(
io, instancePath, procDir)
457 processorsPath(
io, instancePath, processorsDir(
io))
479 const fileName& filePath,
481 PstreamBuffers& pBufs
489 <<
"Cannot open file " << filePath
495 Pout<<
"masterUncollatedFileOperation::readAndSend :" 496 <<
" compressed:" << bool(ifs.compression()) <<
" " 506 const std::string buf
508 std::istreambuf_iterator<char>(ifs.stdStream()),
509 std::istreambuf_iterator<char>()
512 for (
const label proci : procs)
514 UOPstream
os(proci, pBufs);
515 os.write(buf.data(), buf.length());
520 Pout<<
"masterUncollatedFileOperation::readStream :" 521 <<
" From " << filePath <<
" sent " << buf.size()
530 List<char> buf(static_cast<label>(
count));
531 ifs.stdStream().read(buf.data(),
count);
533 for (
const label proci : procs)
535 UOPstream
os(proci, pBufs);
541 Pout<<
"masterUncollatedFileOperation::readStream :" 542 <<
" From " << filePath <<
" sent " << buf.size()
559 autoPtr<ISstream> isPtr;
571 if (filePaths[0].empty())
574 <<
"cannot find file " <<
io.objectPath()
581 if (procValid[proci])
583 validProcs.append(proci);
591 Pout<<
"masterUncollatedFileOperation::readStream :" 592 <<
" For uniform file " << filePaths[0]
593 <<
" sending to " << validProcs
594 <<
" in comm:" << comm <<
endl;
596 readAndSend(filePaths[0], validProcs, pBufs);
603 if (filePaths[0].empty())
606 <<
"cannot find file " <<
io.objectPath()
611 isPtr.reset(
new IFstream(filePaths[0]));
614 if (!
io.readHeader(*isPtr))
617 <<
"problem while reading header for object " 627 Pout<<
"masterUncollatedFileOperation::readStream :" 628 <<
" For processor " << proci
629 <<
" opening " << filePaths[proci] <<
endl;
632 const fileName& fPath = filePaths[proci];
634 if (procValid[proci] && !fPath.empty())
638 readAndSend(fPath,
labelList(one{}, proci), pBufs);
645 pBufs.finishedSends(recvSizes);
662 is.read(buf.data(), buf.size());
667 Pout<<
"masterUncollatedFileOperation::readStream :" 668 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
675 isPtr.reset(
new IListStream(std::move(buf)));
680 if (!
io.readHeader(*isPtr))
683 <<
"problem while reading header for object " 689 isPtr.reset(
new dummyISstream());
700 void Foam::fileOperations::masterUncollatedFileOperation::init(
bool verbose)
707 <<
"I/O : " << typeName
708 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')' 717 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
726 <<
"Resetting fileModificationChecking to inotify" 788 return masterOp<mode_t>
804 return masterOp<mode_t>
817 const bool followLink
820 return masterOp<mode_t>
833 const bool followLink
852 const bool checkGzip,
853 const bool followLink
856 return masterOp<bool>
859 existsOp(checkGzip, followLink),
869 const bool followLink
872 return masterOp<bool>
885 const bool checkGzip,
886 const bool followLink
889 return masterOp<bool>
892 isFileOp(checkGzip, followLink),
902 const bool followLink
905 return masterOp<off_t>
908 fileSizeOp(followLink),
918 const bool followLink
921 return masterOp<time_t>
924 lastModifiedOp(followLink),
934 const bool followLink
937 return masterOp<double>
940 highResLastModifiedOp(followLink),
950 const std::string& ext
953 return masterOp<bool>
968 return masterOp<bool>
985 return masterOp<bool>
988 rmDirOp(silent, emptyOnly),
1000 const bool followLink
1003 return masterOp<fileNameList>
1006 readDirOp(
type, filtergz, followLink),
1017 const bool followLink
1020 return masterOp<bool>
1037 return masterOp<bool>
1052 const bool followLink
1055 return masterOp<bool>
1070 const bool checkGlobal,
1072 const word& typeName,
1078 Pout<<
"masterUncollatedFileOperation::filePath :" 1079 <<
" objectPath:" <<
io.objectPath()
1080 <<
" checkGlobal:" << checkGlobal <<
endl;
1085 (void)lookupProcessorsPath(
io.objectPath());
1088 (void)findTimes(
io.time().path(),
io.time().constant());
1094 pathType searchType = NOTFOUND;
1096 word newInstancePath;
1120 Pout<<
"masterUncollatedFileOperation::filePath :" 1121 <<
" master objPath:" << objPath
1123 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1133 int masterType(searchType);
1135 searchType = pathType(masterType);
1144 ||
io.local() ==
"uniform" 1176 objPath = localObjectPath
1192 objPath = masterOp<fileName>
1206 Pout<<
"masterUncollatedFileOperation::filePath :" 1207 <<
" Returning from file searching:" <<
endl 1208 <<
" objectPath:" <<
io.objectPath() <<
endl 1217 const bool checkGlobal,
1224 Pout<<
"masterUncollatedFileOperation::dirPath :" 1225 <<
" objectPath:" <<
io.objectPath()
1226 <<
" checkGlobal:" << checkGlobal <<
endl;
1231 (void)lookupProcessorsPath(
io.objectPath());
1236 pathType searchType = NOTFOUND;
1238 word newInstancePath;
1244 objPath = filePathInfo
1259 int masterType(searchType);
1262 searchType = pathType(masterType);
1271 ||
io.local() ==
"uniform" 1303 objPath = localObjectPath
1319 objPath = masterOp<fileName>
1322 fileOrNullOp(
false),
1333 Pout<<
"masterUncollatedFileOperation::dirPath :" 1334 <<
" Returning from file searching:" <<
endl 1335 <<
" objectPath:" <<
io.objectPath() <<
endl 1344 const dirIndexList& pDirs,
1351 const bool isFile = !
io.name().empty();
1357 if (isFileOrDir(
isFile, writePath))
1363 if (
io.time().processorCase())
1365 for (
const dirIndex& dirIdx : pDirs)
1367 const fileName& pDir = dirIdx.first();
1369 processorsPath(
io,
io.instance(), pDir)
1371 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1379 fileName localPath =
io.objectPath();
1381 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1394 const scalar startValue,
1395 const word& stopInstance
1400 Pout<<
"masterUncollatedFileOperation::findInstance :" 1401 <<
" Starting searching for name:" << startIO.
name()
1402 <<
" local:" << startIO.
local()
1403 <<
" from instance:" << startIO.
instance()
1427 foundInstance =
io.instance();
1435 if (!foundInstance.empty())
1437 io.instance() = foundInstance;
1440 Pout<<
"masterUncollatedFileOperation::findInstance :" 1441 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1442 <<
" found starting instance:" <<
io.instance() <<
endl;
1451 enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 };
1461 label instIndex = ts.size()-1;
1464 for (; instIndex >= 0; --instIndex)
1466 if (ts[instIndex].value() <= startValue)
1473 for (; instIndex >= 0; --instIndex)
1482 io.instance() = ts[instIndex].name();
1485 foundInstance =
io.instance();
1488 Pout<<
"masterUncollatedFileOperation::findInstance :" 1489 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1490 <<
" found at:" <<
io.instance()
1497 if (
io.instance() == stopInstance)
1501 Pout<<
"masterUncollatedFileOperation::findInstance :" 1502 <<
" name:" <<
io.name()
1503 <<
" local:" <<
io.local()
1504 <<
" at stop-instance:" <<
io.instance() <<
endl;
1509 failed = failureCodes::FAILED_STOPINST;
1513 foundInstance =
io.instance();
1534 !failed && foundInstance.empty()
1535 && (ts.empty() || ts[0].name() != time.
constant() || startValue < 0)
1549 Pout<<
"masterUncollatedFileOperation::findInstance :" 1550 <<
" name:" <<
io.name()
1551 <<
" local:" <<
io.local()
1552 <<
" at:" <<
io.instance() <<
endl;
1554 foundInstance =
io.instance();
1558 if (!failed && foundInstance.empty())
1562 failed = failureCodes::FAILED_CONSTINST;
1575 io.instance() = foundInstance;
1584 if (!
io.name().empty())
1587 <<
" file \"" <<
io.name() <<
"\" in";
1592 <<
io.local() <<
" in times " 1593 << startIO.
instance() <<
" down to ";
1595 if (failed == failureCodes::FAILED_STOPINST)
1608 Pout<<
"masterUncollatedFileOperation::findInstance :" 1609 <<
" name:" <<
io.name() <<
" local:" <<
io.local()
1610 <<
" returning instance:" <<
io.instance() <<
endl;
1627 Pout<<
"masterUncollatedFileOperation::readObjects :" 1629 <<
" local:" <<
local <<
" instance:" << instance <<
endl;
1653 if (newInstance.empty())
1669 const instant t(instance);
1672 if (t.
equal(timeDirs[i].value()))
1694 Pout<<
"masterUncollatedFileOperation::readObjects :" 1695 <<
" newInstance:" << newInstance
1696 <<
" objectNames:" << objectNames <<
endl;
1707 const word& typeName
1714 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl 1715 <<
" objectPath:" <<
io.objectPath() <<
endl 1716 <<
" filePath :" << fName <<
endl;
1723 bool uniform = uniformFile(filePaths);
1746 io.headerClassName(),
1769 result.resize(np,
false);
1770 headerClassName.resize(np);
1775 if (!filePaths[proci].empty())
1777 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1779 result[proci] = result[proci-1];
1780 headerClassName[proci] = headerClassName[proci-1];
1781 note[proci] = note[proci-1];
1785 IFstream is(filePaths[proci]);
1791 headerClassName[proci] =
io.headerClassName();
1792 note[proci] =
io.note();
1805 io.headerClassName() = headerClassName[0];
1806 io.note() = note[0];
1809 for (
const int proci : pBufs.subProcs())
1811 UOPstream
os(proci, pBufs);
1812 os << result[proci] << headerClassName[proci] << note[proci];
1816 pBufs.finishedScatters();
1821 is >> ok >>
io.headerClassName() >>
io.note();
1827 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1828 <<
" class:" <<
io.headerClassName() <<
endl;
1839 const word& typeName,
1845 Pout<<
"masterUncollatedFileOperation::readStream :" 1846 <<
" object : " <<
io.name()
1847 <<
" global : " <<
io.global()
1848 <<
" fName : " << fName <<
" valid:" << valid <<
endl;
1853 bool isCollated =
false;
1873 headerIO.readHeader(*isPtr);
1883 Pout<<
"masterUncollatedFileOperation::readStream :" 1884 <<
" For object : " <<
io.name()
1885 <<
" doing straight IFstream input from " 1907 Pout<<
"masterUncollatedFileOperation::readStream :" 1908 <<
" For object : " <<
io.name()
1909 <<
" starting collating input from " << fName <<
endl;
1918 procRangeType
group;
1927 label proci = detectProcessorPath(
io.objectPath());
1932 <<
"Could not detect processor number" 1933 <<
" from objectPath:" <<
io.objectPath()
1940 proci = proci -
group.start();
1945 Pout<<
"masterUncollatedFileOperation::readStream :" 1946 <<
" For object : " <<
io.name()
1947 <<
" starting input from block " << proci
1948 <<
" of " << isPtr->name() <<
endl;
1957 label readComm = -1;
1965 isPtr.
reset(
new IFstream(fName));
1970 IOobject headerIO(
io);
1971 headerIO.readHeader(*isPtr);
1982 bool bigSize =
false;
1990 > off_t(maxMasterFileBufferSize)
2019 Pout<<
"masterUncollatedFileOperation::readStream :" 2020 <<
" For object : " <<
io.name()
2021 <<
" starting separated input from " << fName <<
endl;
2032 boolList procValid(UPstream::listGatherValues<bool>(valid));
2046 boolList procValid(UPstream::listGatherValues<bool>(valid, comm_));
2052 const bool uniform = uniformFile(filePaths);
2054 return read(
io, comm_, uniform, filePaths, procValid);
2063 const bool masterOnly,
2065 const word& typeName
2070 if (
io.globalObject())
2074 Pout<<
"masterUncollatedFileOperation::read :" 2075 <<
" Reading global object " <<
io.name() <<
endl;
2084 ok =
io.readData(
io.readStream(typeName));
2097 io.headerClassName(),
2109 bool okWrite =
io.writeData(toAll);
2114 IPBstream fromMaster
2120 ok =
io.readData(fromMaster);
2128 Pout<<
"masterUncollatedFileOperation::read :" 2129 <<
" Reading local object " <<
io.name() <<
endl;
2132 ok =
io.readData(
io.readStream(typeName));
2151 Pout<<
"masterUncollatedFileOperation::writeObject :" 2152 <<
" io:" << pathName <<
" valid:" << valid <<
endl;
2169 &&
io.writeHeader(
os)
2185 const word& constantName
2188 const auto iter = times_.cfind(directory);
2193 Pout<<
"masterUncollatedFileOperation::findTimes :" 2194 <<
" Found " << iter.val()->size() <<
" cached times" <<
endl;
2196 return *(iter.val());
2214 Pout<<
"masterUncollatedFileOperation::findTimes :" 2215 <<
" Caching times:" << times <<
nl 2216 <<
" for directory:" << directory <<
endl;
2222 auto* tPtr =
new DynamicList<instant>(std::move(times));
2224 times_.set(directory, tPtr);
2244 HashPtrTable<DynamicList<instant>>::iterator iter = times_.find(tm.
path());
2248 DynamicList<instant>& times = *(iter.val());
2253 const label startIdx =
2255 (times.empty() || times[0].name() != tm.
constant())
2264 if (times.size() <= startIdx || times.last() < timeNow)
2272 SubList<instant>(times, times.size()-startIdx, startIdx),
2279 Pout<<
"masterUncollatedFileOperation::setTime :" 2280 <<
" Caching time " << tm.
timeName()
2281 <<
" for case:" << tm.
path() <<
endl;
2284 times.append(timeNow);
2286 SubList<instant> realTimes
2288 times, times.size()-startIdx, startIdx
2324 const bool uniform = uniformFile(filePaths);
2330 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2331 <<
" Opening global file " << filePath <<
endl;
2368 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2369 <<
" Reading " << filePath
2380 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2381 <<
" Done reading " << buf.
size() <<
" bytes" <<
endl;
2391 isPtr->name() = filePath;
2463 watchFd = monitor().addWatch(fName);
2472 const label watchIndex
2478 ok = monitor().removeWatch(watchIndex);
2497 if (monitor().getFile(watchIndices[i]) == fName)
2522 const label index = findWatch(watchIndices,
f);
2526 newWatchIndices.
append(addWatch(
f));
2531 newWatchIndices.
append(watchIndices[index]);
2532 removedWatches.
erase(index);
2537 for (
const label index : removedWatches)
2539 removeWatch(watchIndices[index]);
2548 const label watchIndex
2554 fName = monitor().getFile(watchIndex);
2563 const bool masterOnly,
2569 monitor().updateStates(
true,
false);
2583 state = monitor().getState(watchFd);
2597 monitor().setUnmodified(watchFd);
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static const Enum< pathType > pathTypeNames_
List< instant > instantList
List of instants.
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.
void size(const label n)
Older name for setAddressableSize.
fileName path() const
Return 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.
A class for handling file names.
virtual const fileName & name() const
The name of the stream.
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
commsTypes
Types of communications.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
const word & name() const noexcept
Return the object name.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
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)
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
static const fileName null
An empty fileName.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const
Reads header for regIOobject and returns an ISstream.
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.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
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.
void clear() noexcept
Same as reset(nullptr)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (cf. MPI AllReduce)
file found in time directory
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.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
static label worldComm
Default world communicator (all processors). May differ from globalComm if local worlds are in use...
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 | MUST_READ_IF_MODIFIED) bits are set.
UList< label > labelUList
A UList of labels.
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
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)
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)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
instance is absolute directory
"scheduled" : (MPI_Send, MPI_Recv)
bool good() const noexcept
True if the managed pointer is non-null.
objectPath exists in 'processorsNN'
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
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.
Inter-processor communications stream.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
void finishedSends(const bool wait=true)
Mark sends as done.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static const word null
An empty word.
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
void append(const T &val)
Copy append an element to the end of this list.
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)
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.
static bool isUserComm(label communicator) noexcept
True if communicator appears to be user-allocated.
masterUncollatedFileOperation(bool verbose)
Default construct.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
An ISstream with internal List storage. Always UNCOMPRESSED.
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.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
const word & constant() const noexcept
Return constant name.
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, using an ISstream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
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 processes in communicator.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
word format(conversionProperties.get< word >("format"))
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
A List of words.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
List< string > stringList
A List of strings.
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.
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.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const Time & time() const
Return Time associated with the objectRegistry.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
static bool master(const label communicator=worldComm)
Am I the master rank.
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
"nonBlocking" : (MPI_Isend, MPI_Irecv)
static void readAndSend(const fileName &filePath, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolList &procValid)
Read files on comms master.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
defineTypeNameAndDebug(collatedFileOperation, 0)
List< label > labelList
A List of labels.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Registry of regIOobjects.
bool equal(scalar val) const noexcept
True if values are equal (includes SMALL for rounding)
static labelList ioRanks()
Retrieve list of IO ranks from FOAM_IORANKS env variable.
virtual void setTime(const Time &) const
Callback for time change.
const fileName & local() const noexcept
Read access to local path component.
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Read buffer contents from given processor.
List< fileName > fileNameList
A List of fileNames.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Defines the attributes of an object for which implicit objectRegistry management is supported...
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Inter-processor communications stream.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
Type
Enumerations to handle directory entry types.
Extract type (as a word) from an object, typically using its type() method.
static labelList subRanks(const label n)
Get the list of processors that are part of this communicator.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...