Go to the documentation of this file.
58 commsType_(commsType),
62 if (io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED)
65 <<
"decomposedBlockData " <<
name()
66 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
67 " but decomposedBlockData does not support automatic rereading."
73 io.
readOpt() == IOobject::MUST_READ
74 || io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED
76 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
93 commsType_(commsType),
97 if (io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED)
100 <<
"decomposedBlockData " <<
name()
101 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
102 " but decomposedBlockData does not support automatic rereading."
109 io.
readOpt() == IOobject::MUST_READ
110 || io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED
112 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
133 commsType_(commsType),
137 if (io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED)
140 <<
"decomposedBlockData " <<
name()
141 <<
" constructed with IOobject::MUST_READ_IF_MODIFIED"
142 " but decomposedBlockData does not support automatic rereading."
151 io.
readOpt() == IOobject::MUST_READ
152 || io.
readOpt() == IOobject::MUST_READ_IF_MODIFIED
154 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
174 Pout<<
"decomposedBlockData::readMasterHeader:"
182 is.
fatalCheck(
"read(Istream&) : reading entry");
208 <<
" version " <<
version <<
";\n"
209 <<
" format " <<
format <<
";\n"
210 <<
" class " <<
type <<
";\n";
227 os <<
" note " << note <<
";\n";
232 os <<
" location " << location <<
";\n";
235 os <<
" object " <<
name <<
";\n"
251 Pout<<
"decomposedBlockData::readBlock:"
252 <<
" stream:" << is.
name() <<
" attempt to read block " << blocki
264 is.
fatalCheck(
"read(Istream&) : reading entry");
281 <<
"problem while reading header for object "
289 is.
fatalCheck(
"read(Istream&) : reading entry");
306 <<
"problem while reading header for object "
309 ver = headerStream.version();
310 fmt = headerStream.format();
313 for (
label i = 1; i < blocki+1; i++)
317 is.
fatalCheck(
"read(Istream&) : reading entry");
331 realIsPtr().format(fmt);
332 realIsPtr().version(ver);
348 Pout<<
"decomposedBlockData::readBlocks:"
349 <<
" stream:" << (isPtr.
valid() ? isPtr().name() :
"invalid")
351 <<
" comm:" << comm <<
endl;
366 is.
fatalCheck(
"read(Istream&) : reading entry");
378 is.
fatalCheck(
"read(Istream&) : reading entry");
423 is.
fatalCheck(
"read(Istream&) : reading entry");
435 is.
fatalCheck(
"read(Istream&) : reading entry");
469 Pout<<
"decomposedBlockData::readBlocks:"
470 <<
" stream:" << (isPtr.
valid() ? isPtr().name() :
"invalid")
489 is.
fatalCheck(
"read(Istream&) : reading entry");
507 <<
"problem while reading header for object "
521 is.
fatalCheck(
"read(Istream&) : reading entry");
577 is.
fatalCheck(
"read(Istream&) : reading entry");
594 <<
"problem while reading header for object "
608 is.
fatalCheck(
"read(Istream&) : reading entry");
641 string versionString(realIsPtr().
version().str());
648 os << realIsPtr().format();
649 string formatString(os.
str());
651 realIsPtr().format(formatString);
676 char* data0Ptr =
reinterpret_cast<char*
>(datas.begin());
683 forAll(recvOffsets, proci)
688 int(
reinterpret_cast<char*
>(&datas[proci]) - data0Ptr);
695 reinterpret_cast<const char*
>(&
data),
711 const label startProc,
724 sliceSizes.
setSize(numProcs, 0);
725 sliceOffsets.
setSize(numProcs+1, 0);
728 label proci = startProc;
729 for (
label i = 0; i < nProcs; i++)
731 sliceSizes[proci] = int(recvSizes[proci]);
732 sliceOffsets[proci] = totalSize;
733 totalSize += sliceSizes[proci];
736 sliceOffsets[proci] = totalSize;
749 nSend = int(
data.byteSize());
768 const off_t maxBufferSize,
770 const label startProci
775 label nSendProcs = -1;
778 off_t totalSize = recvSizes[startProci];
779 label proci = startProci+1;
780 while (proci < nProcs && (totalSize+recvSizes[proci] < maxBufferSize))
782 totalSize += recvSizes[proci];
786 nSendProcs = proci-startProci;
793 reinterpret_cast<const char*
>(&nSendProcs),
796 reinterpret_cast<char*
>(&
n),
816 const bool syncReturnState
821 Pout<<
"decomposedBlockData::writeBlocks:"
822 <<
" stream:" << (osPtr.
valid() ? osPtr().name() :
"invalid")
823 <<
" data:" <<
data.size()
824 <<
" (master only) slaveData:" << slaveData.size()
832 if (slaveData.size())
841 start.setSize(nProcs);
852 label slaveOffset = 0;
854 for (
label proci = 1; proci < nProcs; ++proci)
856 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
859 os << slaveData[proci];
860 slaveOffset += recvSizes[proci];
870 start.setSize(nProcs);
882 for (
label proci = 1; proci < nProcs; ++proci)
884 elems.
setSize(recvSizes[proci]);
895 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
920 start.setSize(nProcs);
935 label nSendProcs = nProcs-1;
937 while (nSendProcs > 0 && startProc < nProcs)
939 nSendProcs = calcNumProcs
945 maxMasterFileBufferSize
980 label proci = startProc;
981 proci < startProc+nSendProcs;
985 os <<
nl <<
nl <<
"// Processor" << proci <<
nl;
992 sliceOffsets[proci+1]-sliceOffsets[proci],
998 startProc += nSendProcs;
1003 ok = osPtr().good();
1007 if (syncReturnState)
1029 return readBlocks(comm_, isPtr,
data, commsType_);
1059 string formatString;
1063 formatString = os.
str();
1075 fileName masterLocation(instance()/db().dbDir()/local());
1094 reinterpret_cast<const char*
>(
data.cbegin()),
1126 gather(comm_,
label(this->byteSize()), recvSizes);
1148 is.
fatalCheck(
"decomposedBlockData::numBlocks(const fileName&)");
1156 token firstToken(is);
1170 headerDict.
get<
float>(
"version")
1186 token sizeToken(is);
int debug
Static debugging option.
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,...
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
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.
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?
streamFormat format() const noexcept
Get the current stream format.
static const versionNumber currentVersion
The current version number.
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.
Input/output from string buffers.
const fileOperation & fileHandler()
Get current file handler.
bool valid() const noexcept
True if the managed pointer is non-null.
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.
virtual ~decomposedBlockData()
Destructor.
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.
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 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.
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.
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 writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool valid) const
Write using given format, version and compression.
virtual const fileName & name() const
Return the name of the stream.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
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.
decomposedBlockData(const label comm, const IOobject &io, const UPstream::commsTypes=UPstream::commsTypes::scheduled)
Construct given an IOobject.
virtual bool writeData(Ostream &) const
Write separated content. Assumes content is the serialised data.
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.
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.
Foam::string str() const
Get the string - as Foam::string rather than std::string.
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 streamFormat formatEnum(const word &formatName)
The stream format enum corresponding to the string.
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...
readOption readOpt() const
The read option.
Output to string buffer, using a OSstream.
void putBack(const token &tok)
Put back token.
label ListType::const_reference const label start
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
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.
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
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)
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
Database for solution data, solver performance and other reduced data.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
virtual bool read()
Read object.
static label numBlocks(const fileName &)
Detect number of blocks in a file.