57 "uncollatedProcInstance",
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;
521 splitProcessorPath(fName, path, pDir, local, gStart, gSz, numProcs);
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;
570 return monitor().addWatch(fName);
576 return monitor().removeWatch(watchIndex);
588 if (getFile(watchIndices[i]) == fName)
611 label index = findWatch(watchIndices,
f);
615 newWatchIndices.
append(addWatch(
f));
620 newWatchIndices.
append(watchIndices[index]);
621 removedWatches.
erase(index);
628 removeWatch(watchIndices[iter.key()]);
637 return monitor().getFile(watchIndex);
643 const bool masterOnly,
656 return monitor().getState(watchFd);
662 monitor().setUnmodified(watchFd);
669 const word& constantName
674 Pout<<
"fileOperation::findTimes : Finding times in directory "
688 instantList times = sortTimes(dirEntries, constantName);
695 const fileName& procDir = procDirs()[i].first();
697 if (!collDir.empty() && collDir !=
directory)
709 sortTimes(extraEntries, constantName),
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;
947 splitProcessorPath(dirN, path, pDir, local, start, size,
n)
959 if (nProcs == 0 &&
Foam::isDir(dir/processorsBaseDir))
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
1017 processorsCasePath(io, 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] !=
'/')
1093 procDir = objectPath;
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;
1176 label start, size, nProcs;
1177 return splitProcessorPath(fName, path, pDir, local, start, size, nProcs);
1189 if (!handler.size())
1206 newHandlerPtr.
valid()
1215 if (newHandlerPtr.
valid())
1228 if (files[i] ==
file)
1257 cp(srcDir/srcFiles[filei], targetDir);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
graph_traits< Graph >::vertices_size_type size_type
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
An STL-conforming const_iterator.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const fileName & local() const
const Time & time() const
Return time.
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const objectRegistry & db() const
Return the local objectRegistry.
readOption readOpt() const
bool headerOk()
Read header of local object without type-checking.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
const word & name() const
Return name.
const fileName & rootPath() const
bool writeHeader(Ostream &) const
Write header.
fileName objectPath(const bool global) const
Return complete path + object name including the processor.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
bool good() const
Return true if next operation might succeed.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
Initialise the NamedEnum HashTable from the static list of names.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
static const word & constant()
Return constant name.
const fileName & globalCaseName() const
Return global case name.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
instantList times() const
Search the case for valid time directories.
A 2-tuple for storing two objects of different types.
iterator end()
Return an iterator to end traversing the UList.
static bool master(const label communicator=0)
Am I the master process.
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
static label numBlocks(const fileName &)
Detect number of blocks in a file.
Checking for changes to files.
fileState
Enumeration defining the file state.
A class for handling file names.
word name() const
Return file name (part beyond last /)
static const fileName null
An empty fileName.
fileName path() const
Return directory path name (part before last /)
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).
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
static word processorsBaseDir
Return the processors directory name (usually "processors")
static instantList sortTimes(const fileNameList &, const word &)
Sort directory entries according to time value.
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
fileOperation(const label comm)
Construct null.
static label detectProcessorPath(const fileName &)
Detect processor number from '/aa/bb/processorDDD/cc'.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
static autoPtr< fileOperation > New(const word &type, const bool verbose)
Select type.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
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.
static word defaultFileHandler
Default fileHandler.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
pathType
Enumeration for the location of an IOobject.
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
static const NamedEnum< pathType, 12 > pathTypeNames_
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
autoPtr< fileMonitor > monitorPtr_
file-change monitor for all registered files
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
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.
fileMonitor & monitor() const
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
virtual ~fileOperation()
Destructor.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
virtual fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const =0
Search for an object. globalFile : also check undecomposed case.
Less function class used in sorting instants.
Registry of regIOobjects.
fileName path(const word &instance, const fileName &local="") const
Return complete path with alternative instance and local.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const labelList & watchIndices() const
Return file-monitoring handles.
fileName objectPath() const
Return complete path + object name.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
A class for managing temporary objects without reference counting.
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
bool valid(const PtrList< ModelType > &l)
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
const fileOperation & fileHandler()
Get current file handler.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar pos(const dimensionedScalar &ds)
bool read(const char *, int32_t &)
void cpFiles(const fileName &srcDir, const fileName &targetDir)
Copy all the files from the source to the target directory.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
errorManip< error > abort(error &err)
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
string getEnv(const word &)
Return environment variable of given name.
prefixOSstream Pout(cout, "Pout")
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
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.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.