mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Moving cellOccupancy into KinematicCloud.
This commit is contained in:
@ -43,6 +43,52 @@ void Foam::KinematicCloud<ParcelType>::preEvolve()
|
||||
{
|
||||
this->dispersion().cacheFields(true);
|
||||
forces_.cacheFields(true, interpolationSchemes_);
|
||||
updateCellOccupancy();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::KinematicCloud<ParcelType>::buildCellOccupancy()
|
||||
{
|
||||
if (cellOccupancyPtr_.empty())
|
||||
{
|
||||
cellOccupancyPtr_.reset
|
||||
(
|
||||
new List<DynamicList<ParcelType*> >(mesh_.nCells())
|
||||
);
|
||||
}
|
||||
else if (cellOccupancyPtr_().size() != mesh_.nCells())
|
||||
{
|
||||
// If the size of the mesh has changed, reset the
|
||||
// cellOccupancy size
|
||||
|
||||
cellOccupancyPtr_().setSize(mesh_.nCells());
|
||||
}
|
||||
|
||||
List<DynamicList<ParcelType*> >& cellOccupancy = cellOccupancyPtr_();
|
||||
|
||||
forAll(cellOccupancy, cO)
|
||||
{
|
||||
cellOccupancy[cO].clear();
|
||||
}
|
||||
|
||||
forAllIter(typename KinematicCloud<ParcelType>, *this, iter)
|
||||
{
|
||||
cellOccupancy[iter().cell()].append(&iter());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::KinematicCloud<ParcelType>::updateCellOccupancy()
|
||||
{
|
||||
// Only build the cellOccupancy if the pointer is set, i.e. it has
|
||||
// been requested before.
|
||||
|
||||
if (cellOccupancyPtr_.valid())
|
||||
{
|
||||
buildCellOccupancy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -80,8 +126,19 @@ void Foam::KinematicCloud<ParcelType>::evolveCloud()
|
||||
g_.value()
|
||||
);
|
||||
|
||||
label preInjectionSize = this->size();
|
||||
|
||||
this->surfaceFilm().inject(td);
|
||||
|
||||
// Update the cellOccupancy if the size of the cloud has changed
|
||||
// during the injection.
|
||||
if (preInjectionSize != this->size())
|
||||
{
|
||||
updateCellOccupancy();
|
||||
|
||||
preInjectionSize = this->size();
|
||||
}
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (coupled_)
|
||||
@ -89,6 +146,18 @@ void Foam::KinematicCloud<ParcelType>::evolveCloud()
|
||||
resetSourceTerms();
|
||||
}
|
||||
|
||||
// Assume that motion will update the cellOccupancy as necessary
|
||||
// before it is required.
|
||||
motion(td);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::KinematicCloud<ParcelType>::motion
|
||||
(
|
||||
typename ParcelType::trackData& td
|
||||
)
|
||||
{
|
||||
// Sympletic leapfrog integration of particle forces:
|
||||
// + apply half deltaV with stored force
|
||||
// + move positions with new velocity
|
||||
@ -136,6 +205,8 @@ void Foam::KinematicCloud<ParcelType>::moveCollide
|
||||
// td.part() = ParcelType::trackData::tpRotationalTrack;
|
||||
// Cloud<ParcelType>::move(td);
|
||||
|
||||
updateCellOccupancy();
|
||||
|
||||
this->collision().collide();
|
||||
|
||||
td.part() = ParcelType::trackData::tpVelocityHalfStep;
|
||||
@ -194,6 +265,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
|
||||
particleProperties_.lookup("cellValueSourceCorrection")
|
||||
),
|
||||
rndGen_(label(0)),
|
||||
cellOccupancyPtr_(),
|
||||
rho_(rho),
|
||||
U_(U),
|
||||
mu_(mu),
|
||||
|
||||
@ -136,6 +136,9 @@ protected:
|
||||
//- Random number generator - used by some injection routines
|
||||
Random rndGen_;
|
||||
|
||||
//- Cell occupancy information for each parcel, (demand driven)
|
||||
autoPtr<List<DynamicList<ParcelType*> > > cellOccupancyPtr_;
|
||||
|
||||
|
||||
// References to the carrier gas fields
|
||||
|
||||
@ -209,10 +212,20 @@ protected:
|
||||
//- Pre-evolve
|
||||
void preEvolve();
|
||||
|
||||
//- Build the cellOccupancy
|
||||
void buildCellOccupancy();
|
||||
|
||||
//- Update (i.e. build) the cellOccupancy if it has
|
||||
// already been used
|
||||
void updateCellOccupancy();
|
||||
|
||||
//- Evolve the cloud
|
||||
void evolveCloud();
|
||||
|
||||
//- Move-collide
|
||||
//- Particle motion
|
||||
void motion(typename ParcelType::trackData& td);
|
||||
|
||||
//- Move-collide particles
|
||||
void moveCollide(typename ParcelType::trackData& td);
|
||||
|
||||
//- Post-evolve
|
||||
@ -284,6 +297,11 @@ public:
|
||||
//- Return refernce to the random object
|
||||
inline Random& rndGen();
|
||||
|
||||
//- Return the cell occupancy information for each parcel,
|
||||
// non-const access, the caller is responsible for updating
|
||||
// it if particles are removed or created.
|
||||
inline List<DynamicList<ParcelType*> >& cellOccupancy();
|
||||
|
||||
|
||||
// References to the carrier gas fields
|
||||
|
||||
|
||||
@ -302,6 +302,19 @@ inline Foam::Random& Foam::KinematicCloud<ParcelType>::rndGen()
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
inline Foam::List<Foam::DynamicList<ParcelType*> >&
|
||||
Foam::KinematicCloud<ParcelType>::cellOccupancy()
|
||||
{
|
||||
if (cellOccupancyPtr_.empty())
|
||||
{
|
||||
buildCellOccupancy();
|
||||
}
|
||||
|
||||
return cellOccupancyPtr_();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
inline Foam::DimensionedField<Foam::vector, Foam::volMesh>&
|
||||
Foam::KinematicCloud<ParcelType>::UTrans()
|
||||
|
||||
@ -120,8 +120,19 @@ void Foam::ReactingCloud<ParcelType>::evolveCloud()
|
||||
this->g().value()
|
||||
);
|
||||
|
||||
label preInjectionSize = this->size();
|
||||
|
||||
this->surfaceFilm().inject(td);
|
||||
|
||||
// Update the cellOccupancy if the size of the cloud has changed
|
||||
// during the injection.
|
||||
if (preInjectionSize != this->size())
|
||||
{
|
||||
this->updateCellOccupancy();
|
||||
|
||||
preInjectionSize = this->size();
|
||||
}
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (this->coupled())
|
||||
@ -129,7 +140,19 @@ void Foam::ReactingCloud<ParcelType>::evolveCloud()
|
||||
resetSourceTerms();
|
||||
}
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
// Assume that motion will update the cellOccupancy as necessary
|
||||
// before it is required.
|
||||
motion(td);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingCloud<ParcelType>::motion
|
||||
(
|
||||
typename ParcelType::trackData& td
|
||||
)
|
||||
{
|
||||
ThermoCloud<ParcelType>::motion(td);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -130,6 +130,9 @@ protected:
|
||||
//- Evolve the cloud
|
||||
void evolveCloud();
|
||||
|
||||
//- Particle motion
|
||||
void motion(typename ParcelType::trackData& td);
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
@ -93,8 +93,19 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::evolveCloud()
|
||||
this->g().value()
|
||||
);
|
||||
|
||||
label preInjectionSize = this->size();
|
||||
|
||||
this->surfaceFilm().inject(td);
|
||||
|
||||
// Update the cellOccupancy if the size of the cloud has changed
|
||||
// during the injection.
|
||||
if (preInjectionSize != this->size())
|
||||
{
|
||||
this->updateCellOccupancy();
|
||||
|
||||
preInjectionSize = this->size();
|
||||
}
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (this->coupled())
|
||||
@ -102,7 +113,19 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::evolveCloud()
|
||||
resetSourceTerms();
|
||||
}
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
// Assume that motion will update the cellOccupancy as necessary
|
||||
// before it is required.
|
||||
motion(td);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingMultiphaseCloud<ParcelType>::motion
|
||||
(
|
||||
typename ParcelType::trackData& td
|
||||
)
|
||||
{
|
||||
ReactingCloud<ParcelType>::motion(td);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -121,6 +121,9 @@ protected:
|
||||
//- Evolve the cloud
|
||||
void evolveCloud();
|
||||
|
||||
//- Particle motion
|
||||
void motion(typename ParcelType::trackData& td);
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
@ -86,8 +86,19 @@ void Foam::ThermoCloud<ParcelType>::evolveCloud()
|
||||
this->g().value()
|
||||
);
|
||||
|
||||
label preInjectionSize = this->size();
|
||||
|
||||
// Update the cellOccupancy if the size of the cloud has changed
|
||||
// during the injection.
|
||||
this->surfaceFilm().inject(td);
|
||||
|
||||
if (preInjectionSize != this->size())
|
||||
{
|
||||
this->updateCellOccupancy();
|
||||
|
||||
preInjectionSize = this->size();
|
||||
}
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (this->coupled())
|
||||
@ -95,7 +106,19 @@ void Foam::ThermoCloud<ParcelType>::evolveCloud()
|
||||
resetSourceTerms();
|
||||
}
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
// Assume that motion will update the cellOccupancy as necessary
|
||||
// before it is required.
|
||||
motion(td);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ThermoCloud<ParcelType>::motion
|
||||
(
|
||||
typename ParcelType::trackData& td
|
||||
)
|
||||
{
|
||||
KinematicCloud<ParcelType>::motion(td);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -121,6 +121,9 @@ protected:
|
||||
//- Evolve the cloud
|
||||
void evolveCloud();
|
||||
|
||||
//- Particle motion
|
||||
void motion(typename ParcelType::trackData& td);
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
@ -51,8 +51,6 @@ void Foam::PairCollision<CloudType>::preInteraction()
|
||||
|
||||
p.torque() = vector::zero;
|
||||
}
|
||||
|
||||
buildCellOccupancy();
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +59,7 @@ void Foam::PairCollision<CloudType>::parcelInteraction()
|
||||
{
|
||||
PstreamBuffers pBufs(Pstream::nonBlocking);
|
||||
|
||||
il_.sendReferredData(cellOccupancy_, pBufs);
|
||||
il_.sendReferredData(this->owner().cellOccupancy(), pBufs);
|
||||
|
||||
realRealInteraction();
|
||||
|
||||
@ -80,17 +78,20 @@ void Foam::PairCollision<CloudType>::realRealInteraction()
|
||||
typename CloudType::parcelType* pA_ptr = NULL;
|
||||
typename CloudType::parcelType* pB_ptr = NULL;
|
||||
|
||||
List<DynamicList<typename CloudType::parcelType*> >& cellOccupancy =
|
||||
this->owner().cellOccupancy();
|
||||
|
||||
forAll(dil, realCellI)
|
||||
{
|
||||
// Loop over all Parcels in cell A (a)
|
||||
forAll(cellOccupancy_[realCellI], a)
|
||||
forAll(cellOccupancy[realCellI], a)
|
||||
{
|
||||
pA_ptr = cellOccupancy_[realCellI][a];
|
||||
pA_ptr = cellOccupancy[realCellI][a];
|
||||
|
||||
forAll(dil[realCellI], interactingCells)
|
||||
{
|
||||
List<typename CloudType::parcelType*> cellBParcels =
|
||||
cellOccupancy_[dil[realCellI][interactingCells]];
|
||||
cellOccupancy[dil[realCellI][interactingCells]];
|
||||
|
||||
// Loop over all Parcels in cell B (b)
|
||||
forAll(cellBParcels, b)
|
||||
@ -102,9 +103,9 @@ void Foam::PairCollision<CloudType>::realRealInteraction()
|
||||
}
|
||||
|
||||
// Loop over the other Parcels in cell A (aO)
|
||||
forAll(cellOccupancy_[realCellI], aO)
|
||||
forAll(cellOccupancy[realCellI], aO)
|
||||
{
|
||||
pB_ptr = cellOccupancy_[realCellI][aO];
|
||||
pB_ptr = cellOccupancy[realCellI][aO];
|
||||
|
||||
// Do not double-evaluate, compare pointers, arbitrary
|
||||
// order
|
||||
@ -127,6 +128,9 @@ void Foam::PairCollision<CloudType>::realReferredInteraction()
|
||||
List<IDLList<typename CloudType::parcelType> >& referredParticles =
|
||||
il_.referredParticles();
|
||||
|
||||
List<DynamicList<typename CloudType::parcelType*> >& cellOccupancy =
|
||||
this->owner().cellOccupancy();
|
||||
|
||||
// Loop over all referred cells
|
||||
forAll(ril, refCellI)
|
||||
{
|
||||
@ -150,7 +154,7 @@ void Foam::PairCollision<CloudType>::realReferredInteraction()
|
||||
forAll(realCells, realCellI)
|
||||
{
|
||||
List<typename CloudType::parcelType*> realCellParcels =
|
||||
cellOccupancy_[realCells[realCellI]];
|
||||
cellOccupancy[realCells[realCellI]];
|
||||
|
||||
forAll(realCellParcels, realParcelI)
|
||||
{
|
||||
@ -179,6 +183,9 @@ void Foam::PairCollision<CloudType>::wallInteraction()
|
||||
|
||||
const volVectorField& U = mesh.lookupObject<volVectorField>(il_.UName());
|
||||
|
||||
List<DynamicList<typename CloudType::parcelType*> >& cellOccupancy =
|
||||
this->owner().cellOccupancy();
|
||||
|
||||
// Storage for the wall interaction sites
|
||||
DynamicList<point> flatSitePoints;
|
||||
DynamicList<scalar> flatSiteExclusionDistancesSqr;
|
||||
@ -196,7 +203,7 @@ void Foam::PairCollision<CloudType>::wallInteraction()
|
||||
const labelList& realWallFaces = directWallFaces[realCellI];
|
||||
|
||||
// Loop over all Parcels in cell
|
||||
forAll(cellOccupancy_[realCellI], cellParticleI)
|
||||
forAll(cellOccupancy[realCellI], cellParticleI)
|
||||
{
|
||||
flatSitePoints.clear();
|
||||
flatSiteExclusionDistancesSqr.clear();
|
||||
@ -209,7 +216,7 @@ void Foam::PairCollision<CloudType>::wallInteraction()
|
||||
sharpSiteData.clear();
|
||||
|
||||
typename CloudType::parcelType& p =
|
||||
*cellOccupancy_[realCellI][cellParticleI];
|
||||
*cellOccupancy[realCellI][cellParticleI];
|
||||
|
||||
const point& pos = p.position();
|
||||
|
||||
@ -482,21 +489,6 @@ void Foam::PairCollision<CloudType>::postInteraction()
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::PairCollision<CloudType>::buildCellOccupancy()
|
||||
{
|
||||
forAll(cellOccupancy_, cO)
|
||||
{
|
||||
cellOccupancy_[cO].clear();
|
||||
}
|
||||
|
||||
forAllIter(typename CloudType, this->owner(), iter)
|
||||
{
|
||||
cellOccupancy_[iter().cell()].append(&iter());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::PairCollision<CloudType>::evaluatePair
|
||||
(
|
||||
@ -539,7 +531,6 @@ Foam::PairCollision<CloudType>::PairCollision
|
||||
)
|
||||
:
|
||||
CollisionModel<CloudType>(dict, owner, typeName),
|
||||
cellOccupancy_(owner.mesh().nCells()),
|
||||
pairModel_
|
||||
(
|
||||
PairModel<CloudType>::New
|
||||
|
||||
@ -76,9 +76,6 @@ class PairCollision
|
||||
|
||||
// Private data
|
||||
|
||||
//- Cell occupancy information for each parcel
|
||||
List<DynamicList<typename CloudType::parcelType*> > cellOccupancy_;
|
||||
|
||||
//- PairModel to calculate the interaction between two parcels
|
||||
autoPtr<PairModel<CloudType> > pairModel_;
|
||||
|
||||
@ -124,9 +121,6 @@ class PairCollision
|
||||
//- Post collision tasks
|
||||
void postInteraction();
|
||||
|
||||
//- Build the cell occupancy information for each parcel
|
||||
void buildCellOccupancy();
|
||||
|
||||
//- Calculate the pair force between parcels
|
||||
void evaluatePair
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user