56 commsType_(commsType),
63 <<
"decomposedBlockData " <<
name()
64 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED" 65 " but decomposedBlockData does not support automatic rereading." 91 commsType_(commsType),
98 <<
"decomposedBlockData " <<
name()
99 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED" 100 " but decomposedBlockData does not support automatic rereading." 132 commsType_(commsType),
139 <<
"decomposedBlockData " <<
name()
140 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED" 141 " but decomposedBlockData does not support automatic rereading." 171 Pout<<
"decomposedBlockData::readMasterHeader:" 179 is.
fatalCheck(
"read(Istream&) : reading entry");
200 <<
" version " << version <<
";\n" 201 <<
" format " << format <<
";\n" 202 <<
" class " << type <<
";\n";
205 os <<
" note " << note <<
";\n";
210 os <<
" location " << location <<
";\n";
213 os <<
" object " << name <<
";\n" 229 Pout<<
"decomposedBlockData::readBlock:" 230 <<
" stream:" << is.
name() <<
" attempt to read block " << blocki
242 is.
fatalCheck(
"read(Istream&) : reading entry");
244 string buf(data.begin(), data.size());
251 <<
"problem while reading header for object " 259 is.
fatalCheck(
"read(Istream&) : reading entry");
264 string buf(data.begin(), data.size());
271 <<
"problem while reading header for object " 274 ver = headerStream.version();
275 fmt = headerStream.format();
278 for (
label i = 1; i < blocki+1; i++)
282 is.
fatalCheck(
"read(Istream&) : reading entry");
284 string buf(data.begin(), data.size());
289 realIsPtr().version(ver);
305 Pout<<
"decomposedBlockData::readBlocks:" 306 <<
" stream:" << (isPtr.
valid() ? isPtr().name() :
"invalid")
308 <<
" comm:" << comm <<
endl;
323 is.
fatalCheck(
"read(Istream&) : reading entry");
335 is.
fatalCheck(
"read(Istream&) : reading entry");
380 is.
fatalCheck(
"read(Istream&) : reading entry");
392 is.
fatalCheck(
"read(Istream&) : reading entry");
426 Pout<<
"decomposedBlockData::readBlocks:" 427 <<
" stream:" << (isPtr.
valid() ? isPtr().name() :
"invalid")
446 is.
fatalCheck(
"read(Istream&) : reading entry");
448 string buf(data.begin(), data.size());
455 <<
"problem while reading header for object " 469 is.
fatalCheck(
"read(Istream&) : reading entry");
496 string buf(data.begin(), data.size());
517 is.
fatalCheck(
"read(Istream&) : reading entry");
519 string buf(data.begin(), data.size());
526 <<
"problem while reading header for object " 540 is.
fatalCheck(
"read(Istream&) : reading entry");
557 string buf(data.begin(), data.size());
565 string versionString(realIsPtr().version().str());
572 os << realIsPtr().format();
573 string formatString(os.
str());
575 realIsPtr().format(formatString);
600 char* data0Ptr =
reinterpret_cast<char*
>(datas.
begin());
607 forAll(recvOffsets, proci)
612 int(reinterpret_cast<char*>(&datas[proci]) - data0Ptr);
619 reinterpret_cast<const char*>(&data),
635 const label startProc,
648 sliceSizes.
setSize(numProcs, 0);
649 sliceOffsets.
setSize(numProcs+1, 0);
652 label proci = startProc;
653 for (
label i = 0; i < nProcs; i++)
655 sliceSizes[proci] = int(recvSizes[proci]);
656 sliceOffsets[proci] = totalSize;
657 totalSize += sliceSizes[proci];
660 sliceOffsets[proci] = totalSize;
692 const off_t maxBufferSize,
694 const label startProci
699 label nSendProcs = -1;
702 off_t totalSize = recvSizes[startProci];
703 label proci = startProci+1;
704 while (proci < nProcs && (totalSize+recvSizes[proci] < maxBufferSize))
706 totalSize += recvSizes[proci];
710 nSendProcs = proci-startProci;
717 reinterpret_cast<const char*>(&nSendProcs),
720 reinterpret_cast<char*>(&n),
740 const bool syncReturnState
745 Pout<<
"decomposedBlockData::writeBlocks:" 746 <<
" stream:" << (osPtr.
valid() ? osPtr().name() :
"invalid")
747 <<
" data:" << data.
size()
748 <<
" (master only) slaveData:" << slaveData.size()
756 if (slaveData.size())
776 label slaveOffset = 0;
778 for (
label proci = 1; proci < nProcs; proci++)
780 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
783 os << slaveData[proci];
784 slaveOffset += recvSizes[proci];
806 for (
label proci = 1; proci < nProcs; proci++)
808 elems.
setSize(recvSizes[proci]);
819 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
859 label nSendProcs = nProcs-1;
861 while (nSendProcs > 0 && startProc < nProcs)
863 nSendProcs = calcNumProcs
869 maxMasterFileBufferSize
904 label proci = startProc;
905 proci < startProc+nSendProcs;
909 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
916 sliceOffsets[proci+1]-sliceOffsets[proci],
922 startProc += nSendProcs;
953 return readBlocks(comm_, isPtr, data, commsType_);
963 reinterpret_cast<const char*>(data.
cbegin()),
985 formatString = os.
str();
997 fileName masterLocation(instance()/db().dbDir()/local());
1007 io.headerClassName(),
1043 gather(comm_,
label(this->byteSize()), recvSizes);
1065 is.
fatalCheck(
"decomposedBlockData::numBlocks(const fileName&)");
1073 token firstToken(is);
1090 token sizeToken(is);
decomposedBlockData(const label comm, const IOobject &, const UPstream::commsTypes=UPstream::commsTypes::scheduled)
Construct given an IOobject.
virtual ~decomposedBlockData()
Destructor.
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.
#define forAll(list, i)
Loop across all elements in list.
static streamFormat formatEnum(const word &)
Return stream format of given format name.
virtual bool read()
Read object.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static int masterNo()
Process index of the master.
const word & name() const
Return name.
A class for handling file names.
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
virtual bool writeData(Ostream &) const
Write separated content. Assumes content is the serialised data.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
commsTypes
Types of communications.
const word & wordToken() const
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
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.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual void rename(const word &newName)
Rename.
A token holds items read from Istream.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
const_iterator cbegin() const
Return const_iterator to begin traversing the constant UList.
void putBack(const token &)
Put back token.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static label numBlocks(const fileName &)
Detect number of blocks in a file.
static bool master(const label communicator=0)
Am I the master process.
static int & msgType()
Message tag of standard messages.
versionNumber version() const
Return the stream version.
bool good() const
Return true if next operation might succeed.
virtual Ostream & writeQuoted(const std::string &, const bool quoted=true)=0
Write std::string surrounded by quotes.
Input inter-processor communications stream.
Input inter-processor communications stream operating on external buffer.
bool readHeader(Istream &)
Read header.
string & note()
Return non-constant access to the optional note.
A List obtained as a section of another List.
bool read(const char *, int32_t &)
A class for handling words, derived from string.
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.
iterator begin()
Return an iterator to begin traversing the UList.
streamFormat
Enumeration for the format of data in the stream.
static const word null
An empty word.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
const fileOperation & fileHandler()
Get current file handler.
streamFormat format() const
Return current stream format.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
compressionType
Enumeration for the format of data in the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Output inter-processor communications stream operating on external buffer.
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.
defineTypeNameAndDebug(combustionModel, 0)
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 const NamedEnum< commsTypes, 3 > commsTypeNames
Output inter-processor communications stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
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.
word name(const complex &)
Return a string representation of a complex.
void operator=(const UList< T > &)
Assignment to UList operator. Takes linear time.
static label calcNumProcs(const label comm, const off_t maxBufferSize, const labelUList &recvSizes, const label startProci)
Helper: determine number of processors whose recvSizes fits.
virtual ostream & stdStream()
Access to underlying std::ostream.
void setSize(const label)
Reset size of List.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
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 WarningInFunction
Report a warning using Foam::Warning.
static const versionNumber currentVersion
Current version number.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
string str() const
Return the versionNumber as a character string.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
std::streamsize byteSize() const
Return the binary size in number of characters of the UList.
Input from memory buffer stream.
prefixOSstream Pout(cout, "Pout")
string str() const
Return the string.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool writeHeader(Ostream &) const
Write header.
label size() const
Return the number of elements in the UList.
readOption readOpt() const
const word & headerClassName() const
Return name of the class name read from header.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Output to memory buffer stream.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
static void gather(const label comm, const label data, labelList &datas)
Helper: gather single label. Note: using native Pstream.