55 const word& objectType
84 commsType_(commsType),
92 <<
"decomposedBlockData " <<
name()
93 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
94 " but decomposedBlockData does not support automatic rereading."
132 if (!isDictFormat && tok.
good())
164 std::streamoff blockOffset =
os.
stdStream().tellp();
169 os <<
nl <<
"// " << procName <<
nl;
183 const bool withLocalHeader
204 ok = ok &&
io.writeData(
os);
208 return std::streamoff(-1);
211 contentChars =
os.str();
217 const_cast<char*
>(contentChars.data()),
218 label(contentChars.size())
235 Pout<<
"decomposedBlockData::readBlock:"
236 <<
" stream:" << is.
name() <<
" attempt to read block " << blocki
254 realIsPtr->name() = is.
name();
262 <<
"Problem while reading object header "
276 <<
"Problem while reading object header "
285 for (label i = 1; i < blocki+1; i++)
291 realIsPtr->name() = is.
name();
294 realIsPtr().format(streamOptData.
format());
295 realIsPtr().version(streamOptData.
version());
296 realIsPtr().setLabelByteSize(labelWidth);
297 realIsPtr().setScalarByteSize(scalarWidth);
314 Pout<<
"decomposedBlockData::readBlocks:"
315 <<
" stream:" << (isPtr ? isPtr->name() :
"invalid")
317 <<
" comm:" << comm <<
endl;
418 Pout<<
"decomposedBlockData::readBlocks:"
419 <<
" stream:" << (isPtr ? isPtr->name() :
"invalid")
436 realIsPtr->name() = fName;
444 <<
"Problem while reading object header "
445 << is.relativeName() <<
nl
490 realIsPtr->name() = fName;
524 realIsPtr->name() = fName;
536 unsigned scalarWidth;
541 verValue = realIsPtr().version().canonical();
542 fmtValue =
static_cast<int>(realIsPtr().format());
543 labelWidth = realIsPtr().labelByteSize();
544 scalarWidth = realIsPtr().scalarByteSize();
563 realIsPtr().setLabelByteSize(labelWidth);
564 realIsPtr().setScalarByteSize(scalarWidth);
566 headerIO.
rename(headerName);
589 forAll(recvOffsets, proci)
594 int(
reinterpret_cast<char*
>(&datas[proci]) - data0Ptr);
596 recvSizes.
setSize(nProcs,
sizeof(label));
601 reinterpret_cast<const char*
>(&
data),
617 const label startProc,
630 sliceSizes.
resize(numProcs, 0);
631 sliceOffsets.
resize(numProcs+1, 0);
634 label proci = startProc;
635 for (label i = 0; i < nProcs; i++)
637 sliceSizes[proci] = int(recvSizes[proci]);
638 sliceOffsets[proci] = totalSize;
639 totalSize += sliceSizes[proci];
642 sliceOffsets[proci] = totalSize;
655 nSend = int(
data.size_bytes());
674 const off_t maxBufferSize,
676 const label startProci
681 label nSendProcs = -1;
684 off_t totalSize = recvSizes[startProci];
685 label proci = startProci+1;
686 while (proci < nProcs && (totalSize+recvSizes[proci] < maxBufferSize))
688 totalSize += recvSizes[proci];
692 nSendProcs = proci-startProci;
699 reinterpret_cast<const char*
>(&nSendProcs),
702 reinterpret_cast<char*
>(&
n),
722 const bool syncReturnState
727 Pout<<
"decomposedBlockData::writeBlocks:"
728 <<
" stream:" << (osPtr ? osPtr->name() :
"invalid")
729 <<
" data:" << masterData.
size()
730 <<
" (master only) slaveData:" << slaveData.size()
741 blockOffset.
resize(nProcs);
756 if (slaveData.size())
766 for (label proci = 1; proci < nProcs; ++proci)
789 for (label proci = 1; proci < nProcs; ++proci)
791 elems.
resize(recvSizes[proci]);
835 label nSendProcs = nProcs-1;
837 while (nSendProcs > 0 && startProc < nProcs)
839 nSendProcs = calcNumProcs
845 maxMasterFileBufferSize
880 label proci = startProc;
881 proci < startProc+nSendProcs;
888 sliceOffsets[proci+1]-sliceOffsets[proci],
902 startProc += nSendProcs;
932 return readBlocks(comm_, isPtr, contentData_, commsType_);
944 fileName masterLocation(instance()/db().dbDir()/local());
953 fmtValue =
static_cast<int>(headerStream.
format());
975 decomposedBlockData::writeHeader
988 if (isA<OFstream>(
os))
991 os.
writeRaw(contentData_.cdata(), contentData_.size_bytes());
996 std::string str(contentData_.cdata(), contentData_.size_bytes());
1029 decomposedBlockData::writeHeader
1033 static_cast<const IOobject&
>(*
this)
1038 gather(comm_, label(contentData_.size_bytes()), recvSizes);
Input/output streams with managed List storage.
Input/output from string buffers.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void resize(const label len)
Input from file stream, using an ISstream.
An ISstream with internal List storage. Always UNCOMPRESSED.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
const word & headerClassName() const noexcept
Return name of the class name read from header.
bool readHeader(Istream &is)
static bool bannerEnabled() noexcept
Status of output file banner.
readOption readOpt() const noexcept
The read option.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
bool good() const noexcept
Did last readHeader() succeed?
virtual void rename(const word &newName)
Rename the object.
const string & note() const noexcept
Return the optional note.
bool writeHeader(Ostream &os) const
Write header with current type()
int canonical() const noexcept
From version to canonical integer value.
The IOstreamOption is a simple container for options an IOstream can normally have.
versionNumber version() const noexcept
Get the stream version.
streamFormat format() const noexcept
Get the current stream format.
streamFormat
Data format (ascii | binary)
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
unsigned scalarByteSize() const noexcept
The sizeof (scalar) in bytes associated with the stream.
bool good() const noexcept
True if next operation might succeed.
unsigned labelByteSize() const noexcept
The sizeof (label) in bytes associated with the stream.
fileName relativeName() const
Return the name of the stream relative to the current case.
Input inter-processor communications stream.
Generic input stream using a standard (STL) stream.
virtual const fileName & name() const
Return the name of the stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label n)
Alias for resize()
void resize(const label len)
Adjust allocated size of list.
Istream & readList(Istream &is)
Read List from Istream, discarding contents of existing List.
virtual Ostream & writeQuoted(const std::string &str, const bool quoted=true)
Write std::string surrounded by quotes.
Output to file stream, using an OSstream.
virtual std::ostream & stdStream()
Access to underlying std::ostream.
Output inter-processor communications stream.
Generic output stream using a standard (STL) stream.
virtual Ostream & writeRaw(const char *data, std::streamsize count)
Low-level raw binary output.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
void finishedScatters(const bool wait=true)
Mark all sends to sub-procs as done.
UPstream::rangeType subProcs() const noexcept
Range of sub-processes indices associated with PstreamBuffers.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all processes in communicator.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
virtual bool read()
Re-read model coefficients if they have changed.
A List obtained as a section of another List.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
commsTypes
Types of communications.
@ nonBlocking
"nonBlocking"
static const Enum< commsTypes > commsTypeNames
Names of the communication types.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
static void gather(const char *sendData, int sendCount, char *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, const label communicator=worldComm)
Receive variable length char data from all ranks.
static label worldComm
Default communicator (all processors)
static void scatter(const char *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, char *recvData, int recvCount, const label communicator=worldComm)
Send variable length char data to all ranks.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
bool good() const noexcept
True if the managed pointer is non-null.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Database for solution data, solver performance and other reduced data.
The decomposedBlockData comprise a List<char> for each output processor, typically with IO on the mas...
static bool readBlockEntry(Istream &is, List< char > &charData)
Helper: read block of (binary) character data.
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.
static std::streamoff writeBlockEntry(OSstream &os, const label blocki, const UList< char > &charData)
Helper: write block of (binary) character data.
virtual bool writeData(Ostream &os) const
Write separated content (assumes content is the serialised data)
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static void gather(const label comm, const label data, labelList &datas)
Helper: gather single label. Note: using native Pstream.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
static bool writeBlocks(const label comm, autoPtr< OSstream > &osPtr, List< std::streamoff > &blockOffset, 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.
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
static label calcNumProcs(const label comm, const off_t maxBufferSize, const labelUList &recvSizes, const label startProci)
virtual bool read()
Read object.
static bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &contentChars, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
virtual bool write()
Write the output fields.
int myProcNo() const noexcept
Return processor number.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool headerOk()
Read and check header info. Does not check the headerClassName.
splitCell * master() const
A token holds an item read from Istream.
@ END_STATEMENT
End entry [isseparator].
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
bool isCompound() const noexcept
Token is COMPOUND.
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
const fileOperation & fileHandler()
Get current file handler.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
static const char *const typeName
The type name used in ensight case files.