mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: additional control and access methods for PstreamBuffers
- PstreamBuffers nProcs() and allProcs() methods to recover the rank
information consistent with the communicator used for construction
- allowClearRecv() methods for more control over buffer reuse
For example,
pBufs.allowClearRecv(false);
forAll(particles, particlei)
{
pBufs.clear();
fill...
read via IPstream(..., pBufs);
}
This preserves the receive buffers memory allocation between calls.
- finishedNeighbourSends() method as compact wrapper for
finishedSends() when send/recv ranks are identically
(eg, neighbours)
- hasSendData()/hasRecvData() methods for PstreamBuffers.
Can be useful for some situations to skip reading entirely.
For example,
pBufs.finishedNeighbourSends(neighProcs);
if (!returnReduce(pBufs.hasRecvData(), orOp<bool>()))
{
// Nothing to do
continue;
}
...
On an individual basis:
for (const int proci : pBufs.allProcs())
{
if (pBufs.hasRecvData(proci))
{
...
}
}
Also conceivable to do the following instead (nonBlocking only):
if (!returnReduce(pBufs.hasSendData(), orOp<bool>()))
{
// Nothing to do
pBufs.clear();
continue;
}
pBufs.finishedNeighbourSends(neighProcs);
...
This commit is contained in:
committed by
Andrew Heather
parent
bfca84d11a
commit
14631984df
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,8 +96,7 @@ void Foam::functionObjects::syncObjects::sync()
|
||||
);
|
||||
|
||||
|
||||
const label nProcs = Pstream::nProcs(pBufs.comm());
|
||||
for (label proci = 0; proci < nProcs; proci++)
|
||||
for (const int proci : pBufs.allProcs())
|
||||
{
|
||||
// Get database to send
|
||||
const objectRegistry& sendObr = mappedPatchBase::subRegistry
|
||||
@ -123,7 +122,7 @@ void Foam::functionObjects::syncObjects::sync()
|
||||
// Start sending and receiving and block
|
||||
pBufs.finishedSends();
|
||||
|
||||
for (label proci = 0; proci < nProcs; proci++)
|
||||
for (const int proci : pBufs.allProcs())
|
||||
{
|
||||
// Get database to receive data into
|
||||
const objectRegistry& receiveObr = mappedPatchBase::subRegistry
|
||||
|
||||
Reference in New Issue
Block a user