Commit fb1ed2e4 authored by Henry Weller's avatar Henry Weller
Browse files

ORourkeCollision: use a CompactListList to avoid memory allocation overhead

parent ca45cf16
......@@ -24,8 +24,9 @@ License
\*---------------------------------------------------------------------------*/
#include "ORourkeCollision.H"
#include "mathematicalConstants.H"
#include "SLGThermo.H"
#include "CompactListList.H"
#include "mathematicalConstants.H"
using namespace Foam::constant::mathematical;
......@@ -34,12 +35,23 @@ using namespace Foam::constant::mathematical;
template<class CloudType>
void Foam::ORourkeCollision<CloudType>::collide(const scalar dt)
{
// Create a list of parcels in each cell
List<DynamicList<parcelType*>> pInCell(this->owner().mesh().nCells());
// Create the occupancy list for the cells
labelList occupancy(this->owner().mesh().nCells(), 0);
forAllIter(typename CloudType, this->owner(), iter)
{
occupancy[iter().cell()]++;
}
// Initialize the sizes of the lists of parcels in each cell
CompactListList<parcelType*> pInCell(occupancy);
// Reset the occupancy to use as a counter
occupancy = 0;
// Set the parcel pointer lists for each cell
forAllIter(typename CloudType, this->owner(), iter)
{
pInCell[iter().cell()].append(&iter());
pInCell(iter().cell(), occupancy[iter().cell()]++) = &iter();
}
for (label celli=0; celli<this->owner().mesh().nCells(); celli++)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment