Moving referral lists to be stored in ReferredCellList

This commit is contained in:
graham
2009-09-04 13:33:19 +01:00
parent 20f8d6a325
commit 940e68b9c8
8 changed files with 184 additions and 225 deletions

View File

@ -32,168 +32,6 @@ template<class ParticleType>
Foam::scalar Foam::InteractionLists<ParticleType>::transTol = 1e-12; Foam::scalar Foam::InteractionLists<ParticleType>::transTol = 1e-12;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParticleType>
void Foam::InteractionLists<ParticleType>::buildCellReferralLists()
{
Info<< " Determining particle referring schedule" << endl;
const ReferredCellList<ParticleType>& refIntL(ril());
DynamicList<label> referralProcs;
// Run through all ReferredCells to build list of interacting processors
forAll(refIntL, rIL)
{
const ReferredCell<ParticleType>& rC(refIntL[rIL]);
if (findIndex(referralProcs, rC.sourceProc()) == -1)
{
referralProcs.append(rC.sourceProc());
}
}
referralProcs.shrink();
// Pout << "referralProcs: " << nl << referralProcs << endl;
List<DynamicList<label> > cellSendingReferralLists(referralProcs.size());
List<DynamicList<DynamicList<label> > >
cellReceivingReferralLists(referralProcs.size());
// Run through all ReferredCells again building up send and receive info
forAll(refIntL, rIL)
{
const ReferredCell<ParticleType>& rC(refIntL[rIL]);
label rPI = findIndex(referralProcs, rC.sourceProc());
DynamicList<DynamicList<label> >& rRL(cellReceivingReferralLists[rPI]);
DynamicList<label>& sRL(cellSendingReferralLists[rPI]);
label existingSource = findIndex(sRL, rC.sourceCell());
// Check to see if this source cell has already been allocated to
// come to this processor. If not, add the source cell to the sending
// list and add the current referred cell to the receiving list.
// It shouldn't be possible for the sending and receiving lists to be
// different lengths, because their append operations happen at the
// same time.
if (existingSource == -1)
{
sRL.append(rC.sourceCell());
rRL.append
(
DynamicList<label> (labelList(1,rIL))
);
}
else
{
rRL[existingSource].append(rIL);
rRL[existingSource].shrink();
}
}
forAll(referralProcs, rPI)
{
DynamicList<DynamicList<label> >& rRL(cellReceivingReferralLists[rPI]);
DynamicList<label>& sRL(cellSendingReferralLists[rPI]);
sRL.shrink();
rRL.shrink();
}
// It is assumed that cell exchange is reciprocal, if proc A has cells to
// send to proc B, then proc B must have some to send to proc A.
cellReceivingReferralLists_.setSize(referralProcs.size());
cellSendingReferralLists_.setSize(referralProcs.size());
forAll(referralProcs, rPI)
{
DynamicList<DynamicList<label> >& rRL(cellReceivingReferralLists[rPI]);
labelListList translLL(rRL.size());
forAll(rRL, rRLI)
{
translLL[rRLI] = rRL[rRLI];
}
cellReceivingReferralLists_[rPI] = receivingReferralList
(
referralProcs[rPI],
translLL
);
}
// Send sendingReferralLists to each interacting processor.
forAll(referralProcs, rPI)
{
DynamicList<label>& sRL(cellSendingReferralLists[rPI]);
if (referralProcs[rPI] != Pstream::myProcNo())
{
if (Pstream::parRun())
{
OPstream toInteractingProc
(
Pstream::blocking,
referralProcs[rPI]
);
toInteractingProc << sendingReferralList
(
Pstream::myProcNo(),
sRL
);
}
}
}
// Receive sendingReferralLists from each interacting processor.
forAll(referralProcs, rPI)
{
if (referralProcs[rPI] != Pstream::myProcNo())
{
if (Pstream::parRun())
{
IPstream fromInteractingProc
(
Pstream::blocking,
referralProcs[rPI]
);
fromInteractingProc >> cellSendingReferralLists_[rPI];
}
}
else
{
cellSendingReferralLists_[rPI] = sendingReferralList
(
Pstream::myProcNo(),
cellSendingReferralLists[rPI]
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParticleType> template<class ParticleType>
@ -207,12 +45,8 @@ Foam::InteractionLists<ParticleType>::InteractionLists
mesh_(mesh), mesh_(mesh),
maxDistanceSqr_(maxDistanceSqr), maxDistanceSqr_(maxDistanceSqr),
dil_(*this, pointPointListBuild), dil_(*this, pointPointListBuild),
ril_(*this, pointPointListBuild), ril_(*this, pointPointListBuild)
cellSendingReferralLists_(), {}
cellReceivingReferralLists_()
{
buildCellReferralLists();
}
template<class ParticleType> template<class ParticleType>

View File

@ -42,9 +42,6 @@ SourceFiles
#include "DirectInteractionList.H" #include "DirectInteractionList.H"
#include "ReferredCell.H" #include "ReferredCell.H"
#include "ReferredCellList.H" #include "ReferredCellList.H"
#include "sendingReferralList.H"
#include "receivingReferralList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,17 +65,8 @@ class InteractionLists
ReferredCellList<ParticleType> ril_; ReferredCellList<ParticleType> ril_;
List<sendingReferralList> cellSendingReferralLists_;
List<receivingReferralList> cellReceivingReferralLists_;
// Private Member Functions // Private Member Functions
//- Build referralLists which define how to send information
// to ReferredCells to source cells
void buildCellReferralLists();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
InteractionLists(const InteractionLists&); InteractionLists(const InteractionLists&);
@ -191,15 +179,8 @@ public:
inline const DirectInteractionList<ParticleType>& dil() const; inline const DirectInteractionList<ParticleType>& dil() const;
inline const ReferredCellList<ParticleType>& ril() const; inline const ReferredCellList<ParticleType>& ril() const;
inline ReferredCellList<ParticleType>& ril(); inline ReferredCellList<ParticleType>& ril();
inline const List<sendingReferralList>&
cellSendingReferralLists() const;
inline const List<receivingReferralList>&
cellReceivingReferralLists() const;
inline label nInteractingProcs() const;
}; };

View File

@ -59,28 +59,4 @@ Foam::InteractionLists<ParticleType>::ril()
} }
template<class ParticleType>
inline const Foam::List<Foam::sendingReferralList>&
Foam::InteractionLists<ParticleType>::cellSendingReferralLists() const
{
return cellSendingReferralLists_;
}
template<class ParticleType>
inline const Foam::List<Foam::receivingReferralList>&
Foam::InteractionLists<ParticleType>::cellReceivingReferralLists() const
{
return cellReceivingReferralLists_;
}
template<class ParticleType>
inline Foam::label
Foam::InteractionLists<ParticleType>::nInteractingProcs() const
{
return cellReceivingReferralLists_.size();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -919,7 +919,8 @@ void Foam::ReferredCellList<ParticleType>::buildReferredCellList
mesh.boundaryMesh()[procPatches[pP]] mesh.boundaryMesh()[procPatches[pP]]
); );
DynamicList<ReferredCell<ParticleType> > ReferredCellsToTransfer; DynamicList<ReferredCell<ParticleType> >
ReferredCellsToTransfer;
const vectorList& neighbFaceCentres = const vectorList& neighbFaceCentres =
allNeighbourFaceCentres[pP]; allNeighbourFaceCentres[pP];
@ -1421,11 +1422,148 @@ void Foam::ReferredCellList<ParticleType>::buildReferredCellList
} }
template<class ParticleType>
void Foam::ReferredCellList<ParticleType>::buildCellReferralLists()
{
Info<< " Determining particle referring schedule" << endl;
DynamicList<label> referralProcs;
// Run through all ReferredCells to build list of interacting processors
forAll(*this, refCellI)
{
const ReferredCell<ParticleType>& refCell((*this)[refCellI]);
if (findIndex(referralProcs, refCell.sourceProc()) == -1)
{
referralProcs.append(refCell.sourceProc());
}
}
List<DynamicList<label> > cellSendingReferralLists(referralProcs.size());
List<DynamicList<DynamicList<label> > >
cellReceivingReferralLists(referralProcs.size());
// Run through all ReferredCells again building up send and receive info
forAll(*this, refCellI)
{
const ReferredCell<ParticleType>& rC((*this)[refCellI]);
label rPI = findIndex(referralProcs, rC.sourceProc());
DynamicList<DynamicList<label> >& rRL(cellReceivingReferralLists[rPI]);
DynamicList<label>& sRL(cellSendingReferralLists[rPI]);
label existingSource = findIndex(sRL, rC.sourceCell());
// Check to see if this source cell has already been allocated to
// come to this processor. If not, add the source cell to the sending
// list and add the current referred cell to the receiving list.
// It shouldn't be possible for the sending and receiving lists to be
// different lengths, because their append operations happen at the
// same time.
if (existingSource == -1)
{
sRL.append(rC.sourceCell());
rRL.append(DynamicList<label>(labelList(1, refCellI)));
}
else
{
rRL[existingSource].append(refCellI);
}
}
// It is assumed that cell exchange is reciprocal, if proc A has cells to
// send to proc B, then proc B must have some to send to proc A.
cellReceivingReferralLists_.setSize(referralProcs.size());
cellSendingReferralLists_.setSize(referralProcs.size());
forAll(referralProcs, rPI)
{
DynamicList<DynamicList<label> >& rRL(cellReceivingReferralLists[rPI]);
labelListList translLL(rRL.size());
forAll(rRL, rRLI)
{
translLL[rRLI] = rRL[rRLI];
}
cellReceivingReferralLists_[rPI] = receivingReferralList
(
referralProcs[rPI],
translLL
);
}
// Send sendingReferralLists to each interacting processor.
forAll(referralProcs, rPI)
{
DynamicList<label>& sRL(cellSendingReferralLists[rPI]);
if (referralProcs[rPI] != Pstream::myProcNo())
{
if (Pstream::parRun())
{
OPstream toInteractingProc
(
Pstream::blocking,
referralProcs[rPI]
);
toInteractingProc << sendingReferralList
(
Pstream::myProcNo(),
sRL
);
}
}
}
// Receive sendingReferralLists from each interacting processor.
forAll(referralProcs, rPI)
{
if (referralProcs[rPI] != Pstream::myProcNo())
{
if (Pstream::parRun())
{
IPstream fromInteractingProc
(
Pstream::blocking,
referralProcs[rPI]
);
fromInteractingProc >> cellSendingReferralLists_[rPI];
}
}
else
{
cellSendingReferralLists_[rPI] = sendingReferralList
(
Pstream::myProcNo(),
cellSendingReferralLists[rPI]
);
}
}
}
template<class ParticleType> template<class ParticleType>
void Foam::ReferredCellList<ParticleType>::storeParticles void Foam::ReferredCellList<ParticleType>::storeParticles
( (
const receivingReferralList& rRL, const receivingReferralList& rRL,
const labelList& destinationReferredCell, const labelList& sourceReferredCell,
IDLList<ParticleType>& particlesToReferIn IDLList<ParticleType>& particlesToReferIn
) )
{ {
@ -1441,7 +1579,7 @@ void Foam::ReferredCellList<ParticleType>::storeParticles
ParticleType& p = referInIter(); ParticleType& p = referInIter();
labelList refCellsToReferTo = labelList refCellsToReferTo =
rRL[destinationReferredCell[particleI]]; rRL[sourceReferredCell[particleI]];
forAll(refCellsToReferTo, refCellI) forAll(refCellsToReferTo, refCellI)
{ {
@ -1470,10 +1608,13 @@ Foam::ReferredCellList<ParticleType>::ReferredCellList
: :
List<ReferredCell<ParticleType> >(), List<ReferredCell<ParticleType> >(),
il_(il), il_(il),
cloud_(il_.mesh(), "referredParticleCloud", IDLList<ParticleType>()) cloud_(il_.mesh(), "referredParticleCloud", IDLList<ParticleType>()),
cellSendingReferralLists_(),
cellReceivingReferralLists_()
{ {
buildReferredCellList(pointPointListBuild); buildReferredCellList(pointPointListBuild);
buildCellReferralLists();
} }
@ -1516,11 +1657,11 @@ void Foam::ReferredCellList<ParticleType>::referParticles
// Create referred particles for sending using cell occupancy and // Create referred particles for sending using cell occupancy and
// cellSendingReferralLists // cellSendingReferralLists
forAll(il_.cellSendingReferralLists(), cSRL) forAll(cellSendingReferralLists_, cSRL)
{ {
const sendingReferralList& sRL const sendingReferralList& sRL
( (
il_.cellSendingReferralLists()[cSRL] cellSendingReferralLists_[cSRL]
); );
IDLList<ParticleType> particlesToReferOut; IDLList<ParticleType> particlesToReferOut;
@ -1565,7 +1706,7 @@ void Foam::ReferredCellList<ParticleType>::referParticles
const receivingReferralList& rRL const receivingReferralList& rRL
( (
il_.cellReceivingReferralLists()[cSRL] cellReceivingReferralLists_[cSRL]
); );
storeParticles(rRL, destinationReferredCell, particlesToReferOut); storeParticles(rRL, destinationReferredCell, particlesToReferOut);
@ -1576,16 +1717,16 @@ void Foam::ReferredCellList<ParticleType>::referParticles
// according to cellReceivingReferralLists, ReferredCells deal with the // according to cellReceivingReferralLists, ReferredCells deal with the
// transformations themselves // transformations themselves
forAll(il_.cellReceivingReferralLists(), cRRL) forAll(cellReceivingReferralLists_, cRRL)
{ {
const receivingReferralList& rRL const receivingReferralList& rRL
( (
il_.cellReceivingReferralLists()[cRRL] cellReceivingReferralLists_[cRRL]
); );
IDLList<ParticleType> particlesToReferIn; IDLList<ParticleType> particlesToReferIn;
labelList destinationReferredCell; labelList sourceReferredCell;
if (rRL.sourceProc() != Pstream::myProcNo()) if (rRL.sourceProc() != Pstream::myProcNo())
{ {
@ -1598,7 +1739,7 @@ void Foam::ReferredCellList<ParticleType>::referParticles
); );
fromInteractingProc fromInteractingProc
>> destinationReferredCell; >> sourceReferredCell;
particlesToReferIn = IDLList<ParticleType> particlesToReferIn = IDLList<ParticleType>
( (
@ -1607,7 +1748,7 @@ void Foam::ReferredCellList<ParticleType>::referParticles
); );
} }
storeParticles(rRL, destinationReferredCell, particlesToReferIn); storeParticles(rRL, sourceReferredCell, particlesToReferIn);
} }
} }

View File

@ -65,14 +65,24 @@ class ReferredCellList
//- Dummy cloud to give to particles //- Dummy cloud to give to particles
Cloud<ParticleType> cloud_; Cloud<ParticleType> cloud_;
List<sendingReferralList> cellSendingReferralLists_;
List<receivingReferralList> cellReceivingReferralLists_;
// Private Member Functions // Private Member Functions
//- Refer and rerefer cells to construct referred interactions
void buildReferredCellList void buildReferredCellList
( (
bool pointPointListBuild bool pointPointListBuild
); );
//- Build referralLists which define how to send information
// to ReferredCells to source cells
void buildCellReferralLists();
//- Store the referred particles in the referred cells //- Store the referred particles in the referred cells
void storeParticles void storeParticles
( (
@ -110,6 +120,8 @@ public:
); );
inline const InteractionLists<ParticleType>& il() const; inline const InteractionLists<ParticleType>& il() const;
inline label nInteractingProcs() const;
}; };

View File

@ -34,4 +34,12 @@ Foam::ReferredCellList<ParticleType>::il() const
} }
template<class ParticleType>
inline Foam::label
Foam::ReferredCellList<ParticleType>::nInteractingProcs() const
{
return cellReceivingReferralLists_.size();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,6 +26,11 @@ Class
Foam::receivingReferralList Foam::receivingReferralList
Description Description
Contains an outer list which has entries corresponding to the
incoming particles sent by the sendingReferralList on the source
processor. The inner list has the indices of the referred cells
on the current processor to refer the particles to, as a real cell
may be referred multiple times.
SourceFiles SourceFiles
receivingReferralListI.H receivingReferralListI.H

View File

@ -26,6 +26,8 @@ Class
Foam::sendingReferralList Foam::sendingReferralList
Description Description
Contains the list of the real cells on the current processor to be
referred to the destination processor
SourceFiles SourceFiles
sendingReferralListI.H sendingReferralListI.H