Skip to content
Snippets Groups Projects
Commit f7104f4a authored by graham's avatar graham
Browse files

Caching deltaT in the DsmcCloud as it is expensive to repeated lookup in the

parcel and in submodels.  Approx 20% speed in solution.
parent 24fa65eb
Branches
Tags
No related merge requests found
......@@ -299,7 +299,7 @@ void Foam::DsmcCloud<ParcelType>::collisions()
// Temporary storage for subCells
List<DynamicList<label> > subCells(8);
scalar deltaT = mesh_.time().deltaT().value();
scalar deltaT = cachedDeltaT();
label collisionCandidates = 0;
......@@ -778,6 +778,9 @@ Foam::DsmcCloud<ParcelType>::~DsmcCloud()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::evolve()
{
// cache the value of deltaT for this timestep
storeDeltaT();
typename ParcelType::trackData td(*this);
// Reset the surface data collection fields
......
......@@ -116,6 +116,10 @@ class DsmcCloud
//- Random number generator
Random rndGen_;
//- In-cloud cache of deltaT, lookup in submodels and parcel is
// expensive
scalar cachedDeltaT_;
// References to the macroscopic fields
......@@ -243,6 +247,12 @@ public:
//- Return refernce to the random object
inline Random& rndGen();
//- Store (cache) the current value of deltaT
inline void storeDeltaT();
//- Return the cached value of deltaT
inline scalar cachedDeltaT() const;
// References to the surface data collection fields
......
......@@ -120,6 +120,20 @@ inline Foam::Random& Foam::DsmcCloud<ParcelType>::rndGen()
}
template<class ParcelType>
inline void Foam::DsmcCloud<ParcelType>::storeDeltaT()
{
cachedDeltaT_ = mesh().time().deltaT().value();
}
template<class ParcelType>
inline Foam::scalar Foam::DsmcCloud<ParcelType>::cachedDeltaT() const
{
return cachedDeltaT_;
}
template<class ParcelType>
inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() const
{
......
......@@ -44,7 +44,7 @@ bool Foam::DsmcParcel<ParcelType>::move
const polyMesh& mesh = td.cloud().pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
const scalar deltaT = mesh.time().deltaT().value();
const scalar deltaT = td.cloud().cachedDeltaT();
scalar tEnd = (1.0 - p.stepFraction())*deltaT;
const scalar dtMax = tEnd;
......@@ -145,7 +145,7 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
const scalar fA = mag(wpp.faceAreas()[wppLocalFace]);
const scalar deltaT = td.cloud().mesh().time().deltaT().value();
const scalar deltaT = td.cloud().cachedDeltaT();
scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA);
......
......@@ -126,7 +126,7 @@ void Foam::FreeStream<CloudType>::inflow()
const polyMesh& mesh(cloud.mesh());
const scalar deltaT = mesh.time().deltaT().value();
const scalar deltaT = cloud.cachedDeltaT();
Random& rndGen(cloud.rndGen());
......
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