62 "uncollatedProcInstance",
88 if (!monitorPtr_.valid())
106 const word& constantName
114 bool haveConstant =
false;
117 if (dirEntries[i] == constantName)
119 Times[nTimes].value() = 0;
120 Times[nTimes].name() = dirEntries[i];
131 if (
readScalar(dirEntries[i].c_str(), timeValue))
133 Times[nTimes].value() = timeValue;
134 Times[nTimes].name() = dirEntries[i];
161 const word& constantName,
165 if (extraTimes.
size())
170 && times[0].name() == constantName
173 bool haveExtraConstant =
175 extraTimes.
size() > 0
176 && extraTimes[0].name() == constantName
183 if (haveExtraConstant)
188 combinedTimes[sz++] = extraTimes[0];
193 combinedTimes[sz++] = times[i];
195 for (; extrai < extraTimes.
size(); extrai++)
197 combinedTimes[sz++] = extraTimes[extrai];
203 if (times.
size() > 1)
206 if (times[0].
name() == constantName)
213 label newi = starti+1;
214 for (
label i = newi; i < times.
size(); i++)
216 if (times[i].value() != times[i-1].value())
220 times[newi] = times[i];
254 splitProcessorPath(fName, path, pDir, local, gStart, gSz, numProcs);
261 procsDirs_.find(procPath);
263 if (iter != procsDirs_.end())
288 label rStart, rSize, rNum;
290 splitProcessorPath(dirN, rp, rd, rl, rStart, rSize, rNum);
291 maxProc =
max(maxProc, readProci);
293 if (proci == readProci)
305 else if (proci >= rStart && proci < rStart+rSize)
349 procsDirs_.insert(procPath, procDirs);
353 Pout<<
"fileOperation::lookupProcessorsPath : For:" << procPath
354 <<
" detected:" << procDirs <<
endl;
358 return procsDirs_[procPath];
372 if (io.
name().empty())
388 if (originalPath != objPath)
391 if (io.
name().empty())
393 ok =
isDir(originalPath);
422 wordConstructorTable::iterator cstrIter =
423 wordConstructorTablePtr_->find(type);
425 if (cstrIter == wordConstructorTablePtr_->end())
428 <<
"Unknown fileOperation type " 430 <<
"Valid fileOperation types are" <<
endl 431 << wordConstructorTablePtr_->sortedToc()
470 mkDir(pathName.path());
517 Pout<<
"fileOperation::filePath :" <<
" fName:" << fName <<
endl;
541 const fileName& procDir = procDirs()[i].first();
543 fileName collatedName(path/procDir/local);
548 Pout<<
"fileOperation::filePath : " << collatedName <<
endl;
559 Pout<<
"fileOperation::filePath : " << fName <<
endl;
567 Pout<<
"fileOperation::filePath : Not found" <<
endl;
594 if (
getFile(watchIndices[i]) == fName)
626 newWatchIndices.
append(watchIndices[index]);
627 removedWatches.
erase(index);
649 const bool masterOnly,
675 const word& constantName
680 Pout<<
"fileOperation::findTimes : Finding times in directory " 681 << directory <<
endl;
701 const fileName& procDir = procDirs()[i].first();
703 if (!collDir.empty() && collDir !=
directory)
724 Pout<<
"fileOperation::findTimes : Found times:" << times <<
endl;
733 const scalar startValue,
734 const word& stopInstance
752 <<
"Found exact match for \"" << io.
name()
766 for (instanceI = ts.
size()-1; instanceI >= 0; --instanceI)
768 if (ts[instanceI].value() <= startValue)
775 for (; instanceI >= 0; --instanceI)
781 && ts[instanceI].name() != stopInstance
787 io.
instance() = ts[instanceI].name();
793 <<
"Found exact match for \"" << io.
name()
802 if (ts[instanceI].
name() == stopInstance)
807 <<
"Hit stopInstance " << stopInstance <<
endl;
816 if (io.
name().empty())
819 <<
"Cannot find directory " 821 <<
" down to " << stopInstance
827 <<
"Cannot find file \"" << io.
name()
828 <<
"\" in directory " << io.
local()
829 <<
" in times " << startIO.
instance()
830 <<
" down to " << stopInstance
856 <<
"Found constant match for \"" << io.
name()
872 <<
"Cannot find file \"" << io.
name() <<
"\" in directory " 892 Pout<<
"fileOperation::readObjects :" 894 <<
" instance:" << instance <<
endl;
904 newInstance = instance;
912 if (!procsPath.empty())
914 newInstance = instance;
979 <<
" to determine the number of decompositions." 980 <<
" Returning 1" <<
endl;
993 Pout<<
"fileOperation::flush : clearing processor directories cache" 1003 const word& procsDir
1013 const word& instance,
1014 const word& procsDir
1028 const word& procsDir
1037 if (caseName.size() <= 9 || caseName[9] ==
's')
1040 <<
" does not end in old-style processorDDD" <<
endl;
1043 return dir.
path()/procsDir;
1078 if (pos == string::npos)
1088 if (pos > 0 && objectPath[pos-1] !=
'/')
1099 path = objectPath.substr(0, pos-1);
1100 procDir = objectPath.substr(pos);
1104 pos = procDir.find(
'/');
1105 if (pos != string::npos)
1107 local = procDir.substr(pos+1);
1108 procDir = procDir.substr(0, pos);
1120 if (
f.size() &&
f[0] ==
's')
1130 if (fromStart != string::npos && toStart != string::npos)
1132 string nProcsName(
f.substr(0, fromStart));
1133 string fromName(
f.substr(fromStart+1, toStart-(fromStart+1)));
1134 string toName(
f.substr(toStart+1));
1136 label groupEnd = -1;
1144 groupSize = groupEnd-groupStart+1;
1190 if (!handler.size())
1207 newHandlerPtr.
valid()
1216 if (newHandlerPtr.
valid())
1229 if (files[i] == file)
1231 return directory/
file;
1258 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.
virtual autoPtr< Ostream > NewOFstream(const fileName &pathname, 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.
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.
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.
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.