nonblocking transfer of particles

This commit is contained in:
mattijs
2009-11-21 10:54:02 +00:00
parent d0e866f2ca
commit e226745a87

View File

@ -105,20 +105,15 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
const globalMeshData& pData = polyMesh_.globalData(); const globalMeshData& pData = polyMesh_.globalData();
const labelList& processorPatches = pData.processorPatches(); const labelList& processorPatches = pData.processorPatches();
const labelList& processorPatchIndices = pData.processorPatchIndices(); const labelList& processorPatchIndices = pData.processorPatchIndices();
const labelList& processorPatchNeighbours =
pData.processorPatchNeighbours();
// Initialise the setpFraction moved for the particles // Initialise the stepFraction moved for the particles
forAllIter(typename Cloud<ParticleType>, *this, pIter) forAllIter(typename Cloud<ParticleType>, *this, pIter)
{ {
pIter().stepFraction() = 0; pIter().stepFraction() = 0;
} }
// Assume there will be particles to transfer
bool transfered = true;
// While there are particles to transfer // While there are particles to transfer
while (transfered) while (true)
{ {
// List of lists of particles to be transfered for all the processor // List of lists of particles to be transfered for all the processor
// patches // patches
@ -158,24 +153,39 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
} }
} }
if (Pstream::parRun()) if (!Pstream::parRun())
{ {
// List of the numbers of particles to be transfered across the break;
// processor patches
labelList nsTransPs(transferList.size());
forAll(transferList, i)
{
nsTransPs[i] = transferList[i].size();
} }
// List of the numbers of particles to be transfered across the
// processor patches for all the processors
labelListList allNTrans(Pstream::nProcs());
allNTrans[Pstream::myProcNo()] = nsTransPs;
combineReduce(allNTrans, UPstream::listEq());
transfered = false; // Allocate transfer buffers
PstreamBuffers pBufs(Pstream::nonBlocking);
// Stream into send buffers
forAll(transferList, i)
{
if (transferList[i].size())
{
UOPstream particleStream
(
refCast<const processorPolyPatch>
(
pMesh().boundaryMesh()[processorPatches[i]]
).neighbProcNo(),
pBufs
);
particleStream << transferList[i];
}
}
// Set up transfers when in non-blocking mode. Returns sizes (in bytes)
// to be sent/received.
labelListList allNTrans(Pstream::nProcs());
pBufs.finishedSends(allNTrans);
bool transfered = false;
forAll(allNTrans, i) forAll(allNTrans, i)
{ {
@ -194,23 +204,8 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
break; break;
} }
forAll(transferList, i)
{
if (transferList[i].size())
{
OPstream particleStream
(
Pstream::blocking,
refCast<const processorPolyPatch>
(
pMesh().boundaryMesh()[processorPatches[i]]
).neighbProcNo()
);
particleStream << transferList[i];
}
}
// Retrieve from receive buffers
forAll(processorPatches, i) forAll(processorPatches, i)
{ {
label patchi = processorPatches[i]; label patchi = processorPatches[i];
@ -219,20 +214,14 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
refCast<const processorPolyPatch> refCast<const processorPolyPatch>
(pMesh().boundaryMesh()[patchi]); (pMesh().boundaryMesh()[patchi]);
label neighbProci = label neighbProci = procPatch.neighbProcNo();
procPatch.neighbProcNo() - Pstream::masterNo();
label neighbProcPatchi = processorPatchNeighbours[patchi]; label nRecPs = allNTrans[neighbProci][Pstream::myProcNo()];
label nRecPs = allNTrans[neighbProci][neighbProcPatchi];
if (nRecPs) if (nRecPs)
{ {
IPstream particleStream UIPstream particleStream(neighbProci, pBufs);
(
Pstream::blocking,
procPatch.neighbProcNo()
);
IDLList<ParticleType> newParticles IDLList<ParticleType> newParticles
( (
particleStream, particleStream,
@ -253,11 +242,6 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
} }
} }
} }
else
{
transfered = false;
}
}
} }