mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Moving referral lists to be stored in ReferredCellList
This commit is contained in:
@ -32,168 +32,6 @@ template<class ParticleType>
|
||||
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 * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParticleType>
|
||||
@ -207,12 +45,8 @@ Foam::InteractionLists<ParticleType>::InteractionLists
|
||||
mesh_(mesh),
|
||||
maxDistanceSqr_(maxDistanceSqr),
|
||||
dil_(*this, pointPointListBuild),
|
||||
ril_(*this, pointPointListBuild),
|
||||
cellSendingReferralLists_(),
|
||||
cellReceivingReferralLists_()
|
||||
{
|
||||
buildCellReferralLists();
|
||||
}
|
||||
ril_(*this, pointPointListBuild)
|
||||
{}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
|
||||
@ -42,9 +42,6 @@ SourceFiles
|
||||
#include "DirectInteractionList.H"
|
||||
#include "ReferredCell.H"
|
||||
#include "ReferredCellList.H"
|
||||
#include "sendingReferralList.H"
|
||||
#include "receivingReferralList.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -68,17 +65,8 @@ class InteractionLists
|
||||
|
||||
ReferredCellList<ParticleType> ril_;
|
||||
|
||||
List<sendingReferralList> cellSendingReferralLists_;
|
||||
|
||||
List<receivingReferralList> cellReceivingReferralLists_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Build referralLists which define how to send information
|
||||
// to ReferredCells to source cells
|
||||
void buildCellReferralLists();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
InteractionLists(const InteractionLists&);
|
||||
|
||||
@ -191,15 +179,8 @@ public:
|
||||
inline const DirectInteractionList<ParticleType>& dil() const;
|
||||
|
||||
inline const ReferredCellList<ParticleType>& ril() const;
|
||||
|
||||
inline ReferredCellList<ParticleType>& ril();
|
||||
|
||||
inline const List<sendingReferralList>&
|
||||
cellSendingReferralLists() const;
|
||||
|
||||
inline const List<receivingReferralList>&
|
||||
cellReceivingReferralLists() const;
|
||||
|
||||
inline label nInteractingProcs() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -919,7 +919,8 @@ void Foam::ReferredCellList<ParticleType>::buildReferredCellList
|
||||
mesh.boundaryMesh()[procPatches[pP]]
|
||||
);
|
||||
|
||||
DynamicList<ReferredCell<ParticleType> > ReferredCellsToTransfer;
|
||||
DynamicList<ReferredCell<ParticleType> >
|
||||
ReferredCellsToTransfer;
|
||||
|
||||
const vectorList& neighbFaceCentres =
|
||||
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>
|
||||
void Foam::ReferredCellList<ParticleType>::storeParticles
|
||||
(
|
||||
const receivingReferralList& rRL,
|
||||
const labelList& destinationReferredCell,
|
||||
const labelList& sourceReferredCell,
|
||||
IDLList<ParticleType>& particlesToReferIn
|
||||
)
|
||||
{
|
||||
@ -1441,7 +1579,7 @@ void Foam::ReferredCellList<ParticleType>::storeParticles
|
||||
ParticleType& p = referInIter();
|
||||
|
||||
labelList refCellsToReferTo =
|
||||
rRL[destinationReferredCell[particleI]];
|
||||
rRL[sourceReferredCell[particleI]];
|
||||
|
||||
forAll(refCellsToReferTo, refCellI)
|
||||
{
|
||||
@ -1470,10 +1608,13 @@ Foam::ReferredCellList<ParticleType>::ReferredCellList
|
||||
:
|
||||
List<ReferredCell<ParticleType> >(),
|
||||
il_(il),
|
||||
cloud_(il_.mesh(), "referredParticleCloud", IDLList<ParticleType>())
|
||||
|
||||
cloud_(il_.mesh(), "referredParticleCloud", IDLList<ParticleType>()),
|
||||
cellSendingReferralLists_(),
|
||||
cellReceivingReferralLists_()
|
||||
{
|
||||
buildReferredCellList(pointPointListBuild);
|
||||
|
||||
buildCellReferralLists();
|
||||
}
|
||||
|
||||
|
||||
@ -1516,11 +1657,11 @@ void Foam::ReferredCellList<ParticleType>::referParticles
|
||||
// Create referred particles for sending using cell occupancy and
|
||||
// cellSendingReferralLists
|
||||
|
||||
forAll(il_.cellSendingReferralLists(), cSRL)
|
||||
forAll(cellSendingReferralLists_, cSRL)
|
||||
{
|
||||
const sendingReferralList& sRL
|
||||
(
|
||||
il_.cellSendingReferralLists()[cSRL]
|
||||
cellSendingReferralLists_[cSRL]
|
||||
);
|
||||
|
||||
IDLList<ParticleType> particlesToReferOut;
|
||||
@ -1565,7 +1706,7 @@ void Foam::ReferredCellList<ParticleType>::referParticles
|
||||
|
||||
const receivingReferralList& rRL
|
||||
(
|
||||
il_.cellReceivingReferralLists()[cSRL]
|
||||
cellReceivingReferralLists_[cSRL]
|
||||
);
|
||||
|
||||
storeParticles(rRL, destinationReferredCell, particlesToReferOut);
|
||||
@ -1576,16 +1717,16 @@ void Foam::ReferredCellList<ParticleType>::referParticles
|
||||
// according to cellReceivingReferralLists, ReferredCells deal with the
|
||||
// transformations themselves
|
||||
|
||||
forAll(il_.cellReceivingReferralLists(), cRRL)
|
||||
forAll(cellReceivingReferralLists_, cRRL)
|
||||
{
|
||||
const receivingReferralList& rRL
|
||||
(
|
||||
il_.cellReceivingReferralLists()[cRRL]
|
||||
cellReceivingReferralLists_[cRRL]
|
||||
);
|
||||
|
||||
IDLList<ParticleType> particlesToReferIn;
|
||||
|
||||
labelList destinationReferredCell;
|
||||
labelList sourceReferredCell;
|
||||
|
||||
if (rRL.sourceProc() != Pstream::myProcNo())
|
||||
{
|
||||
@ -1598,7 +1739,7 @@ void Foam::ReferredCellList<ParticleType>::referParticles
|
||||
);
|
||||
|
||||
fromInteractingProc
|
||||
>> destinationReferredCell;
|
||||
>> sourceReferredCell;
|
||||
|
||||
particlesToReferIn = IDLList<ParticleType>
|
||||
(
|
||||
@ -1607,7 +1748,7 @@ void Foam::ReferredCellList<ParticleType>::referParticles
|
||||
);
|
||||
}
|
||||
|
||||
storeParticles(rRL, destinationReferredCell, particlesToReferIn);
|
||||
storeParticles(rRL, sourceReferredCell, particlesToReferIn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,14 +65,24 @@ class ReferredCellList
|
||||
//- Dummy cloud to give to particles
|
||||
Cloud<ParticleType> cloud_;
|
||||
|
||||
List<sendingReferralList> cellSendingReferralLists_;
|
||||
|
||||
List<receivingReferralList> cellReceivingReferralLists_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Refer and rerefer cells to construct referred interactions
|
||||
void buildReferredCellList
|
||||
(
|
||||
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
|
||||
void storeParticles
|
||||
(
|
||||
@ -110,6 +120,8 @@ public:
|
||||
);
|
||||
|
||||
inline const InteractionLists<ParticleType>& il() const;
|
||||
|
||||
inline label nInteractingProcs() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -34,4 +34,12 @@ Foam::ReferredCellList<ParticleType>::il() const
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
inline Foam::label
|
||||
Foam::ReferredCellList<ParticleType>::nInteractingProcs() const
|
||||
{
|
||||
return cellReceivingReferralLists_.size();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,6 +26,11 @@ Class
|
||||
Foam::receivingReferralList
|
||||
|
||||
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
|
||||
receivingReferralListI.H
|
||||
|
||||
@ -26,6 +26,8 @@ Class
|
||||
Foam::sendingReferralList
|
||||
|
||||
Description
|
||||
Contains the list of the real cells on the current processor to be
|
||||
referred to the destination processor
|
||||
|
||||
SourceFiles
|
||||
sendingReferralListI.H
|
||||
|
||||
Reference in New Issue
Block a user