57 "uncollatedProcInstance",
83 if (!monitorPtr_.valid())
101 const word& constantName
109 bool haveConstant =
false;
112 if (dirEntries[i] == constantName)
114 Times[nTimes].value() = 0;
115 Times[nTimes].name() = dirEntries[i];
126 if (
readScalar(dirEntries[i].c_str(), timeValue))
128 Times[nTimes].value() = timeValue;
129 Times[nTimes].name() = dirEntries[i];
156 const word& constantName,
160 if (extraTimes.
size())
165 && times[0].name() == constantName
168 bool haveExtraConstant =
170 extraTimes.
size() > 0
171 && extraTimes[0].name() == constantName
178 if (haveExtraConstant)
183 combinedTimes[sz++] = extraTimes[0];
188 combinedTimes[sz++] = times[i];
190 for (; extrai < extraTimes.
size(); extrai++)
192 combinedTimes[sz++] = extraTimes[extrai];
198 if (times.
size() > 1)
201 if (times[0].
name() == constantName)
208 label newi = starti+1;
209 for (
label i = newi; i < times.
size(); i++)
211 if (times[i].value() != times[i-1].value())
215 times[newi] = times[i];
249 splitProcessorPath(fName, path, pDir, local, gStart, gSz, numProcs);
256 procsDirs_.find(procPath);
258 if (iter != procsDirs_.end())
283 label rStart, rSize, rNum;
285 splitProcessorPath(dirN, rp, rd, rl, rStart, rSize, rNum);
286 maxProc =
max(maxProc, readProci);
288 if (proci == readProci)
300 else if (proci >= rStart && proci < rStart+rSize)
344 procsDirs_.insert(procPath, procDirs);
348 Pout<<
"fileOperation::lookupProcessorsPath : For:" << procPath
349 <<
" detected:" << procDirs <<
endl;
353 return procsDirs_[procPath];
367 if (io.
name().empty())
383 if (originalPath != objPath)
386 if (io.
name().empty())
388 ok =
isDir(originalPath);
417 wordConstructorTable::iterator cstrIter =
418 wordConstructorTablePtr_->find(type);
420 if (cstrIter == wordConstructorTablePtr_->end())
423 <<
"Unknown fileOperation type " 425 <<
"Valid fileOperation types are" <<
endl 426 << wordConstructorTablePtr_->sortedToc()
512 Pout<<
"fileOperation::filePath :" <<
" fName:" << fName <<
endl;
536 const fileName& procDir = procDirs()[i].first();
538 fileName collatedName(path/procDir/local);
543 Pout<<
"fileOperation::filePath : " << collatedName <<
endl;
554 Pout<<
"fileOperation::filePath : " << fName <<
endl;
562 Pout<<
"fileOperation::filePath : Not found" <<
endl;
589 if (
getFile(watchIndices[i]) == fName)
621 newWatchIndices.
append(watchIndices[index]);
622 removedWatches.
erase(index);
644 const bool masterOnly,
670 const word& constantName
675 Pout<<
"fileOperation::findTimes : Finding times in directory " 676 << directory <<
endl;
696 const fileName& procDir = procDirs()[i].first();
698 if (!collDir.empty() && collDir !=
directory)
719 Pout<<
"fileOperation::findTimes : Found times:" << times <<
endl;
728 const scalar startValue,
729 const word& stopInstance
747 <<
"Found exact match for \"" << io.
name()
761 for (instanceI = ts.
size()-1; instanceI >= 0; --instanceI)
763 if (ts[instanceI].value() <= startValue)
770 for (; instanceI >= 0; --instanceI)
776 && ts[instanceI].name() != stopInstance
782 io.
instance() = ts[instanceI].name();
788 <<
"Found exact match for \"" << io.
name()
797 if (ts[instanceI].
name() == stopInstance)
802 <<
"Hit stopInstance " << stopInstance <<
endl;
811 if (io.
name().empty())
814 <<
"Cannot find directory " 816 <<
" down to " << stopInstance
822 <<
"Cannot find file \"" << io.
name()
823 <<
"\" in directory " << io.
local()
824 <<
" in times " << startIO.
instance()
825 <<
" down to " << stopInstance
851 <<
"Found constant match for \"" << io.
name()
867 <<
"Cannot find file \"" << io.
name() <<
"\" in directory " 887 Pout<<
"fileOperation::readObjects :" 889 <<
" instance:" << instance <<
endl;
899 newInstance = instance;
907 if (!procsPath.empty())
909 newInstance = instance;
974 <<
" to determine the number of decompositions." 975 <<
" Returning 1" <<
endl;
988 Pout<<
"fileOperation::flush : clearing processor directories cache" 1008 const word& instance,
1009 const word& procsDir
1023 const word& procsDir
1032 if (caseName.size() <= 9 || caseName[9] ==
's')
1035 <<
" does not end in old-style processorDDD" <<
endl;
1038 return dir.
path()/procsDir;
1073 if (pos == string::npos)
1083 if (pos > 0 && objectPath[pos-1] !=
'/')
1094 path = objectPath.substr(0, pos-1);
1095 procDir = objectPath.substr(pos);
1099 pos = procDir.find(
'/');
1100 if (pos != string::npos)
1102 local = procDir.substr(pos+1);
1103 procDir = procDir.substr(0, pos);
1115 if (
f.size() &&
f[0] ==
's')
1125 if (fromStart != string::npos && toStart != string::npos)
1127 string nProcsName(
f.substr(0, fromStart));
1128 string fromName(
f.substr(fromStart+1, toStart-(fromStart+1)));
1129 string toName(
f.substr(toStart+1));
1131 label groupEnd = -1;
1139 groupSize = groupEnd-groupStart+1;
1185 if (!handler.size())
1202 newHandlerPtr.
valid()
1211 if (newHandlerPtr.
valid())
1224 if (files[i] == file)
1226 return directory/
file;
1253 cp(srcDir/srcFiles[filei], targetDir);
pathType
Enumeration for the location of an IOobject.
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.
const word & name() const
Return name.
bool typeHeaderOk(const bool checkType=true)
Read header (uses typeFilePath to find file) and check header.
A class for handling file names.
An STL-conforming const_iterator.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Checking for changes to files.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
void cpFiles(const fileName &srcDir, const fileName &targetDir)
Copy all the files from the source to the target directory.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
fileState getState(const label watchFd) const
Check state using handle.
fileState
Enumeration defining the file state.
void setUnmodified(const label watchFd)
Reset state (e.g. after having read it) using handle.
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 bool mkDir(const fileName &, mode_t=0777) const =0
Make directory.
bool exists(IOobject &io) const
Does ioobject exist. Is either a directory (empty name()) or.
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.
static bool master(const label communicator=0)
Am I the master process.
const labelList & watchIndices() const
Return file-monitoring handles.
virtual ~fileOperation()
Destructor.
static int & msgType()
Message tag of standard messages.
tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
iterator end()
Return an iterator to end traversing the UList.
Initialise the NamedEnum HashTable from the static list of names.
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool less(const vector &x, const vector &y)
To compare normals.
bool good() const
Return true if next operation might succeed.
virtual autoPtr< Ostream > NewOFstream(const fileName &filePath, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const =0
Generate an Ostream that writes a file.
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.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
dimensionedScalar pos(const dimensionedScalar &ds)
virtual fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true) const =0
Read a directory and return the entries as a string list.
bool read(const char *, int32_t &)
bool removeWatch(const label watchFd)
Remove file to watch. Return true if successful.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
void updateStates(const bool masterOnly, const bool syncPar) const
Check state of all files. Updates state_.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
const fileName & getFile(const label watchFd) const
Get name of file being watched.
const fileName & local() const
const word & constant() const
Return constant name.
regionProperties rp(runTime)
word name() const
Return file name (part beyond last /)
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 successful.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
graph_traits< Graph >::vertices_size_type size_type
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)
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
compressionType
Enumeration for the format of data in the stream.
static word processorsBaseDir
Return the processors directory name (usually "processors")
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual bool writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const
Writes a regIOobject (so header, contents and divider).
const fileName & globalCaseName() const
Return global case name.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
fileOperation(const label comm)
Construct null.
defineTypeNameAndDebug(combustionModel, 0)
static fileCheckTypes fileModificationChecking
Type of file modification checking.
fileMonitor & monitor() const
HashTable< dirIndexList > procsDirs_
Detected processors directories.
word name(const complex &)
Return a string representation of a complex.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
A class for managing temporary objects without reference counting.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
const fileName & rootPath() const
void setSize(const label)
Reset size of List.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
static bool & parRun()
Is this a parallel run?
const fileName & instance() const
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.
label addWatch(const fileName &)
Add file to watch. Return watch descriptor.
const Time & time() const
Return time.
prefixOSstream Pout(cout, "Pout")
static instantList sortTimes(const fileNameList &, const word &)
Sort directory entries according to time value.
instantList times() const
Search the case for valid time directories.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool writeHeader(Ostream &) const
Write header.
const label comm_
Communicator to use.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
fileName path() const
Return directory path name (part before last /)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
static label detectProcessorPath(const fileName &)
Detect processor number from '/aa/bb/processorDDD/cc'.
Registry of regIOobjects.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
const objectRegistry & db() const
Return the local objectRegistry.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
readOption readOpt() const
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static const NamedEnum< pathType, 12 > pathTypeNames_
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
static label splitProcessorPath(const fileName &, fileName &path, fileName &procDir, fileName &local, label &groupStart, label &groupSize, label &nProcs)
Split fileName into part before 'processor' and part after.
fileName objectPath() const
Return complete path + object name.
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
fileName path(UMean.rootPath()/UMean.caseName()/functionObjects::writeFile::outputPrefix/"graphs"/UMean.instance())
#define InfoInFunction
Report an information message using Foam::Info.