Go to the documentation of this file.
59 commsType_(commsType),
63 if (io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED)
66 <<
"decomposedBlockData " <<
name()
67 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
68 " but decomposedBlockData does not support automatic rereading."
74 io.
readOpt() == IOobject::MUST_READ
75 || io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED
77 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
94 commsType_(commsType),
98 if (io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED)
101 <<
"decomposedBlockData " <<
name()
102 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
103 " but decomposedBlockData does not support automatic rereading."
110 io.
readOpt() == IOobject::MUST_READ
111 || io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED
113 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
134 commsType_(commsType),
138 if (io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED)
141 <<
"decomposedBlockData " <<
name()
142 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
143 " but decomposedBlockData does not support automatic rereading."
152 io.
readOpt() == IOobject::MUST_READ
153 || io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED
155 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
169 Pout<<
"decomposedBlockData::readMasterHeader:"
177 is.
fatalCheck(
"read(Istream&) : reading entry");
199 <<
" version " <<
version <<
";\n"
200 <<
" format " <<
format <<
";\n"
201 <<
" class " <<
type <<
";\n";
216 os <<
" note " << note <<
";\n";
221 os <<
" location " << location <<
";\n";
224 os <<
" object " <<
name <<
";\n"
240 Pout<<
"decomposedBlockData::readBlock:"
241 <<
" stream:" << is.
name() <<
" attempt to read block " << blocki
252 is.
fatalCheck(
"read(Istream&) : reading entry");
261 <<
"problem while reading header for object "
269 is.
fatalCheck(
"read(Istream&) : reading entry");
282 <<
"problem while reading header for object "
286 fmt = headerStream.
format();
291 for (label i = 1; i < blocki+1; i++)
295 is.
fatalCheck(
"read(Istream&) : reading entry");
301 realIsPtr().format(fmt);
302 realIsPtr().version(ver);
321 Pout<<
"decomposedBlockData::readBlocks:"
322 <<
" stream:" << (isPtr ? isPtr->
name() :
"invalid")
324 <<
" comm:" << comm <<
endl;
339 is.
fatalCheck(
"read(Istream&) : reading entry");
351 is.
fatalCheck(
"read(Istream&) : reading entry");
396 is.
fatalCheck(
"read(Istream&) : reading entry");
408 is.
fatalCheck(
"read(Istream&) : reading entry");
442 Pout<<
"decomposedBlockData::readBlocks:"
443 <<
" stream:" << (isPtr ? isPtr->
name() :
"invalid")
462 is.
fatalCheck(
"read(Istream&) : reading entry");
465 realIsPtr->
name() = fName;
471 <<
"problem while reading header for object "
485 is.
fatalCheck(
"read(Istream&) : reading entry");
513 realIsPtr->
name() = fName;
533 is.
fatalCheck(
"read(Istream&) : reading entry");
536 realIsPtr->
name() = fName;
542 <<
"problem while reading header for object "
556 is.
fatalCheck(
"read(Istream&) : reading entry");
574 realIsPtr->
name() = fName;
583 string versionString;
589 versionString = realIsPtr().version().str();
590 formatValue =
static_cast<label
>(realIsPtr().format());
626 char* data0Ptr =
reinterpret_cast<char*
>(datas.begin());
633 forAll(recvOffsets, proci)
638 int(
reinterpret_cast<char*
>(&datas[proci]) - data0Ptr);
640 recvSizes.
setSize(nProcs,
sizeof(label));
645 reinterpret_cast<const char*
>(&
data),
661 const label startProc,
674 sliceSizes.
setSize(numProcs, 0);
675 sliceOffsets.
setSize(numProcs+1, 0);
678 label proci = startProc;
679 for (label i = 0; i < nProcs; i++)
681 sliceSizes[proci] = int(recvSizes[proci]);
682 sliceOffsets[proci] = totalSize;
683 totalSize += sliceSizes[proci];
686 sliceOffsets[proci] = totalSize;
699 nSend = int(
data.byteSize());
718 const off_t maxBufferSize,
720 const label startProci
725 label nSendProcs = -1;
728 off_t totalSize = recvSizes[startProci];
729 label proci = startProci+1;
730 while (proci < nProcs && (totalSize+recvSizes[proci] < maxBufferSize))
732 totalSize += recvSizes[proci];
736 nSendProcs = proci-startProci;
743 reinterpret_cast<const char*
>(&nSendProcs),
746 reinterpret_cast<char*
>(&
n),
766 const bool syncReturnState
771 Pout<<
"decomposedBlockData::writeBlocks:"
772 <<
" stream:" << (osPtr ? osPtr->
name() :
"invalid")
773 <<
" data:" <<
data.size()
774 <<
" (master only) slaveData:" << slaveData.size()
782 if (slaveData.size())
802 label slaveOffset = 0;
804 for (label proci = 1; proci < nProcs; ++proci)
806 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
809 os << slaveData[proci];
810 slaveOffset += recvSizes[proci];
832 for (label proci = 1; proci < nProcs; ++proci)
834 elems.
setSize(recvSizes[proci]);
845 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
885 label nSendProcs = nProcs-1;
887 while (nSendProcs > 0 && startProc < nProcs)
889 nSendProcs = calcNumProcs
895 maxMasterFileBufferSize
930 label proci = startProc;
931 proci < startProc+nSendProcs;
935 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
942 sliceOffsets[proci+1]-sliceOffsets[proci],
948 startProc += nSendProcs;
979 return readBlocks(comm_, isPtr,
data, commsType_);
1001 label formatValue(os.
format());
1012 fileName masterLocation(instance()/db().dbDir()/local());
1030 if (isA<OFstream>(os))
1038 std::string str(
data.cdata(),
data.byteSize());
1070 gather(comm_, label(this->byteSize()), recvSizes);
1092 is.
fatalCheck(
"decomposedBlockData::numBlocks(const fileName&)");
1100 token firstToken(is);
1124 token sizeToken(is);
int debug
Static debugging option.
unsigned labelByteSize() const
The label byte-size associated with the stream.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static constexpr int masterNo() noexcept
Process index of the master.
const word & name() const
Return name.
A class for handling words, derived from Foam::string.
Output inter-processor communications stream operating on external buffer.
A class for handling file names.
static constexpr const zero Zero
Global zero (0)
Input from file stream, using an ISstream.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static Ostream & writeBanner(Ostream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
Output inter-processor communications stream.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
A List obtained as a section of another List.
static label calcNumProcs(const label comm, const off_t maxBufferSize, const labelUList &recvSizes, const label startProci)
Helper: determine number of processors whose recvSizes fits.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual Ostream & writeQuoted(const std::string &str, const bool quoted=true)=0
Write std::string surrounded by quotes.
static bool & parRun()
Is this a parallel run?
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
streamFormat format() const noexcept
Get the current stream format.
static const versionNumber currentVersion
The current version number (2.0)
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
An ISstream with internal List storage.
const fileOperation & fileHandler()
Get current file handler.
static bool writeBlocks(const label comm, autoPtr< OSstream > &osPtr, List< std::streamoff > &start, const UList< char > &masterData, const labelUList &recvSizes, const PtrList< SubList< char >> &slaveData, const UPstream::commsTypes, const bool syncReturnState=true)
Write *this. Ostream only valid on master. Returns starts of.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
static void writeHeader(Ostream &os, const word &fieldName)
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
static label numBlocks(const fileName &fName)
Detect number of blocks in a file.
static void gather(const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=0)
Receive data from all processors on the master.
#define forAll(list, i)
Loop across all elements in list.
bool isLabel() const
Token is LABEL.
bool readHeader(Istream &is)
Read header.
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
word format(conversionProperties.get< word >("format"))
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
Representation of a major/minor version number.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
word name(const complex &c)
Return string representation of complex.
virtual const fileName & name() const
Return the name of the stream.
static void writeHeader(Ostream &os, const IOstream::versionNumber version, const IOstream::streamFormat format, const word &type, const string ¬e, const fileName &location, const word &name)
Helper: write FoamFile IOobject header.
virtual std::ostream & stdStream()
Access to underlying std::ostream.
static void gather(const label comm, const label data, labelList &datas)
Helper: gather single label. Note: using native Pstream.
The IOstreamOption is a simple container for options an IOstream can normally have.
static void gatherSlaveData(const label comm, const UList< char > &data, const labelUList &recvSizes, const label startProc, const label nProcs, List< int > &recvOffsets, List< char > &recvData)
Helper: gather data from (subset of) slaves. Returns.
virtual const fileName & name() const
Return the name of the stream.
Generic output stream using a standard (STL) stream.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
virtual const fileName & name() const
Return the name of the stream.
static const Enum< commsTypes > commsTypeNames
Names of the communication types.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
versionNumber version() const noexcept
Get the stream version.
static void scatter(const char *sendData, const UList< int > &sendSizes, const UList< int > &sendOffsets, char *recvData, int recvSize, const label communicator=0)
Send data to all processors from the root of the communicator.
std::string str() const
A string representation of major.minor.
streamFormat
Data format (ascii | binary)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool isWord() const
Token is WORD or DIRECTIVE word.
decomposedBlockData(const label comm, const IOobject &io, const UPstream::commsTypes=UPstream::commsTypes::scheduled)
Construct given an IOobject.
virtual void rename(const word &newName)
Rename.
const word & wordToken() const
Return const reference to the word contents.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
virtual bool writeData(Ostream &os) const
Write separated content. Assumes content is the serialised data.
Output to file stream, using an OSstream.
const word & headerClassName() const
Return name of the class name read from header.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static bool master(const label communicator=0)
Am I the master process.
const string & note() const
Return the optional note.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
static int & msgType()
Message tag of standard messages.
commsTypes
Types of communications.
static bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &data, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
Input/output from file streams.
static Ostream & writeDivider(Ostream &os)
Write the standard file section divider.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
readOption readOpt() const
The read option.
void putBack(const token &tok)
Put back token.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const std::string buildArch
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static const word null
An empty word.
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
Input inter-processor communications stream.
bool writeHeader(Ostream &os) const
Write header.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Input inter-processor communications stream operating on external buffer.
bool good() const
Return true if next operation might succeed.
void setSize(const label newSize)
Alias for resize(const label)
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
Database for solution data, solver performance and other reduced data.
virtual Ostream & writeRaw(const char *data, std::streamsize count)=0
Low-level raw binary output.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
unsigned scalarByteSize() const
The scalar byte-size associated with the stream.
virtual bool read()
Read object.