47 namespace fileOperations
53 masterUncollatedFileOperation,
59 masterUncollatedFileOperation,
69 "maxMasterFileBufferSize",
77 fileOperationInitialise,
78 fileOperationInitialise_unthreaded,
103 if (t.
equal(timeDirs[i].value()))
105 return timeDirs[i].name();
116 const bool checkGlobal,
119 const dirIndexList& pDirs,
121 pathType& searchType,
123 word& newInstancePath
127 newInstancePath.clear();
129 if (
io.instance().isAbsolute())
133 if (isFileOrDir(
isFile, objPath))
147 fileName writePath(objectPath(
io,
io.headerClassName()));
149 if (isFileOrDir(
isFile, writePath))
156 if (
io.time().processorCase())
158 for (
const dirIndex& dirIdx : pDirs)
160 const fileName& pDir = dirIdx.first();
162 processorsPath(
io,
io.instance(), pDir)
164 if (objPath != writePath && isFileOrDir(
isFile, objPath))
166 searchType = dirIdx.second().first();
174 fileName localPath =
io.objectPath();
178 localPath != writePath
179 && isFileOrDir(
isFile, localPath)
193 &&
io.time().processorCase()
195 io.instance() ==
io.time().system()
196 ||
io.instance() ==
io.time().constant()
200 fileName parentPath =
201 io.rootPath()/
io.time().globalCaseName()
202 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
204 if (isFileOrDir(
isFile, parentPath))
213 const auto pathFnd = times_.cfind(
io.time().path());
215 if (
search && pathFnd.good())
217 newInstancePath = findInstancePath
220 instant(
io.instance())
223 if (newInstancePath.size() && newInstancePath !=
io.instance())
226 for (
const dirIndex& dirIdx : pDirs)
228 const fileName& pDir = dirIdx.first();
232 processorsPath(
io, newInstancePath, pDir)
235 if (isFileOrDir(
isFile, fName))
237 switch (dirIdx.second().first())
267 io.rootPath()/
io.caseName()
268 /newInstancePath/
io.db().dbDir()/
io.local()/
io.name()
270 if (isFileOrDir(
isFile, fName))
289 const pathType& searchType,
291 const word& instancePath
300 return io.instance()/
io.name();
306 return io.path()/
io.name();
312 return objectPath(
io,
io.headerClassName());
342 processorsPath(
io,
io.instance(), procDir)
351 processorsPath(
io,
io.instance(), processorsDir(
io))
359 io.rootPath()/
io.time().globalCaseName()
360 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name();
367 io.rootPath()/
io.caseName()
368 /instancePath/
io.db().dbDir()/
io.local()/
io.name();
399 processorsPath(
io, instancePath, procDir)
408 processorsPath(
io, instancePath, processorsDir(
io))
430 const fileName& filePath,
432 PstreamBuffers& pBufs
435 if (recvProcs.empty())
return;
442 <<
"Cannot open file " << filePath
450 Pout<<
"masterUncollatedFileOperation::readAndSend :" 451 <<
" compressed:" << bool(ifs.compression()) <<
" " 461 const std::string buf
463 std::istreambuf_iterator<char>(ifs.stdStream()),
464 std::istreambuf_iterator<char>()
467 for (
const label proci : recvProcs)
469 UOPstream
os(proci, pBufs);
470 os.write(buf.data(), buf.length());
475 Pout<<
"masterUncollatedFileOperation::readStream :" 476 <<
" From " << filePath <<
" sent " << buf.size()
485 List<char> buf(static_cast<label>(
count));
486 ifs.stdStream().read(buf.data(),
count);
488 for (
const label proci : recvProcs)
490 UOPstream
os(proci, pBufs);
496 Pout<<
"masterUncollatedFileOperation::readStream :" 497 <<
" From " << filePath <<
" sent " << buf.size()
514 autoPtr<ISstream> isPtr;
524 if (filePaths[0].empty())
527 <<
"Cannot find file " <<
io.objectPath()
528 <<
" fileHandler : comm:" << comm
536 if (readOnProcs[proci])
538 recvProcs.push_back(proci);
546 Pout<<
"masterUncollatedFileOperation::readStream :" 547 <<
" For uniform file " << filePaths[0]
548 <<
" sending to " << recvProcs
549 <<
" in comm:" << comm <<
endl;
551 readAndSend(filePaths[0], recvProcs, pBufs);
558 if (filePaths[0].empty())
561 <<
"Cannot find file " <<
io.objectPath()
562 <<
" fileHandler : comm:" << comm
568 isPtr.reset(
new IFstream(filePaths[0]));
571 if (!
io.readHeader(*isPtr))
574 <<
"problem while reading header for object " 576 <<
" fileHandler : comm:" << comm
587 Pout<<
"masterUncollatedFileOperation::readStream :" 588 <<
" For processor " << proci
589 <<
" opening " << filePaths[proci] <<
endl;
592 const fileName& fPath = filePaths[proci];
594 if (readOnProcs[proci] && !fPath.empty())
598 readAndSend(fPath,
labelList(one{}, proci), pBufs);
604 pBufs.finishedScatters();
620 is.read(buf.data(), buf.size());
625 Pout<<
"masterUncollatedFileOperation::readStream :" 626 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
633 isPtr.reset(
new IListStream(std::move(buf)));
638 if (!
io.readHeader(*isPtr))
641 <<
"problem while reading header for object " 643 <<
" fileHandler : comm:" << comm
650 isPtr.reset(
new dummyISstream());
683 return commAndIORanks;
691 void Foam::fileOperations::masterUncollatedFileOperation::init(
bool verbose)
698 <<
"I/O : " << typeName
699 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')' 708 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
717 <<
"Resetting fileModificationChecking to inotify" 735 managedComm_(getManagedComm(comm_))
745 const bool distributedRoots,
759 managedComm_ = getManagedComm(comm_);
780 return masterOp<mode_t>
796 return masterOp<mode_t>
809 const bool followLink
812 return masterOp<mode_t>
825 const bool followLink
844 const bool checkGzip,
845 const bool followLink
848 return masterOp<bool>
851 existsOp(checkGzip, followLink),
861 const bool followLink
864 return masterOp<bool>
877 const bool checkGzip,
878 const bool followLink
881 return masterOp<bool>
884 isFileOp(checkGzip, followLink),
894 const bool followLink
897 return masterOp<off_t>
900 fileSizeOp(followLink),
910 const bool followLink
913 return masterOp<time_t>
916 lastModifiedOp(followLink),
926 const bool followLink
929 return masterOp<double>
932 highResLastModifiedOp(followLink),
942 const std::string& ext
945 return masterOp<bool>
960 return masterOp<bool>
977 return masterOp<bool>
980 rmDirOp(silent, emptyOnly),
992 const bool followLink
995 return masterOp<fileNameList>
998 readDirOp(
type, filtergz, followLink),
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;
1119 Pout<<
"masterUncollatedFileOperation::filePath :" 1120 <<
" master objPath:" << objPath
1122 <<
" 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 using type " 1209 <<
" objectPath:" <<
io.objectPath() <<
endl 1218 const bool checkGlobal,
1225 Pout<<
"masterUncollatedFileOperation::dirPath :" 1226 <<
" objectPath:" <<
io.objectPath()
1227 <<
" checkGlobal:" << checkGlobal
1234 const refPtr<dirIndexList> pDirs(lookupProcessorsPath(
io.objectPath()));
1237 if (cacheLevel() > 0)
1239 (void)findTimes(
io.time().path(),
io.time().constant());
1245 pathType searchType = NOTFOUND;
1247 word newInstancePath;
1255 objPath = filePathInfo
1272 Pout<<
"masterUncollatedFileOperation::dirPath :" 1273 <<
" master objPath:" << objPath
1275 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1287 int masterType(searchType);
1289 searchType = pathType(masterType);
1299 ||
io.local() ==
"uniform" 1332 objPath = localObjectPath
1348 objPath = masterOp<fileName>
1351 fileOrNullOp(
false),
1362 Pout<<
"masterUncollatedFileOperation::dirPath :" 1363 <<
" Returning from directory searching using type " 1365 <<
" objectPath:" <<
io.objectPath() <<
endl 1374 const dirIndexList& pDirs,
1381 const bool isFile = !
io.name().empty();
1387 if (isFileOrDir(
isFile, writePath))
1393 if (
io.time().processorCase())
1395 for (
const dirIndex& dirIdx : pDirs)
1397 const fileName& pDir = dirIdx.first();
1399 processorsPath(
io,
io.instance(), pDir)
1401 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1409 fileName localPath =
io.objectPath();
1411 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1424 const scalar startValue,
1425 const word& stopInstance
1430 Pout<<
"masterUncollatedFileOperation::findInstance :" 1431 <<
" Starting searching for name:" << startIO.
name()
1432 <<
" local:" << startIO.
local()
1433 <<
" from instance:" << startIO.
instance()
1459 foundInstance =
io.instance();
1469 if (!foundInstance.empty())
1471 io.instance() = foundInstance;
1474 Pout<<
"masterUncollatedFileOperation::findInstance :" 1475 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1476 <<
" found starting instance:" <<
io.instance() <<
endl;
1485 enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 };
1496 label instIndex = ts.size()-1;
1499 for (; instIndex >= 0; --instIndex)
1501 if (ts[instIndex].value() <= startValue)
1508 for (; instIndex >= 0; --instIndex)
1517 io.instance() = ts[instIndex].name();
1520 foundInstance =
io.instance();
1523 Pout<<
"masterUncollatedFileOperation::findInstance :" 1524 <<
" for name:" <<
io.name() <<
" local:" <<
io.local()
1525 <<
" found at:" <<
io.instance()
1532 if (
io.instance() == stopInstance)
1536 Pout<<
"masterUncollatedFileOperation::findInstance :" 1537 <<
" name:" <<
io.name()
1538 <<
" local:" <<
io.local()
1539 <<
" at stop-instance:" <<
io.instance() <<
endl;
1544 failed = failureCodes::FAILED_STOPINST;
1548 foundInstance =
io.instance();
1569 !failed && foundInstance.empty()
1570 && (ts.empty() || ts[0].name() != time.
constant() || startValue < 0)
1584 Pout<<
"masterUncollatedFileOperation::findInstance :" 1585 <<
" name:" <<
io.name()
1586 <<
" local:" <<
io.local()
1587 <<
" at:" <<
io.instance() <<
endl;
1589 foundInstance =
io.instance();
1593 if (!failed && foundInstance.empty())
1597 failed = failureCodes::FAILED_CONSTINST;
1611 io.instance() = foundInstance;
1620 if (!
io.name().empty())
1623 <<
" file \"" <<
io.name() <<
"\" in";
1628 <<
io.local() <<
" in times " 1629 << startIO.
instance() <<
" down to ";
1631 if (failed == failureCodes::FAILED_STOPINST)
1644 Pout<<
"masterUncollatedFileOperation::findInstance :" 1645 <<
" name:" <<
io.name() <<
" local:" <<
io.local()
1646 <<
" returning instance:" <<
io.instance() <<
endl;
1663 Pout<<
"masterUncollatedFileOperation::readObjects :" 1665 <<
" local:" <<
local <<
" instance:" << instance <<
endl;
1669 newInstance.clear();
1690 if (newInstance.empty())
1706 const instant t(instance);
1709 if (t.
equal(timeDirs[i].value()))
1731 Pout<<
"masterUncollatedFileOperation::readObjects :" 1732 <<
" newInstance:" << newInstance
1733 <<
" objectNames:" << objectNames <<
endl;
1744 const word& typeName
1751 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl 1752 <<
" objectPath:" <<
io.objectPath() <<
endl 1753 <<
" filePath :" << fName <<
endl;
1794 io.headerClassName(),
1818 result.resize(np,
false);
1819 headerClassName.resize(np);
1824 if (!filePaths[proci].empty())
1826 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1828 result[proci] = result[proci-1];
1829 headerClassName[proci] = headerClassName[proci-1];
1830 note[proci] = note[proci-1];
1834 IFstream is(filePaths[proci]);
1840 headerClassName[proci] =
io.headerClassName();
1841 note[proci] =
io.note();
1854 io.headerClassName() = headerClassName[0];
1855 io.note() = note[0];
1858 for (
const int proci : pBufs.subProcs())
1860 UOPstream
os(proci, pBufs);
1861 os << result[proci] << headerClassName[proci] << note[proci];
1865 pBufs.finishedScatters();
1870 is >> ok >>
io.headerClassName() >>
io.note();
1876 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1877 <<
" class:" <<
io.headerClassName()
1878 <<
" for file:" << fName <<
endl;;
1889 const word& typeName,
1890 const bool readOnProc
1895 Pout<<
"masterUncollatedFileOperation::readStream :" 1896 <<
" object : " <<
io.name()
1897 <<
" global : " <<
io.global()
1898 <<
" globalObject : " <<
io.globalObject()
1899 <<
" fName : " << fName <<
" readOnProc:" << readOnProc <<
endl;
1904 bool isCollated =
false;
1924 headerIO.readHeader(*isPtr);
1934 Pout<<
"masterUncollatedFileOperation::readStream :" 1935 <<
" For object : " <<
io.name()
1936 <<
" doing straight IFstream input from " 1958 Pout<<
"masterUncollatedFileOperation::readStream :" 1959 <<
" For object : " <<
io.name()
1960 <<
" starting collating input from " << fName <<
endl;
1969 procRangeType
group;
1978 label proci = detectProcessorPath(
io.objectPath());
1983 <<
"Could not detect processor number" 1984 <<
" from objectPath:" <<
io.objectPath()
1985 <<
" fileHandler : comm:" << comm_
1993 proci = proci -
group.start();
1998 Pout<<
"masterUncollatedFileOperation::readStream :" 1999 <<
" For object : " <<
io.name()
2000 <<
" starting input from block " << proci
2001 <<
" of " << isPtr->name() <<
endl;
2010 label readComm = -1;
2018 isPtr.
reset(
new IFstream(fName));
2023 IOobject headerIO(
io);
2024 headerIO.readHeader(*isPtr);
2035 bool bigSize =
false;
2043 > off_t(maxMasterFileBufferSize)
2072 Pout<<
"masterUncollatedFileOperation::readStream :" 2073 <<
" For object : " <<
io.name()
2074 <<
" starting separated input from " << fName <<
endl;
2077 if (
io.global() ||
io.globalObject())
2092 UPstream::listGatherValues<bool>
2119 UPstream::listGatherValues<bool>
2132 return read(
io, comm_, uniform, filePaths, readOnProcs);
2141 const bool masterOnly,
2143 const word& typeName
2148 if (
io.global() ||
io.globalObject())
2152 Pout<<
"masterUncollatedFileOperation::read :" 2153 <<
" Reading global object " <<
io.name()
2155 <<
" Pstream::myProcNo:" 2168 auto& is =
io.readStream(typeName);
2169 ok =
io.readData(is);
2183 io.headerClassName(),
2195 bool okWrite =
io.writeData(toAll);
2200 IPBstream fromMaster
2206 ok =
io.readData(fromMaster);
2214 Pout<<
"masterUncollatedFileOperation::read :" 2215 <<
" Reading local object " <<
io.name() <<
endl;
2218 ok =
io.readData(
io.readStream(typeName));
2224 Pout<<
"masterUncollatedFileOperation::read :" 2225 <<
" Read object:" <<
io.name()
2226 <<
" isGlobal:" << (
io.global() ||
io.globalObject())
2227 <<
" status:" << ok <<
endl;
2238 const bool writeOnProc
2245 Pout<<
"masterUncollatedFileOperation::writeObject :" 2246 <<
" io:" << pathName <<
" writeOnProc:" << writeOnProc <<
endl;
2263 &&
io.writeHeader(
os)
2279 const word& constantName
2282 const auto iter = times_.cfind(directory);
2287 Pout<<
"masterUncollatedFileOperation::findTimes :" 2288 <<
" Found " << iter.val()->size() <<
" cached times" <<
nl 2289 <<
" for directory:" << directory <<
endl;
2291 return *(iter.val());
2312 Pout<<
"masterUncollatedFileOperation::findTimes :" 2314 <<
" for directory:" << directory <<
endl;
2320 if (cacheLevel() > 0)
2322 auto* tPtr =
new DynamicList<instant>(std::move(times));
2323 times_.set(directory, tPtr);
2347 auto iter = times_.find(tm.
path());
2351 DynamicList<instant>& times = *(iter.val());
2356 const label startIdx =
2358 (times.empty() || times[0].name() != tm.
constant())
2367 if (times.size() <= startIdx || times.last() < timeNow)
2375 SubList<instant>(times, times.size()-startIdx, startIdx),
2382 Pout<<
"masterUncollatedFileOperation::setTime :" 2383 <<
" Caching time " << tm.
timeName()
2384 <<
" for case:" << tm.
path() <<
endl;
2387 times.append(timeNow);
2389 SubList<instant> realTimes
2391 times, times.size()-startIdx, startIdx
2429 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2430 <<
" Opening global file " << filePath <<
endl;
2446 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2447 <<
" Opening local file " << filePath
2448 <<
" for rank " << proci <<
endl;
2473 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2474 <<
" Reading " << filePath
2483 is.
read(buf.data(), buf.size());
2488 Pout<<
"masterUncollatedFileOperation::NewIFstream :" 2489 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2499 isPtr->name() = filePath;
2517 const bool writeOnProc
2540 const bool writeOnProc
2569 Pout<<
"masterUncollatedFileOperation::sync :" 2570 <<
" syncing information across processors" <<
endl;
2581 timeNames.
resize(times_.size());
2582 instants.
resize(times_.size());
2588 timeNames[i] = iter.key();
2589 instants[i] = std::move(*(iter.val()));
2599 fileName dir(timeNames[i]);
2600 auto ptr = autoPtr<DynamicList<instant>>
::New(std::move(instants[i]));
2608 procRangeType
group;
2610 const label proci = splitProcessorPath
2629 if (proci != -1 && proci != myProci)
2635 times_.insert(dir, ptr);
2648 watchFd = monitor().addWatch(fName);
2658 const label watchIndex
2664 ok = monitor().removeWatch(watchIndex);
2684 if (monitor().getFile(watchIndices[i]) == fName)
2710 const label index = findWatch(watchIndices,
f);
2714 newWatchIndices.
append(addWatch(
f));
2719 newWatchIndices.
append(watchIndices[index]);
2720 removedWatches.
erase(index);
2725 for (
const label index : removedWatches)
2727 removeWatch(watchIndices[index]);
2736 const label watchIndex
2742 fName = monitor().getFile(watchIndex);
2752 const bool masterOnly,
2758 monitor().updateStates(
true,
false);
2772 state = monitor().getState(watchFd);
2787 monitor().setUnmodified(watchFd);
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static const Enum< pathType > pathTypeNames_
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.
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.
static label read(const UPstream::commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr)
Read buffer contents from given processor.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
as PROCUNCOLLATED but with instance
masterUncollatedFileOperation(bool verbose=false)
Default construct.
void resize(const label len)
Adjust allocated size of list.
commsTypes
Communications types.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
void append(const T &val)
Append an element at the end of the list.
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolUList &readOnProcs)
Read files on comms master.
const word & name() const noexcept
Return the object name.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
fileState
Enumeration defining the file state.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
int infoDetailLevel
Global for selective suppression of Info output.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
constexpr char nl
The newline '\n' character (0x0a)
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
label findSortedIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
Binary search to find the index of the last element in a sorted list that is less than value...
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
void clear() noexcept
Same as reset(nullptr)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (MPI_AllReduce)
file found in time directory
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const
Reads header for regIOobject and returns an ISstream to read the contents.
void stableSort(UList< T > &list)
Stable sort the list.
static bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &contentChars, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
static int & msgType() noexcept
Message tag of standard messages.
label subCycling() const noexcept
Zero (tests as false) if time is not being sub-cycled, otherwise the current sub-cycle index or the t...
A simple container for options an IOstream can normally have.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
List< string > stringList
List of string.
UList< bool > boolUList
A UList of bools.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for managing references or pointers (no reference counting)
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
An encapsulation of filesystem-related operations.
fileName objectPath() const
The complete path + object name.
Macros for easy insertion into run-time selection tables.
as PROCOBJECT but with instance
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
UList< label > labelUList
A UList of labels.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all 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)
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Writes a regIOobject (so header, contents and divider).
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
atomicType
Atomic operations (output)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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.
static constexpr int masterNo() noexcept
Relative rank for the master process - is 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.
addNamedToRunTimeSelectionTable(fileOperationInitialise, fileOperationInitialise_collated, word, collated)
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
as PROCBASEOBJECT but with instance
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)
static void readAndSend(const fileName &filePath, const labelUList &recvProcs, PstreamBuffers &pBufs)
Read file contents and send to processors.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
static bool readHeader(IOobject &io, Istream &is)
Read header as per IOobject with additional handling of decomposedBlockData.
const Time & time() const noexcept
Return Time associated with the objectRegistry.
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.
virtual void sync()
Forcibly parallel sync.
static int cacheLevel() noexcept
Return cache level.
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.
label recvDataCount(const label proci) const
Number of unconsumed receive bytes for the specified processor. Must call finishedSends() or other fi...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
static fileCheckTypes fileModificationChecking
Type of file modification checking.
Input from file stream, using an ISstream.
static Tuple2< label, labelList > getCommPattern()
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static bool uniformFile(const fileNameList &names)
True if the file names are identical. False on an empty list.
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
const fileName & instance() const noexcept
Read access to instance path component.
virtual ~masterUncollatedFileOperation()
Destructor.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all 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
List of word.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual void sync()
Forcibly parallel sync.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const dirIndexList &pDirs, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
instantList times() const
Search the case for valid time directories.
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
virtual void setTime(const Time &) const
Callback for time change.
#define WarningInFunction
Report a warning using Foam::Warning.
static List< int > & procID(const label communicator)
The list of ranks within a given communicator.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
const T2 & second() const noexcept
Access the second element.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
"nonBlocking" : (MPI_Isend, MPI_Irecv)
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
defineTypeNameAndDebug(collatedFileOperation, 0)
List< label > labelList
A List of labels.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Registry of regIOobjects.
bool equal(scalar val) const noexcept
True if values are equal (includes SMALL for rounding)
const T1 & first() const noexcept
Access the first element.
virtual void setTime(const Time &) const
Callback for time change.
const fileName & local() const noexcept
Read access to local path component.
List< fileName > fileNameList
List of fileName.
#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.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is.
Type
Enumerations to handle directory entry types.
static label allocateCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Allocate new communicator with contiguous sub-ranks on the parent communicator.
Extract type (as a word) from an object, typically using its type() method.
forAllConstIters(mixture.phases(), phase)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...