55 "uncollatedProcInstance",
95 const word& constantName
103 bool haveConstant =
false;
106 if (dirEntries[i] == constantName)
108 Times[nTimes].value() = 0;
109 Times[nTimes].name() = dirEntries[i];
120 if (
readScalar(dirEntries[i].c_str(), timeValue))
122 Times[nTimes].value() = timeValue;
123 Times[nTimes].name() = dirEntries[i];
150 const word& constantName,
154 if (extraTimes.
size())
159 && times[0].name() == constantName
162 bool haveExtraConstant =
164 extraTimes.
size() > 0
165 && extraTimes[0].name() == constantName
172 if (haveExtraConstant)
177 combinedTimes[sz++] = extraTimes[0];
182 combinedTimes[sz++] = times[i];
184 for (; extrai < extraTimes.
size(); extrai++)
186 combinedTimes[sz++] = extraTimes[extrai];
192 if (times.
size() > 1)
195 if (times[0].
name() == constantName)
202 label newi = starti+1;
203 for (
label i = newi; i < times.
size(); i++)
205 if (times[i].value() != times[i-1].value())
209 times[newi] = times[i];
243 splitProcessorPath(fName, path, pDir, local, gStart, gSz, numProcs);
250 procsDirs_.find(procPath);
252 if (iter != procsDirs_.end())
277 label rStart, rSize, rNum;
279 splitProcessorPath(dirN, rp, rd, rl, rStart, rSize, rNum);
280 maxProc =
max(maxProc, readProci);
282 if (proci == readProci)
294 else if (proci >= rStart && proci < rStart+rSize)
338 procsDirs_.insert(procPath, procDirs);
342 Pout<<
"fileOperation::lookupProcessorsPath : For:" << procPath
343 <<
" detected:" << procDirs <<
endl;
347 return procsDirs_[procPath];
361 if (io.
name().empty())
376 if (originalPath != objPath)
379 if (io.
name().empty())
381 ok =
isDir(originalPath);
409 wordConstructorTable::iterator cstrIter =
410 wordConstructorTablePtr_->find(
type);
412 if (cstrIter == wordConstructorTablePtr_->end())
415 <<
"Unknown fileOperation type "
417 <<
"Valid fileOperation types are" <<
endl
418 << wordConstructorTablePtr_->sortedToc()
501 Pout<<
"fileOperation::filePath :" <<
" fName:" << fName <<
endl;
511 splitProcessorPath(fName, path, pDir, local, gStart, gSz, numProcs);
525 const fileName& procDir = procDirs()[i].first();
527 fileName collatedName(path/procDir/local);
532 Pout<<
"fileOperation::filePath : " << collatedName <<
endl;
543 Pout<<
"fileOperation::filePath : " << fName <<
endl;
551 Pout<<
"fileOperation::filePath : Not found" <<
endl;
560 return monitor().addWatch(fName);
566 return monitor().removeWatch(watchIndex);
578 if (getFile(watchIndices[i]) == fName)
601 label index = findWatch(watchIndices,
f);
605 newWatchIndices.
append(addWatch(
f));
610 newWatchIndices.
append(watchIndices[index]);
611 removedWatches.
erase(index);
618 removeWatch(watchIndices[iter.key()]);
627 return monitor().getFile(watchIndex);
633 const bool masterOnly,
646 return monitor().getState(watchFd);
652 monitor().setUnmodified(watchFd);
660 const word& constantName
665 Pout<<
"fileOperation::findTimes : Finding times in directory "
679 instantList times = sortTimes(dirEntries, constantName);
686 const fileName& procDir = procDirs()[i].first();
688 if (!collDir.empty() && collDir !=
directory)
700 sortTimes(extraEntries, constantName),
709 Pout<<
"fileOperation::findTimes : Found times:" << times <<
endl;
718 const scalar startValue,
719 const word& stopInstance
737 <<
"Found exact match for \"" << io.
name()
751 for (instanceI = ts.
size()-1; instanceI >= 0; --instanceI)
756 || ts[instanceI].value() <= startValue
764 for (; instanceI >= 0; --instanceI)
770 && ts[instanceI].name() != stopInstance
776 io.
instance() = ts[instanceI].name();
782 <<
"Found exact match for \"" << io.
name()
791 if (ts[instanceI].
name() == stopInstance)
796 <<
"Hit stopInstance " << stopInstance <<
endl;
805 if (io.
name().empty())
808 <<
"Cannot find directory "
810 <<
" down to " << stopInstance
816 <<
"Cannot find file \"" << io.
name()
817 <<
"\" in directory " << io.
local()
818 <<
" in times " << startIO.
instance()
819 <<
" down to " << stopInstance
845 <<
"Found constant match for \"" << io.
name()
861 <<
"Cannot find file \"" << io.
name() <<
"\" in directory "
881 Pout<<
"fileOperation::readObjects :"
883 <<
" instance:" << instance <<
endl;
893 newInstance = instance;
901 if (!procsPath.empty())
903 newInstance = instance;
938 splitProcessorPath(dirN, path, pDir, local, start, size,
n)
950 if (nProcs == 0 &&
Foam::isDir(dir/processorsBaseDir))
969 <<
" to determine the number of decompositions."
970 <<
" Returning 1" <<
endl;
983 Pout<<
"fileOperation::flush : clearing processor directories cache"
1003 const word& instance,
1004 const word& procsDir
1008 processorsCasePath(io, procsDir)
1018 const word& procsDir
1027 if (caseName.size() <= 9 || caseName[9] ==
's')
1030 <<
" does not end in old-style processorDDD" <<
endl;
1033 return dir.
path()/procsDir;
1068 if (
pos == string::npos)
1078 if (
pos > 0 && objectPath[
pos-1] !=
'/')
1084 procDir = objectPath;
1089 path = objectPath.substr(0,
pos-1);
1090 procDir = objectPath.substr(
pos);
1094 pos = procDir.find(
'/');
1095 if (
pos != string::npos)
1097 local = procDir.substr(
pos+1);
1098 procDir = procDir.substr(0,
pos);
1110 if (
f.
size() &&
f[0] ==
's')
1120 if (fromStart != string::npos && toStart != string::npos)
1122 string nProcsName(
f.substr(0, fromStart));
1123 string fromName(
f.substr(fromStart+1, toStart-(fromStart+1)));
1124 string toName(
f.substr(toStart+1));
1126 label groupEnd = -1;
1134 groupSize = groupEnd-groupStart+1;
1167 label start, size, nProcs;
1168 return splitProcessorPath(fName, path, pDir, local, start, size, nProcs);
1180 if (!handler.size())
1197 newHandlerPtr.
valid()
1206 if (newHandlerPtr.
valid())
1219 if (files[i] ==
file)
1248 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)
virtual fileName objectPath(const IOobject &io) const
Generate disk file name for object. Opposite of filePath.
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'.
static const NamedEnum< pathType, 12 > pathTypeNames_
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.
virtual fileName filePath(const bool globalFile, const IOobject &) const =0
Search for an object. globalFile : also check undecomposed case.
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.
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 Time &, const fileName &, const word &) const
Get sorted list of times.
static word processorsBaseDir
Return the processors directory name (usually "processors")
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)
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
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.
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.
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.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
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.