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())
382 if (originalPath != objPath)
385 if (io.
name().empty())
387 ok =
isDir(originalPath);
415 wordConstructorTable::iterator cstrIter =
416 wordConstructorTablePtr_->find(type);
418 if (cstrIter == wordConstructorTablePtr_->end())
421 <<
"Unknown fileOperation type " 423 <<
"Valid fileOperation types are" <<
endl 424 << wordConstructorTablePtr_->sortedToc()
511 Pout<<
"fileOperation::filePath :" <<
" fName:" << fName <<
endl;
535 const fileName& procDir = procDirs()[i].first();
537 fileName collatedName(path/procDir/local);
542 Pout<<
"fileOperation::filePath : " << collatedName <<
endl;
553 Pout<<
"fileOperation::filePath : " << fName <<
endl;
561 Pout<<
"fileOperation::filePath : Not found" <<
endl;
588 if (
getFile(watchIndices[i]) == fName)
620 newWatchIndices.
append(watchIndices[index]);
621 removedWatches.
erase(index);
643 const bool masterOnly,
669 const word& constantName
674 Pout<<
"fileOperation::findTimes : Finding times in directory " 675 << directory <<
endl;
695 const fileName& procDir = procDirs()[i].first();
697 if (!collDir.empty() && collDir !=
directory)
718 Pout<<
"fileOperation::findTimes : Found times:" << times <<
endl;
727 const scalar startValue,
728 const word& stopInstance
746 <<
"Found exact match for \"" << io.
name()
760 for (instanceI = ts.
size()-1; instanceI >= 0; --instanceI)
765 || ts[instanceI].value() <= startValue
773 for (; instanceI >= 0; --instanceI)
779 && ts[instanceI].name() != stopInstance
785 io.
instance() = ts[instanceI].name();
791 <<
"Found exact match for \"" << io.
name()
800 if (ts[instanceI].
name() == stopInstance)
805 <<
"Hit stopInstance " << stopInstance <<
endl;
814 if (io.
name().empty())
817 <<
"Cannot find directory " 819 <<
" down to " << stopInstance
825 <<
"Cannot find file \"" << io.
name()
826 <<
"\" in directory " << io.
local()
827 <<
" in times " << startIO.
instance()
828 <<
" down to " << stopInstance
854 <<
"Found constant match for \"" << io.
name()
870 <<
"Cannot find file \"" << io.
name() <<
"\" in directory " 890 Pout<<
"fileOperation::readObjects :" 892 <<
" instance:" << instance <<
endl;
902 newInstance = instance;
910 if (!procsPath.empty())
912 newInstance = instance;
978 <<
" to determine the number of decompositions." 979 <<
" Returning 1" <<
endl;
992 Pout<<
"fileOperation::flush : clearing processor directories cache" 1002 const word& procsDir
1012 const word& instance,
1013 const word& procsDir
1027 const word& procsDir
1036 if (caseName.size() <= 9 || caseName[9] ==
's')
1039 <<
" does not end in old-style processorDDD" <<
endl;
1042 return dir.
path()/procsDir;
1077 if (pos == string::npos)
1087 if (pos > 0 && objectPath[pos-1] !=
'/')
1098 path = objectPath.substr(0, pos-1);
1099 procDir = objectPath.substr(pos);
1103 pos = procDir.find(
'/');
1104 if (pos != string::npos)
1106 local = procDir.substr(pos+1);
1107 procDir = procDir.substr(0, pos);
1119 if (
f.size() &&
f[0] ==
's')
1129 if (fromStart != string::npos && toStart != string::npos)
1131 string nProcsName(
f.substr(0, fromStart));
1132 string fromName(
f.substr(fromStart+1, toStart-(fromStart+1)));
1133 string toName(
f.substr(toStart+1));
1135 label groupEnd = -1;
1143 groupSize = groupEnd-groupStart+1;
1189 if (!handler.size())
1206 newHandlerPtr.
valid()
1215 if (newHandlerPtr.
valid())
1228 if (files[i] == file)
1230 return directory/
file;
1257 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.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return name.
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)
Checking for changes to files.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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.
fileName objectPath() const
Return complete path + object name.
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.
fileName path(const word &instance, const fileName &local="") const
Return complete path with alternative instance and local.
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.
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 fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const =0
Search for an object. globalFile : also check undecomposed case.
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.
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)
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?
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.
bool headerOk()
Read header of local object without type-checking.
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.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
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.
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.
fileName objectPath(const bool global) const
Return complete path + object name including the processor.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
#define InfoInFunction
Report an information message using Foam::Info.