Go to the documentation of this file.
48 namespace fileOperations
54 masterUncollatedFileOperation,
64 "maxMasterFileBufferSize",
73 masterUncollatedFileOperationInitialise,
88 string ioRanksString(
getEnv(
"FOAM_IORANKS"));
89 if (ioRanksString.empty())
100 if (!ioRanks.found(0))
103 <<
"Rank 0 (master) should be in the IO ranks. Currently "
108 const bitSet isIOrank(
n, ioRanks);
110 for (label proci = Pstream::myProcNo(); proci >= 0; --proci)
118 label rank = proci+1;
119 rank <
n && !isIOrank[rank];
148 if (t.
equal(timeDirs[i].value()))
150 return timeDirs[i].name();
161 const bool checkGlobal,
167 word& newInstancePath
170 procsDir = word::null;
171 newInstancePath = word::null;
177 if (isFileOrDir(
isFile, objPath))
179 searchType = fileOperation::ABSOLUTE;
184 searchType = fileOperation::NOTFOUND;
185 return fileName::null;
193 if (isFileOrDir(
isFile, writePath))
195 searchType = fileOperation::WRITEOBJECT;
205 const fileName& pDir = pDirs()[i].first();
207 processorsPath(io, io.
instance(), pDir)
209 if (objPath != writePath && isFileOrDir(
isFile, objPath))
211 searchType = pDirs()[i].second().first();
223 localPath != writePath
224 && isFileOrDir(
isFile, localPath)
227 searchType = fileOperation::OBJECT;
249 if (isFileOrDir(
isFile, parentPath))
251 searchType = fileOperation::PARENTOBJECT;
258 const auto pathFnd = times_.cfind(io.
time().
path());
260 if (
search && pathFnd.found())
262 newInstancePath = findInstancePath
268 if (newInstancePath.size() && newInstancePath != io.
instance())
277 const fileName& pDir = pDirs()[i].first();
281 processorsPath(io, newInstancePath, pDir)
284 if (isFileOrDir(
isFile, fName))
286 switch (pDirs()[i].second().first())
288 case fileOperation::PROCUNCOLLATED:
291 fileOperation::PROCUNCOLLATEDINSTANCE;
294 case fileOperation::PROCBASEOBJECT:
296 searchType = fileOperation::PROCBASEINSTANCE;
299 case fileOperation::PROCOBJECT:
301 searchType = fileOperation::PROCINSTANCE;
319 if (isFileOrDir(
isFile, fName))
321 searchType = fileOperation::FINDINSTANCE;
327 searchType = fileOperation::NOTFOUND;
328 return fileName::null;
339 const word& instancePath
346 case fileOperation::ABSOLUTE:
352 case fileOperation::OBJECT:
358 case fileOperation::WRITEOBJECT:
364 case fileOperation::PROCUNCOLLATED:
369 "processor" +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
386 case fileOperation::PROCBASEOBJECT:
390 processorsPath(io, io.
instance(), procDir)
395 case fileOperation::PROCOBJECT:
399 processorsPath(io, io.
instance(), processorsDir(io))
404 case fileOperation::PARENTOBJECT:
412 case fileOperation::FINDINSTANCE:
420 case fileOperation::PROCUNCOLLATEDINSTANCE:
426 +
Foam::name(Pstream::myProcNo(Pstream::worldComm))
443 case fileOperation::PROCBASEINSTANCE:
447 processorsPath(io, instancePath, procDir)
452 case fileOperation::PROCINSTANCE:
456 processorsPath(io, instancePath, processorsDir(io))
461 case fileOperation::NOTFOUND:
463 return fileName::null;
470 return fileName::null;
481 const fileName& object0 = filePaths[0];
483 for (label i = 1; i < filePaths.size(); i++)
485 if (filePaths[i] != object0)
501 IFstream ifs(filePath, IOstream::streamFormat::BINARY);
506 <<
"Cannot open file " << filePath
512 Pout<<
"masterUncollatedFileOperation::readAndSend :"
517 if (ifs.
compression() == IOstream::compressionType::COMPRESSED)
523 const std::string buf
525 std::istreambuf_iterator<char>(ifs.
stdStream()),
526 std::istreambuf_iterator<char>()
529 for (
const label proci : procs)
532 os.
write(buf.data(), buf.length());
537 Pout<<
"masterUncollatedFileOperation::readStream :"
538 <<
" From " << filePath <<
" sent " << buf.size()
550 for (
const label proci : procs)
558 Pout<<
"masterUncollatedFileOperation::readStream :"
559 <<
" From " << filePath <<
" sent " << buf.size()
582 Pstream::commsTypes::nonBlocking,
587 if (Pstream::master(comm))
593 if (filePaths[0].empty())
604 proci < Pstream::nProcs(comm);
608 if (procValid[proci])
618 Pout<<
"masterUncollatedFileOperation::readStream :"
619 <<
" For uniform file " << filePaths[0]
620 <<
" sending to " << validProcs
621 <<
" in comm:" << comm <<
endl;
623 readAndSend(filePaths[0], validProcs, pBufs);
630 if (filePaths[0].empty())
644 <<
"problem while reading header for object "
653 proci < Pstream::nProcs(comm);
659 Pout<<
"masterUncollatedFileOperation::readStream :"
660 <<
" For processor " << proci
661 <<
" opening " << filePaths[proci] <<
endl;
664 const fileName& fPath = filePaths[proci];
666 if (procValid[proci] && !fPath.empty())
670 readAndSend(fPath,
labelList(1, proci), pBufs);
683 if (procValid[Pstream::myProcNo(comm)])
689 UIPstream is(Pstream::masterNo(), pBufs);
691 List<char> buf(recvSizes[Pstream::masterNo()]);
692 if (recvSizes[Pstream::masterNo()] > 0)
694 is.
read(buf.data(), recvSizes[Pstream::masterNo()]);
699 Pout<<
"masterUncollatedFileOperation::readStream :"
700 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
710 isPtr->name() = filePaths[Pstream::myProcNo(comm)];
715 <<
"problem while reading header for object "
739 UPstream::allocateCommunicator
742 subRanks(Pstream::nProcs())
752 <<
"I/O : " << typeName
753 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
757 if (regIOobject::fileModificationChecking == regIOobject::timeStampMaster)
762 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
764 regIOobject::fileModificationChecking = regIOobject::timeStamp;
768 regIOobject::fileModificationChecking
769 == regIOobject::inotifyMaster
775 <<
"Resetting fileModificationChecking to inotify"
778 regIOobject::fileModificationChecking = regIOobject::inotify;
798 <<
"I/O : " << typeName
799 <<
" (maxMasterFileBufferSize " << maxMasterFileBufferSize <<
')'
803 if (regIOobject::fileModificationChecking == regIOobject::timeStampMaster)
808 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
810 regIOobject::fileModificationChecking = regIOobject::timeStamp;
814 regIOobject::fileModificationChecking
815 == regIOobject::inotifyMaster
821 <<
"Resetting fileModificationChecking to inotify"
824 regIOobject::fileModificationChecking = regIOobject::inotify;
835 const string s(
"-ioRanks");
838 for (
int i=1; i<argc-1; i++)
843 setEnv(
"FOAM_IORANKS", argv[i+1],
true);
850 for (
int i=index+2; i<argc; i++)
879 return masterOp<mode_t, mkDirOp>
895 return masterOp<mode_t, chModOp>
908 const bool followLink
911 return masterOp<mode_t, modeOp>
924 const bool followLink
929 masterOp<label, typeOp>
943 const bool checkGzip,
944 const bool followLink
947 return masterOp<bool, existsOp>
960 const bool followLink
963 return masterOp<bool, isDirOp>
976 const bool checkGzip,
977 const bool followLink
980 return masterOp<bool, isFileOp>
993 const bool followLink
996 return masterOp<off_t, fileSizeOp>
1009 const bool followLink
1012 return masterOp<time_t, lastModifiedOp>
1025 const bool followLink
1028 return masterOp<double, lastModifiedHROp>
1041 const std::string& ext
1044 return masterOp<bool, mvBakOp>
1059 return masterOp<bool, rmOp>
1075 return masterOp<bool, rmDirOp>
1089 const bool filtergz,
1090 const bool followLink
1093 return masterOp<fileNameList, readDirOp>
1107 const bool followLink
1110 return masterOp<bool, cpOp>
1127 return masterOp<bool, lnOp>
1142 const bool followLink
1145 return masterOp<bool, mvOp>
1158 const bool checkGlobal,
1160 const word& typeName,
1166 Pout<<
"masterUncollatedFileOperation::filePath :"
1168 <<
" checkGlobal:" << checkGlobal <<
endl;
1184 word newInstancePath;
1204 Pout<<
"masterUncollatedFileOperation::filePath :"
1205 <<
" master objPath:" << objPath
1207 <<
" procsDir:" << procsDir <<
" instance:" << newInstancePath
1217 label masterType(searchType);
1229 || io.
local() ==
"uniform"
1262 objPath = localObjectPath
1278 objPath = masterOp<fileName, fileOrNullOp>
1292 Pout<<
"masterUncollatedFileOperation::filePath :"
1293 <<
" Returning from file searching:" <<
endl
1295 <<
" filePath :" << objPath <<
endl <<
endl;
1303 const bool checkGlobal,
1310 Pout<<
"masterUncollatedFileOperation::dirPath :"
1312 <<
" checkGlobal:" << checkGlobal <<
endl;
1324 word newInstancePath;
1328 objPath = filePathInfo
1341 label masterType(searchType);
1353 || io.
local() ==
"uniform"
1386 objPath = localObjectPath
1402 objPath = masterOp<fileName, fileOrNullOp>
1416 Pout<<
"masterUncollatedFileOperation::dirPath :"
1417 <<
" Returning from file searching:" <<
endl
1419 <<
" filePath :" << objPath <<
endl <<
endl;
1440 if (isFileOrDir(
isFile, writePath))
1450 const fileName& pDir = pDirs[i].first();
1452 processorsPath(io, io.
instance(), pDir)
1454 if (procPath != writePath && isFileOrDir(
isFile, procPath))
1464 if (localPath != writePath && isFileOrDir(
isFile, localPath))
1477 const scalar startValue,
1478 const word& stopInstance
1483 Pout<<
"masterUncollatedFileOperation::findInstance :"
1484 <<
" Starting searching for name:" << startIO.
name()
1485 <<
" local:" << startIO.
local()
1486 <<
" from instance:" << startIO.
instance()
1518 if (!foundInstance.empty())
1523 Pout<<
"masterUncollatedFileOperation::findInstance :"
1524 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1525 <<
" found starting instance:" << io.
instance() <<
endl;
1540 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
1542 if (ts[instanceI].value() <= startValue)
1549 for (; instanceI >= 0; --instanceI)
1558 io.
instance() = ts[instanceI].name();
1564 Pout<<
"masterUncollatedFileOperation::findInstance :"
1565 <<
" for name:" << io.
name() <<
" local:" << io.
local()
1573 if (ts[instanceI].
name() == stopInstance)
1581 if (io.
name().empty())
1584 <<
"Cannot find directory "
1586 <<
" down to " << stopInstance
1592 <<
"Cannot find file \"" << io.
name()
1593 <<
"\" in directory " << io.
local()
1595 <<
" down to " << stopInstance
1602 Pout<<
"masterUncollatedFileOperation::findInstance :"
1603 <<
" name:" << io.
name() <<
" local:" << io.
local()
1611 if (foundInstance.empty())
1618 if (!ts.size() || ts[0].name() != time.
constant())
1629 Pout<<
"masterUncollatedFileOperation::findInstance :"
1630 <<
" name:" << io.
name()
1631 <<
" local:" << io.
local()
1639 if (foundInstance.empty())
1648 <<
"Cannot find file \"" << io.
name() <<
"\" in directory "
1665 Pout<<
"masterUncollatedFileOperation::findInstance :"
1666 <<
" name:" << io.
name() <<
" local:" << io.
local()
1684 Pout<<
"masterUncollatedFileOperation::readObjects :"
1686 <<
" local:" << local <<
" instance:" << instance <<
endl;
1711 if (newInstance.empty())
1730 if (t.
equal(timeDirs[i].value()))
1752 Pout<<
"masterUncollatedFileOperation::readObjects :"
1753 <<
" newInstance:" << newInstance
1754 <<
" objectNames:" << objectNames <<
endl;
1765 const word& typeName
1772 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
endl
1774 <<
" fName :" << fName <<
endl;
1781 bool uniform = uniformFile(filePaths);
1829 if (!filePaths[proci].empty())
1831 if (proci > 0 && filePaths[proci] == filePaths[proci-1])
1833 result[proci] = result[proci-1];
1834 headerClassName[proci] = headerClassName[proci-1];
1835 note[proci] = note[proci-1];
1847 == decomposedBlockData::typeName
1860 note[proci] = io.
note();
1878 Pout<<
"masterUncollatedFileOperation::readHeader :" <<
" ok:" << ok
1890 const word& typeName,
1896 Pout<<
"masterUncollatedFileOperation::readStream :"
1897 <<
" object : " << io.
name()
1898 <<
" global : " << io.
global()
1899 <<
" fName : " << fName <<
" valid:" << valid <<
endl;
1904 bool isCollated =
false;
1936 Pout<<
"masterUncollatedFileOperation::readStream :"
1937 <<
" For object : " << io.
name()
1938 <<
" doing straight IFstream input from "
1960 Pout<<
"masterUncollatedFileOperation::readStream :"
1961 <<
" For object : " << io.
name()
1962 <<
" starting collating input from " << fName <<
endl;
1968 label groupStart, groupSize, nProcs;
1985 label proci = detectProcessorPath(io.
objectPath());
1990 <<
"Could not detect processor number"
1998 if (groupStart != -1 && groupSize > 0)
2000 proci = proci-groupStart;
2005 Pout<<
"masterUncollatedFileOperation::readStream :"
2006 <<
" For object : " << io.
name()
2007 <<
" starting input from block " << proci
2008 <<
" of " << isPtr->name() <<
endl;
2017 bool bigSize = sz > off_t(maxMasterFileBufferSize);
2022 label readComm = -1;
2023 if (groupStart != -1 && groupSize > 0)
2065 Pout<<
"masterUncollatedFileOperation::readStream :"
2066 <<
" For object : " << io.
name()
2067 <<
" starting separated input from " << fName <<
endl;
2094 const bool uniform = uniformFile(filePaths);
2096 return read(io, comm_,
uniform, filePaths, procValid);
2105 const bool masterOnly,
2107 const word& typeName
2116 Pout<<
"masterUncollatedFileOperation::read :"
2117 <<
" Reading global object " << io.
name() <<
endl;
2127 ok = io.
readData(io.readStream(typeName));
2158 if (myComm.
above() != -1)
2178 myComm.
below()[belowI],
2192 Pout<<
"masterUncollatedFileOperation::read :"
2193 <<
" Reading local object " << io.
name() <<
endl;
2196 ok = io.
readData(io.readStream(typeName));
2215 Pout<<
"masterUncollatedFileOperation::writeObject :"
2216 <<
" io:" << pathName <<
" valid:" << valid <<
endl;
2251 const word& constantName
2254 const auto iter = times_.cfind(directory);
2259 Pout<<
"masterUncollatedFileOperation::findTimes :"
2260 <<
" Found " << iter()->size() <<
" cached times" <<
endl;
2282 times_.set(directory, tPtr);
2286 Pout<<
"masterUncollatedFileOperation::findTimes :"
2287 <<
" Caching times:" << *tPtr <<
nl
2288 <<
" for directory:" << directory <<
endl;
2317 const label skipConst =
2319 (!times.empty() && times[0].name() == tm.
constant())
2336 Pout<<
"masterUncollatedFileOperation::setTime :"
2337 <<
" Caching time " << tm.
timeName()
2338 <<
" for case:" << tm.
path() <<
endl;
2344 times, times.size()-skipConst, skipConst
2380 const bool uniform = uniformFile(filePaths);
2386 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2387 <<
" Opening global file " << filePath <<
endl;
2429 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2430 <<
" Reading " << filePath
2437 is.
read(buf.data(), buf.size());
2441 Pout<<
"masterUncollatedFileOperation::NewIFstream :"
2442 <<
" Done reading " << buf.size() <<
" bytes" <<
endl;
2452 isPtr->name() = filePath;
2501 watchFd = monitor().addWatch(fName);
2510 const label watchIndex
2516 ok = monitor().removeWatch(watchIndex);
2535 if (monitor().getFile(watchIndices[i]) == fName)
2560 const label index = findWatch(watchIndices,
f);
2564 newWatchIndices.
append(addWatch(
f));
2569 newWatchIndices.
append(watchIndices[index]);
2570 removedWatches.
erase(index);
2575 for (
const label index : removedWatches)
2577 removeWatch(watchIndices[index]);
2586 const label watchIndex
2592 fName = monitor().getFile(watchIndex);
2601 const bool masterOnly,
2607 monitor().updateStates(
true,
false);
2621 state = monitor().getState(watchFd);
2635 monitor().setUnmodified(watchFd);
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
int debug
Static debugging option.
List< label > labelList
A List of labels.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or LINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
const fileName & globalCaseName() const
Return global case name.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual void setTime(const Time &) const
Callback for time change.
static void readAndSend(const fileName &filePath, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
static constexpr int masterNo() noexcept
Process index of the master.
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?
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const word & name() const
Return name.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
A class for handling words, derived from Foam::string.
An encapsulation of filesystem-related operations.
Output inter-processor communications stream operating on external buffer.
A class for handling file names.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
static bool uniformFile(const fileNameList &)
Same file?
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.
const labelList & watchIndices() const
Return file-monitoring handles.
Input from file stream, using an ISstream.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
Output inter-processor communications stream.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
virtual bool writeData(Ostream &) const =0
Pure virtual writeData function.
Dummy input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream....
A List obtained as a section of another List.
const fileName & rootPath() const
const fileName & instance() const
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const Time & time() const
Return time.
static bool & parRun()
Is this a parallel run?
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?
static word timeName(const scalar t, const int precision=precision_)
static const Enum< pathType > pathTypeNames_
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
Type
Enumerations to handle directory entry types.
virtual bool global() const
Is object global.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
fileState
Enumeration defining the file state.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
An ISstream with internal List storage.
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
const Type & value() const
Return const reference to value.
bool equal(scalar val) const
True if values are equal (includes SMALL for rounding)
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
const Time & time() const
Return time.
List< instant > instantList
List of instants.
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
masterUncollatedFileOperationInitialise(int &argc, char **&argv)
Construct from components.
string getEnv(const std::string &envName)
Get environment value for given envName.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
virtual ~masterUncollatedFileOperation()
Destructor.
#define forAll(list, i)
Loop across all elements in list.
void stableSort(UList< T > &a)
bool readHeader(Istream &is)
Read header.
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
registerOptSwitch("maxThreadFileBufferSize", float, collatedFileOperation::maxThreadFileBufferSize)
const objectRegistry & db() const
Return the local objectRegistry.
Registry of regIOobjects.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const
Reads header for regIOobject and returns an ISstream.
word format(conversionProperties.get< word >("format"))
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolList &procValid)
Read files on comms master.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
const fileName & local() const
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
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.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
A class for managing temporary objects without reference counting.
pathType
Enumeration for the location of an IOobject.
word name(const complex &c)
Return string representation of complex.
virtual void setTime(const Time &) const
Callback for time change.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
const fileName & caseName() const
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
bool globalObject() const
Is object same for all processors?
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
instantList times() const
Search the case for valid time directories.
The IOstreamOption is a simple container for options an IOstream can normally have.
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
Generic output stream using a standard (STL) stream.
label findSortedIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
masterUncollatedFileOperation(bool verbose)
Construct null.
streamFormat
Data format (ascii | binary)
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
Macros for easy insertion into run-time selection tables.
Input from string buffer, using a ISstream.
virtual bool rmDir(const fileName &dir, const bool silent=false) const
Remove a directory and its contents.
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.
int infoDetailLevel
Global for selective suppression of Info output.
Structure for communicating between processors.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
const word & headerClassName() const
Return name of the class name read from header.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
static bool master(const label communicator=0)
Am I the master process.
static int nProcsSimpleSum
virtual std::istream & stdStream()
Access to underlying std::istream.
const string & note() const
Return the optional note.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
const word & system() const
Return system name.
static int & msgType()
Message tag of standard messages.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
static bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &data, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
fileName path() const
Return path.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
void close()
Close Istream.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label worldComm
Default communicator (all processors)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
readOption readOpt() const
The read option.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
static const word null
An empty word.
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?
void clear() noexcept
Same as reset(nullptr)
#define forAllReverse(list, i)
Reverse loop across all elements in list.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
virtual bool readData(Istream &)
Virtual readData function.
Input inter-processor communications stream.
bool writeHeader(Ostream &os) const
Write header.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An instant of time. Contains the time value and name.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
Input inter-processor communications stream operating on external buffer.
static const List< commsStruct > & linearCommunication(const label communicator=0)
Communication schedule for linear all-to-master (proc 0)
bool good() const
Return true if next operation might succeed.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
fileName objectPath() const
The complete path + object name.
bool processorCase() const
Return true if this is a processor case.
compressionType compression() const noexcept
Get the stream compression.
void setSize(const label newSize)
Alias for resize(const label)
const word & constant() const
Return constant name.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
typename parent_type::iterator iterator
fileName path() const
The complete path.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
#define WarningInFunction
Report a warning using Foam::Warning.
static labelList subRanks(const label n)
Get the list of processors that are part of this communicator.
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
Master-only drop-in replacement for OFstream.
defineTypeNameAndDebug(collatedFileOperation, 0)
const labelList & below() const
static const List< commsStruct > & treeCommunication(const label communicator=0)
Communication schedule for tree all-to-master (proc 0)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.