55 "override the fileHandler" 82 if (!monitorPtr_.valid())
100 const word& constantName
108 bool haveConstant =
false;
111 if (dirEntries[i] == constantName)
113 Times[nTimes].value() = 0;
114 Times[nTimes].name() = dirEntries[i];
129 if (
readScalar(dirEntries[i].c_str(), timeValue))
131 Times[nTimes].value() = timeValue;
132 Times[nTimes].name() = dirEntries[i];
181 wordConstructorTable::iterator cstrIter =
182 wordConstructorTablePtr_->find(type);
184 if (cstrIter == wordConstructorTablePtr_->end())
187 <<
"Unknown fileOperation type " 189 <<
"Valid fileOperation types are" <<
endl 190 << wordConstructorTablePtr_->sortedToc()
229 mkDir(pathName.path());
290 fileName procsName(path/processorsDir/local);
293 if (proci != -1 &&
exists(procsName))
310 return monitor().addWatch(fName);
316 return monitor().removeWatch(watchIndex);
328 if (getFile(watchIndices[i]) == fName)
351 label index = findWatch(watchIndices, f);
355 newWatchIndices.
append(addWatch(f));
360 newWatchIndices.
append(watchIndices[index]);
361 removedWatches.
erase(index);
368 removeWatch(watchIndices[iter.key()]);
377 return monitor().getFile(watchIndex);
383 const bool masterOnly,
396 return monitor().getState(watchFd);
402 monitor().setUnmodified(watchFd);
409 const word& constantName
415 <<
" : Finding times in directory " << directory <<
endl;
428 instantList times = sortTimes(dirEntries, constantName);
439 if (!procsDir.empty() && procsDir != directory)
450 instantList extraTimes = sortTimes(extraEntries, constantName);
452 if (extraTimes.
size())
457 && times[0].name() == constantName
460 bool haveExtraConstant =
462 extraTimes.
size() > 0
463 && extraTimes[0].name() == constantName
470 if (haveExtraConstant)
475 combinedTimes[sz++] = extraTimes[0];
480 combinedTimes[sz++] = times[i];
482 for (; extrai < extraTimes.
size(); extrai++)
484 combinedTimes[sz++] = extraTimes[extrai];
490 if (times.
size() > 1)
493 if (times[0].
name() == constantName)
500 label newi = starti+1;
501 for (
label i = newi; i < times.
size(); i++)
503 if (times[i].value() != times[i-1].value())
507 times[newi] = times[i];
521 <<
" : Found times:" << times <<
endl;
537 Pout<<
"fileOperation::readObjects :" 539 <<
" instance:" << instance <<
endl;
549 newInstance = instance;
565 fileName procsPath(prefix/processorsDir/postfix);
569 newInstance = instance;
602 <<
" to determine the number of decompositions." 603 <<
" Falling back to looking for processor.*" <<
endl;
629 if (!fileOperation::fileHandlerPtr_.valid())
646 if (fileOperation::fileHandlerPtr_.valid())
650 newHandlerPtr.
valid()
651 && newHandlerPtr->type() == fileOperation::fileHandlerPtr_->type()
657 fileOperation::fileHandlerPtr_.clear();
659 if (newHandlerPtr.
valid())
661 fileOperation::fileHandlerPtr_ = newHandlerPtr;
virtual bool writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
string getEnv(const word &)
Return environment variable of given name.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
fileOperation()
Construct null.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
Checking for changes to files.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
fileState
Enumeration defining the file state.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void size(const label)
Override size to be inconsistent with allocated storage.
static const fileName null
An empty fileName.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
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 label numBlocks(const fileName &)
Detect number of blocks in a file.
const labelList & watchIndices() const
Return file-monitoring handles.
virtual ~fileOperation()
Destructor.
iterator end()
Return an iterator to end traversing the UList.
static bool less(const vector &x, const vector &y)
To compare normals.
bool good() const
Return true if next operation might succeed.
fileName path() const
Return complete path.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
static autoPtr< fileOperation > New(const word &type, const bool verbose)
Select type.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
static label splitProcessorPath(const fileName &, fileName &path, fileName &local)
Split fileName into part before processor and part after.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
A class for handling words, derived from string.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
streamFormat
Enumeration for the format of data in the stream.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static const word null
An empty word.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName) const =0
Search for an object. checkGlobal : also check undecomposed case.
const fileOperation & fileHandler()
Get current file handler.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
compressionType
Enumeration for the format of data in the stream.
bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static word processorsDir
Return the processors directory name (usually "processors")
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
defineTypeNameAndDebug(combustionModel, 0)
static fileCheckTypes fileModificationChecking
Type of file modification checking.
fileMonitor & monitor() const
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
word name(const complex &)
Return a string representation of a complex.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
void setSize(const label)
Reset size of List.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
static bool & parRun()
Is this a parallel run?
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
static word defaultFileHandler
Default fileHandler.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
static fileName processorsPath(const IOobject &, const word &)
Like io.path with provided instance and any 'processorXXX'.
static instantList sortTimes(const fileNameList &, const word &)
Sort directory entries according to time value.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool writeHeader(Ostream &) const
Write header.
fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a string list.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
Registry of regIOobjects.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
fileName objectPath() const
Return complete path + object name.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
#define InfoInFunction
Report an information message using Foam::Info.