diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H index 64faa6508b..8bf5df2a23 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H @@ -64,8 +64,7 @@ class Pstream { // Private Static Functions - //- Exchange contiguous data. Sends sendData, receives into - // recvData. If block=true will wait for all transfers to finish. + //- Exchange contiguous data. Sends sendBufs, receives into recvBufs. // Data provided and received as container. template static void exchangeContainer @@ -75,11 +74,10 @@ class Pstream List& recvBufs, const int tag, const label comm, - const bool block //!< Wait for all to finish + const bool wait //!< Wait for requests to complete ); - //- Exchange contiguous data. Sends sendData, receives into - // recvData. If block=true will wait for all transfers to finish. + //- Exchange contiguous data. Sends sendBufs, receives into recvBufs. // Data provided and received as pointers. template static void exchangeBuf @@ -90,7 +88,7 @@ class Pstream List& recvBufs, const int tag, const label comm, - const bool block //!< Wait for all to finish + const bool wait //!< Wait for requests to complete ); @@ -119,7 +117,7 @@ public: : UPstream(commsType) { - if (bufSize) + if (bufSize > 0) { transferBuf_.setCapacity(bufSize + 2*sizeof(scalar) + 1); } @@ -438,7 +436,7 @@ public: List& recvData, const int tag = UPstream::msgType(), const label comm = UPstream::worldComm, - const bool block = true + const bool wait = true //!< Wait for requests to complete ); //- Exchange contiguous data. Sends sendData, receives into @@ -451,7 +449,7 @@ public: List& recvData, const int tag = UPstream::msgType(), const label comm = UPstream::worldComm, - const bool block = true + const bool wait = true //!< Wait for requests to complete ); }; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamExchange.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamExchange.C index 81e730f953..903f2428f8 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamExchange.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamExchange.C @@ -43,7 +43,7 @@ void Foam::Pstream::exchangeContainer List& recvBufs, const int tag, const label comm, - const bool block + const bool wait ) { const label startOfRequests = Pstream::nRequests(); @@ -101,7 +101,7 @@ void Foam::Pstream::exchangeContainer // Wait for all to finish // ~~~~~~~~~~~~~~~~~~~~~~ - if (block) + if (wait) { UPstream::waitRequests(startOfRequests); } @@ -117,7 +117,7 @@ void Foam::Pstream::exchangeBuf List& recvBufs, const int tag, const label comm, - const bool block + const bool wait ) { const label startOfRequests = Pstream::nRequests(); @@ -175,7 +175,7 @@ void Foam::Pstream::exchangeBuf // Wait for all to finish // ~~~~~~~~~~~~~~~~~~~~~~ - if (block) + if (wait) { UPstream::waitRequests(startOfRequests); } @@ -190,7 +190,7 @@ void Foam::Pstream::exchange List& recvBufs, const int tag, const label comm, - const bool block + const bool wait ) { // OR static_assert(is_contiguous::value, "Contiguous data only!") @@ -234,7 +234,7 @@ void Foam::Pstream::exchange recvBufs, tag, comm, - block + wait ); } else @@ -327,7 +327,7 @@ void Foam::Pstream::exchange charRecvBufs, tag, comm, - block + wait ); forAll(nSend, proci) @@ -410,21 +410,14 @@ void Foam::Pstream::exchangeSizes /// template /// void Foam::Pstream::exchangeSizes /// ( -/// const labelUList& sendRecvProcs, +/// const labelUList& neighProcs, /// const Container& sendBufs, /// labelList& recvSizes, /// const label tag, /// const label comm /// ) /// { -/// exchangeSizes -/// ( -/// sendRecvProcs, -/// sendRecvProcs, -/// sendBufs, -/// tag, -/// comm -/// ); +/// exchangeSizes(neighProcs, neighProcs, sendBufs, tag, comm); /// } @@ -462,13 +455,13 @@ void Foam::Pstream::exchange List& recvBufs, const int tag, const label comm, - const bool block + const bool wait ) { labelList recvSizes; exchangeSizes(sendBufs, recvSizes, comm); - exchange(sendBufs, recvSizes, recvBufs, tag, comm, block); + exchange(sendBufs, recvSizes, recvBufs, tag, comm, wait); } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H index 580a47085e..5c22fc28c1 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H @@ -177,17 +177,20 @@ public: return true; } - //- Rewind the stream so that it may be read again - void rewind(); + + // Positioning + + //- Rewind the receive stream position so that it may be read again + virtual void rewind(); - // Edit + // Edit - //- Set flags of stream - virtual ios_base::fmtflags flags(const ios_base::fmtflags) - { - return ios_base::fmtflags(0); - } + //- Set flags of stream + virtual ios_base::fmtflags flags(const ios_base::fmtflags) + { + return ios_base::fmtflags(0); + } // Print diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstreamBase.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstreamBase.C index 4a6108788b..e7d8266f32 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstreamBase.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstreamBase.C @@ -490,9 +490,26 @@ bool Foam::UIPstreamBase::beginRawRead() } +// Not needed yet +/// +/// //- The current get position (tellg) in the buffer +/// label pos() const; +/// +/// Foam::label Foam::UIPstreamBase::pos() const +/// { +/// return recvBufPos_; +/// } + + void Foam::UIPstreamBase::rewind() { - recvBufPos_ = 0; + recvBufPos_ = 0; // Assume the entire buffer is for us to read from + setOpened(); + setGood(); + if (recvBuf_.empty() || !messageSize_) + { + setEof(); + } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H index 2e0c184378..e7d8e3a97a 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H @@ -251,13 +251,19 @@ public: } - // Edit + // Positioning - //- Set flags of stream - virtual ios_base::fmtflags flags(const ios_base::fmtflags) - { - return ios_base::fmtflags(0); - } + //- Rewind the send buffer for overwriting + virtual void rewind(); + + + // Edit + + //- Set flags of stream + virtual ios_base::fmtflags flags(const ios_base::fmtflags) + { + return ios_base::fmtflags(0); + } // Print diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstreamBase.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstreamBase.C index 25992abec8..9cafc25cbf 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstreamBase.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstreamBase.C @@ -369,6 +369,25 @@ bool Foam::UOPstreamBase::beginRawWrite(std::streamsize count) } +// Not needed yet +/// +/// //- The current put position (tellp) in the buffer +/// label pos() const; +/// +/// Foam::label Foam::UOPstreamBase::pos() const +/// { +/// return sendBuf_.size(); +/// } + + +void Foam::UOPstreamBase::rewind() +{ + sendBuf_.clear(); // Overwrite into buffer + setOpened(); + setGood(); +} + + void Foam::UOPstreamBase::print(Ostream& os) const { os << "Writing from processor " << toProcNo_