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."
131 List<char>(move(list)),
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");
196 Pout<<
"decomposedBlockData::readBlock:"
197 <<
" stream:" << is.
name() <<
" attempt to read block " << blocki
209 is.
fatalCheck(
"read(Istream&) : reading entry");
211 string buf(data.begin(), data.size());
218 <<
"problem while reading header for object "
226 is.
fatalCheck(
"read(Istream&) : reading entry");
231 string buf(data.begin(), data.size());
238 <<
"problem while reading header for object "
242 fmt = headerStream.
format();
245 for (
label i = 1; i < blocki+1; i++)
249 is.
fatalCheck(
"read(Istream&) : reading entry");
251 string buf(data.begin(), data.size());
255 realIsPtr().format(fmt);
256 realIsPtr().version(ver);
272 Pout<<
"decomposedBlockData::readBlocks:"
273 <<
" stream:" << (isPtr.
valid() ? isPtr().name() :
"invalid")
275 <<
" comm:" << comm <<
endl;
290 is.
fatalCheck(
"read(Istream&) : reading entry");
302 is.
fatalCheck(
"read(Istream&) : reading entry");
347 is.
fatalCheck(
"read(Istream&) : reading entry");
359 is.
fatalCheck(
"read(Istream&) : reading entry");
393 Pout<<
"decomposedBlockData::readBlocks:"
394 <<
" stream:" << (isPtr.
valid() ? isPtr().name() :
"invalid")
413 is.
fatalCheck(
"read(Istream&) : reading entry");
415 string buf(data.begin(), data.size());
422 <<
"problem while reading header for object "
436 is.
fatalCheck(
"read(Istream&) : reading entry");
463 string buf(data.begin(), data.size());
484 is.
fatalCheck(
"read(Istream&) : reading entry");
486 string buf(data.begin(), data.size());
493 <<
"problem while reading header for object "
507 is.
fatalCheck(
"read(Istream&) : reading entry");
524 string buf(data.begin(), data.size());
532 string versionString(realIsPtr().version().str());
539 os << realIsPtr().format();
540 string formatString(os.
str());
542 realIsPtr().format(formatString);
567 char* data0Ptr =
reinterpret_cast<char*
>(datas.
begin());
574 forAll(recvOffsets, proci)
579 int(
reinterpret_cast<char*
>(&datas[proci]) - data0Ptr);
586 reinterpret_cast<const char*
>(&data),
602 const label startProc,
615 sliceSizes.
setSize(numProcs, 0);
616 sliceOffsets.
setSize(numProcs+1, 0);
619 label proci = startProc;
620 for (
label i = 0; i < nProcs; i++)
622 sliceSizes[proci] = int(recvSizes[proci]);
623 sliceOffsets[proci] = totalSize;
624 totalSize += sliceSizes[proci];
627 sliceOffsets[proci] = totalSize;
659 const off_t maxBufferSize,
661 const label startProci
666 label nSendProcs = -1;
669 off_t totalSize = recvSizes[startProci];
670 label proci = startProci+1;
671 while (proci < nProcs && (totalSize+recvSizes[proci] < maxBufferSize))
673 totalSize += recvSizes[proci];
677 nSendProcs = proci-startProci;
684 reinterpret_cast<const char*
>(&nSendProcs),
687 reinterpret_cast<char*
>(&
n),
707 const bool syncReturnState
712 Pout<<
"decomposedBlockData::writeBlocks:"
713 <<
" stream:" << (osPtr.
valid() ? osPtr().name() :
"invalid")
714 <<
" data:" << data.
size()
715 <<
" (master only) slaveData:" << slaveData.size()
723 if (slaveData.size())
742 for (
label proci = 1; proci < nProcs; proci++)
744 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
747 os << slaveData[proci];
769 for (
label proci = 1; proci < nProcs; proci++)
771 elems.
setSize(recvSizes[proci]);
782 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
822 label nSendProcs = nProcs-1;
824 while (nSendProcs > 0 && startProc < nProcs)
826 nSendProcs = calcNumProcs
832 maxMasterFileBufferSize
867 label proci = startProc;
868 proci < startProc+nSendProcs;
872 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
879 sliceOffsets[proci+1]-sliceOffsets[proci],
885 startProc += nSendProcs;
916 return readBlocks(comm_, isPtr, data, commsType_);
926 reinterpret_cast<const char*
>(data.
cbegin()),
948 formatString = os.
str();
960 fileName masterLocation(instance()/db().dbDir()/local());
1006 gather(comm_,
label(this->byteSize()), recvSizes);
1028 is.
fatalCheck(
"decomposedBlockData::numBlocks(const fileName&)");
1036 token firstToken(is);
1053 token sizeToken(is);
#define forAll(list, i)
Loop across all elements in list.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
string & note()
Return non-constant access to the optional note.
readOption readOpt() const
static constexpr const char * foamFile
Keyword for the FoamFile header sub-dictionary.
const word & headerClassName() const
Return name of the class name read from header.
virtual void rename(const word &newName)
Rename.
bool readHeader(Istream &)
Read header.
const word & name() const
Return name.
static bool writeHeader(Ostream &os, const IOstream::versionNumber version, const IOstream::streamFormat format, const word &type, const string ¬e, const fileName &location, const word &name)
Write header.
string str() const
Return the versionNumber as a character string.
static const versionNumber currentVersion
Current version number.
streamFormat format() const
Return current stream format.
virtual const fileName & name() const
Return the name of the stream.
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
streamFormat
Enumeration for the format of data in the stream.
versionNumber version() const
Return the stream version.
static streamFormat formatEnum(const word &)
Return stream format of given format name.
compressionType
Enumeration for the format of data in the stream.
bool good() const
Return true if next operation might succeed.
Input inter-processor communications stream.
Input from memory buffer stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool good() const
Return true if next operation might succeed.
void putBack(const token &)
Put back token.
void size(const label)
Override size to be inconsistent with allocated storage.
void operator=(const UList< T > &)
Assignment to UList operator. Takes linear time.
void setSize(const label)
Reset size of List.
Output inter-processor communications stream.
virtual ostream & stdStream()
Access to underlying std::ostream.
Output to memory buffer stream.
string str() const
Return the string.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & writeQuoted(const std::string &, const bool quoted=true)=0
Write std::string surrounded by quotes.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A List obtained as a section of another List.
Input 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.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const_iterator cbegin() const
Return const_iterator to begin traversing the constant UList.
label size() const
Return the number of elements in the UList.
iterator begin()
Return an iterator to begin traversing the UList.
std::streamsize byteSize() const
Return the binary size in number of characters of the UList.
Output inter-processor communications stream operating on external buffer.
virtual Ostream & write(const token &)
Write token.
commsTypes
Types of communications.
static int masterNo()
Process index of the master.
static bool master(const label communicator=0)
Am I the master process.
static const NamedEnum< commsTypes, 3 > commsTypeNames
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.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
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.
static int & msgType()
Message tag of standard messages.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
decomposedBlockData is a List<char> with IO on the master processor only.
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.
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 bool writeData(Ostream &) const
Write separated content. Assumes content is the serialised data.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
static void gather(const label comm, const label data, labelList &datas)
Helper: gather single label. Note: using native Pstream.
static label numBlocks(const fileName &)
Detect number of blocks in a file.
decomposedBlockData(const label comm, const IOobject &, const UPstream::commsTypes=UPstream::commsTypes::scheduled)
Construct given an IOobject.
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 autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
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 bool read()
Read object.
virtual ~decomposedBlockData()
Destructor.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
A class for handling file names.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool headerOk()
Read and check header info.
A token holds items read from Istream.
const word & wordToken() const
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define WarningInFunction
Report a warning using Foam::Warning.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
const fileOperation & fileHandler()
Get current file handler.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)