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");
346 is.
fatalCheck(
"read(Istream&) : reading entry");
391 is.
fatalCheck(
"read(Istream&) : reading entry");
398 is.
fatalCheck(
"read(Istream&) : reading entry");
432 Pout<<
"decomposedBlockData::readBlocks:"
433 <<
" stream:" << (isPtr ? isPtr->
name() :
"invalid")
452 is.
fatalCheck(
"read(Istream&) : reading entry");
455 realIsPtr->
name() = fName;
461 <<
"problem while reading header for object "
470 is.
fatalCheck(
"read(Istream&) : reading entry");
498 realIsPtr->
name() = fName;
518 is.
fatalCheck(
"read(Istream&) : reading entry");
521 realIsPtr->
name() = fName;
527 <<
"problem while reading header for object "
536 is.
fatalCheck(
"read(Istream&) : reading entry");
554 realIsPtr->
name() = fName;
563 string versionString;
569 versionString = realIsPtr().version().str();
570 formatValue =
static_cast<label
>(realIsPtr().format());
606 char* data0Ptr =
reinterpret_cast<char*
>(datas.begin());
613 forAll(recvOffsets, proci)
618 int(
reinterpret_cast<char*
>(&datas[proci]) - data0Ptr);
620 recvSizes.
setSize(nProcs,
sizeof(label));
625 reinterpret_cast<const char*
>(&
data),
641 const label startProc,
654 sliceSizes.
setSize(numProcs, 0);
655 sliceOffsets.
setSize(numProcs+1, 0);
658 label proci = startProc;
659 for (label i = 0; i < nProcs; i++)
661 sliceSizes[proci] = int(recvSizes[proci]);
662 sliceOffsets[proci] = totalSize;
663 totalSize += sliceSizes[proci];
666 sliceOffsets[proci] = totalSize;
679 nSend = int(
data.byteSize());
698 const off_t maxBufferSize,
700 const label startProci
705 label nSendProcs = -1;
708 off_t totalSize = recvSizes[startProci];
709 label proci = startProci+1;
710 while (proci < nProcs && (totalSize+recvSizes[proci] < maxBufferSize))
712 totalSize += recvSizes[proci];
716 nSendProcs = proci-startProci;
723 reinterpret_cast<const char*
>(&nSendProcs),
726 reinterpret_cast<char*
>(&
n),
746 const bool syncReturnState
751 Pout<<
"decomposedBlockData::writeBlocks:"
752 <<
" stream:" << (osPtr ? osPtr->
name() :
"invalid")
753 <<
" data:" <<
data.size()
754 <<
" (master only) slaveData:" << slaveData.size()
762 if (slaveData.size())
782 label slaveOffset = 0;
784 for (label proci = 1; proci < nProcs; ++proci)
786 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
789 os << slaveData[proci];
790 slaveOffset += recvSizes[proci];
812 for (label proci = 1; proci < nProcs; ++proci)
814 elems.
setSize(recvSizes[proci]);
825 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
865 label nSendProcs = nProcs-1;
867 while (nSendProcs > 0 && startProc < nProcs)
869 nSendProcs = calcNumProcs
875 maxMasterFileBufferSize
910 label proci = startProc;
911 proci < startProc+nSendProcs;
915 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
922 sliceOffsets[proci+1]-sliceOffsets[proci],
928 startProc += nSendProcs;
959 return readBlocks(comm_, isPtr,
data, commsType_);
981 label formatValue(os.
format());
992 fileName masterLocation(instance()/db().dbDir()/local());
1010 if (isA<OFstream>(os))
1018 std::string str(
data.cdata(),
data.byteSize());
1050 gather(comm_, label(this->byteSize()), recvSizes);
1072 is.
fatalCheck(
"decomposedBlockData::numBlocks(const fileName&)");
1080 token firstToken(is);
1104 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 (always 0)
const word & name() const
Return name.
bool isLabel() const noexcept
Token is LABEL.
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.
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()
Test if this a parallel run, or allow modify access.
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 bool master(const label communicator=worldComm)
Am I the master process.
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
OSstream wrapped stdout (std::cout) with parallel prefix.
static label numBlocks(const fileName &fName)
Detect number of blocks in a file.
bool isWord() const noexcept
Token is WORD or DIRECTIVE word.
#define forAll(list, i)
Loop across all elements in list.
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 rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
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.
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,...
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.
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.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
static void scatter(const char *sendData, const UList< int > &sendSizes, const UList< int > &sendOffsets, char *recvData, int recvSize, const label communicator=worldComm)
Send data to all processors from the root of the communicator.
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.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
static void gather(const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=worldComm)
Receive data from all processors on the master.
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.