38 namespace fileOperations
71 string ioRanksString(
getEnv(
"FOAM_IORANKS"));
72 if (!ioRanksString.empty())
124 Pout<<
"collatedFileOperation::writeObject :"
125 <<
" For local object : " << io.
name()
126 <<
" appending processor " << proci
127 <<
" data to " << filePath <<
endl;
133 <<
"Not a valid processor path " << filePath
137 const bool isMaster = isMasterRank(proci);
140 label localProci = proci;
143 label groupStart, groupSize, nProcs;
154 if (groupSize > 0 && groupStart != -1)
156 localProci = proci-groupStart;
203 <<
"Cannot open for appending"
213 os <<
" version " << os.
version() <<
";\n";
216 os <<
" format " << os.
format() <<
";\n"
217 <<
" class " << decomposedBlockData::typeName
219 <<
" location " << filePath <<
";\n"
220 <<
" object " << filePath.
name() <<
";\n"
229 const_cast<char*
>(buf.data()),
232 os <<
nl <<
"// Processor" << localProci <<
nl << slice <<
nl;
259 writer_(maxThreadFileBufferSize, comm_),
266 <<
"I/O : " << typeName
273 <<
" Threading not activated "
274 "since maxThreadFileBufferSize = 0." <<
nl
275 <<
" Writing may run slowly for large file sizes."
281 <<
" Threading activated "
282 "since maxThreadFileBufferSize > 0." <<
nl
283 <<
" Requires large enough buffer to collect all data"
284 " or thread support " <<
nl
285 <<
" enabled in MPI. If thread support cannot be "
286 "enabled, deactivate" <<
nl
287 <<
" threading by setting maxThreadFileBufferSize "
289 <<
" $FOAM_ETC/controlDict"
321 <<
"Resetting fileModificationChecking to inotify" <<
endl;
331 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
341 const word& typeName,
347 writer_(maxThreadFileBufferSize, comm),
354 <<
"I/O : " << typeName
361 <<
" Threading not activated "
362 "since maxThreadFileBufferSize = 0." <<
nl
363 <<
" Writing may run slowly for large file sizes."
369 <<
" Threading activated "
370 "since maxThreadFileBufferSize > 0." <<
nl
371 <<
" Requires large enough buffer to collect all data"
372 " or thread support " <<
nl
373 <<
" enabled in MPI. If thread support cannot be "
374 "enabled, deactivate" <<
nl
375 <<
" threading by setting maxThreadFileBufferSize "
377 <<
" $FOAM_ETC/controlDict"
388 <<
"Resetting fileModificationChecking to inotify" <<
endl;
398 <<
"Resetting fileModificationChecking to timeStamp" <<
endl;
466 Pout<<
"collatedFileOperation::writeObject :"
467 <<
" For object : " << io.
name()
468 <<
" falling back to master-only output to " << io.
path()
503 fileName path(processorsPath(io, inst, processorsDir(io)));
512 Pout<<
"collatedFileOperation::writeObject :"
513 <<
" For global object : " << io.
name()
514 <<
" falling back to master-only output to " << filePath
553 Pout<<
"collatedFileOperation::writeObject :"
554 <<
" For object : " << io.
name()
555 <<
" appending to " << filePath <<
endl;
558 return appendObject(io, filePath, fmt, ver, cmp);
564 bool useThread = (maxThreadFileBufferSize > 0);
568 Pout<<
"collatedFileOperation::writeObject :"
569 <<
" For object : " << io.
name()
570 <<
" starting collating output to " << filePath
571 <<
" useThread:" << useThread <<
endl;
618 Pout<<
"collatedFileOperation::flush : clearing and waiting for thread"
655 label proci = detectProcessorPath(fName);
661 label maxProc = nProcs_-1;
664 if (ioRanks_[i] >= nProcs_)
668 else if (ioRanks_[i] <= proci)
670 minProc = ioRanks_[i];
674 maxProc = ioRanks_[i]-1;
706 Pout<<
"collatedFileOperation::setNProcs :"
707 <<
" Setting number of processors to " << nProcs_ <<
endl;
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
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.
static constexpr const char * foamFile
Keyword for the FoamFile header sub-dictionary.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
const word & name() const
Return name.
bool writeHeader(Ostream &) const
Write header.
fileName objectPath(const bool global) const
Return complete path + object name including the processor.
static const versionNumber currentVersion
Current version number.
streamFormat format() const
Return current stream format.
streamFormat
Enumeration for the format of data in the stream.
versionNumber version() const
Return the stream version.
compressionType
Enumeration for the format of data in the stream.
bool good() const
Return true if next operation might succeed.
Input from memory buffer stream.
void size(const label)
Override size to be inconsistent with allocated storage.
Output to memory buffer stream.
string str() const
Return the string.
Inter-processor communications stream.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
bool processorCase() const
Return true if this is a processor case.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & last()
Return the last element of the list.
Inter-processor communications stream.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static bool master(const label communicator=0)
Am I the master process.
static List< int > & procID(label communicator)
Process ID of given process index.
static label worldComm
Default communicator (all processors)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A class for handling file names.
bool isAbsolute() const
Return true if file name is absolute.
word name() const
Return file name (part beyond last /)
const label comm_
Communicator to use.
Version of masterUncollatedFileOperation that collates regIOobjects into a container in the processor...
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).
bool isMasterRank(const label proci) const
Is proci master of communicator (in parallel) or master of.
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
virtual ~collatedFileOperation()
Destructor.
virtual word processorsDir(const IOobject &) const
Actual name of processors dir.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
const labelList ioRanks_
Ranks of IO handlers.
collatedFileOperation(const bool verbose)
Construct null.
static float maxThreadFileBufferSize
Max size of thread buffer size. This is the overall size of.
static labelList ioRanks()
bool appendObject(const regIOobject &io, const fileName &filePath, IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Append to processors/ file.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
fileName relativeObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
Master-only drop-in replacement for OFstream.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
fileName objectPath() const
Return complete path + object name.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
virtual bool global() const
Return true if object is global, i.e. same for all processors.
fileName path() const
Return complete path.
Master-only drop-in replacement for OFstream.
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoHeader
Report write to Foam::Info if the local log switch is true.
float floatOptimisationSwitch(const char *name, const float defaultValue=0)
Lookup optimisation switch or add default value.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
defineTypeNameAndDebug(collatedFileOperation, 0)
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
string hostName(const bool full=false)
Return the system's host name, as per hostname(1)
string getEnv(const word &)
Return environment variable of given name.
pid_t pid()
Return the PID of this process.
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.