Commit 87c15bf1 authored by Will Bainbridge's avatar Will Bainbridge Committed by Andrew Heather
Browse files

lagrangian: Un-templated the tracking data

Tracking data classes are no longer templated on the derived cloud type.
The advantage of this is that they can now be passed to sub models. This
should allow continuous phase data to be removed from the parcel
classes. The disadvantage is that every function which once took a
templated TrackData argument now needs an additional TrackCloudType
argument in order to perform the necessary down-casting.
parent 14d2a1ef
......@@ -143,7 +143,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
IDLList<passiveParticle>()
);
particle::TrackingData<passiveParticleCloud> td(targetParcels);
passiveParticle::trackingData td(targetParcels);
label sourceParticleI = 0;
......
......@@ -133,7 +133,7 @@ void mapLagrangian(const meshToMesh& interp)
IDLList<passiveParticle>()
);
particle::TrackingData<passiveParticleCloud> td(targetParcels);
passiveParticle::trackingData td(targetParcels);
label sourceParticleI = 0;
......
......@@ -95,6 +95,7 @@ Foam::findCellParticle::findCellParticle
bool Foam::findCellParticle::move
(
Cloud<findCellParticle>& cloud,
trackingData& td,
const scalar maxTrackLen
)
......@@ -105,7 +106,7 @@ bool Foam::findCellParticle::move
while (td.keepParticle && !td.switchProcessor && stepFraction() < 1)
{
const scalar f = 1 - stepFraction();
trackToAndHitFace(f*(end_ - start_), f, td);
trackToAndHitFace(f*(end_ - start_), f, cloud, td);
}
if (stepFraction() == 1 || !td.keepParticle)
......@@ -123,6 +124,7 @@ bool Foam::findCellParticle::move
bool Foam::findCellParticle::hitPatch
(
const polyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
......@@ -136,6 +138,7 @@ bool Foam::findCellParticle::hitPatch
void Foam::findCellParticle::hitWedgePatch
(
const wedgePolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
......@@ -147,6 +150,7 @@ void Foam::findCellParticle::hitWedgePatch
void Foam::findCellParticle::hitSymmetryPlanePatch
(
const symmetryPlanePolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
......@@ -158,6 +162,7 @@ void Foam::findCellParticle::hitSymmetryPlanePatch
void Foam::findCellParticle::hitSymmetryPatch
(
const symmetryPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
......@@ -169,6 +174,7 @@ void Foam::findCellParticle::hitSymmetryPatch
void Foam::findCellParticle::hitCyclicPatch
(
const cyclicPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
......@@ -180,6 +186,7 @@ void Foam::findCellParticle::hitCyclicPatch
void Foam::findCellParticle::hitProcessorPatch
(
const processorPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
......@@ -191,6 +198,7 @@ void Foam::findCellParticle::hitProcessorPatch
void Foam::findCellParticle::hitWallPatch
(
const wallPolyPatch& wpp,
Cloud<findCellParticle>& cloud,
trackingData& td,
const tetIndices&
)
......@@ -203,6 +211,7 @@ void Foam::findCellParticle::hitWallPatch
void Foam::findCellParticle::hitPatch
(
const polyPatch& wpp,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
......
......@@ -80,7 +80,7 @@ public:
//- Class used to pass tracking data to the trackToFace function
class trackingData
:
public particle::TrackingData<Cloud<findCellParticle>>
public particle::trackingData
{
labelListList& cellToData_;
List<List<point>>& cellToEnd_;
......@@ -96,7 +96,7 @@ public:
List<List<point>>& cellToEnd
)
:
particle::TrackingData<Cloud<findCellParticle>>(cloud),
particle::trackingData(cloud),
cellToData_(cellToData),
cellToEnd_(cellToEnd)
{}
......@@ -220,7 +220,7 @@ public:
// Tracking
//- Track all particles to their end point
bool move(trackingData&, const scalar);
bool move(Cloud<findCellParticle>&, trackingData&, const scalar);
//- Overridable function to handle the particle hitting a patch
......@@ -228,6 +228,7 @@ public:
bool hitPatch
(
const polyPatch&,
Cloud<findCellParticle>&,
trackingData& td,
const label patchi,
const scalar trackFraction,
......@@ -238,6 +239,7 @@ public:
void hitWedgePatch
(
const wedgePolyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......@@ -246,6 +248,7 @@ public:
void hitSymmetryPlanePatch
(
const symmetryPlanePolyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......@@ -254,6 +257,7 @@ public:
void hitSymmetryPatch
(
const symmetryPolyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......@@ -261,6 +265,7 @@ public:
void hitCyclicPatch
(
const cyclicPolyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......@@ -269,6 +274,7 @@ public:
void hitProcessorPatch
(
const processorPolyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......@@ -276,6 +282,7 @@ public:
void hitWallPatch
(
const wallPolyPatch&,
Cloud<findCellParticle>&,
trackingData& td,
const tetIndices&
);
......@@ -284,6 +291,7 @@ public:
void hitPatch
(
const polyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......
......@@ -189,7 +189,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
}
cloud.move(td, maxTrackLen);
cloud.move(cloud, td, maxTrackLen);
// Rework cell-to-globalpatchface into a map
......
......@@ -112,7 +112,7 @@ void Foam::functionObjects::streamLine::track()
const scalar trackTime = Foam::sqrt(GREAT);
// Track
particles.move(td, trackTime);
particles.move(particles, td, trackTime);
}
......
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "streamLineParticle.H"
#include "streamLineParticleCloud.H"
#include "vectorFieldIOField.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -140,6 +141,7 @@ Foam::streamLineParticle::streamLineParticle
bool Foam::streamLineParticle::move
(
streamLineParticleCloud& cloud,
trackingData& td,
const scalar
)
......@@ -198,7 +200,7 @@ bool Foam::streamLineParticle::move
dt = maxDt;
}
trackToAndHitFace(dt*U, 0, td);
trackToAndHitFace(dt*U, 0, cloud, td);
if
(
......@@ -266,6 +268,7 @@ bool Foam::streamLineParticle::move
bool Foam::streamLineParticle::hitPatch
(
const polyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
......@@ -280,6 +283,7 @@ bool Foam::streamLineParticle::hitPatch
void Foam::streamLineParticle::hitWedgePatch
(
const wedgePolyPatch& pp,
streamLineParticleCloud& cloud,
trackingData& td
)
{
......@@ -291,6 +295,7 @@ void Foam::streamLineParticle::hitWedgePatch
void Foam::streamLineParticle::hitSymmetryPlanePatch
(
const symmetryPlanePolyPatch& pp,
streamLineParticleCloud& cloud,
trackingData& td
)
{
......@@ -302,6 +307,7 @@ void Foam::streamLineParticle::hitSymmetryPlanePatch
void Foam::streamLineParticle::hitSymmetryPatch
(
const symmetryPolyPatch& pp,
streamLineParticleCloud& cloud,
trackingData& td
)
{
......@@ -313,6 +319,7 @@ void Foam::streamLineParticle::hitSymmetryPatch
void Foam::streamLineParticle::hitCyclicPatch
(
const cyclicPolyPatch& pp,
streamLineParticleCloud& cloud,
trackingData& td
)
{
......@@ -324,6 +331,7 @@ void Foam::streamLineParticle::hitCyclicPatch
void Foam::streamLineParticle::hitProcessorPatch
(
const processorPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
)
{
......@@ -335,6 +343,7 @@ void Foam::streamLineParticle::hitProcessorPatch
void Foam::streamLineParticle::hitWallPatch
(
const wallPolyPatch& wpp,
streamLineParticleCloud& cloud,
trackingData& td,
const tetIndices&
)
......@@ -347,6 +356,7 @@ void Foam::streamLineParticle::hitWallPatch
void Foam::streamLineParticle::hitPatch
(
const polyPatch& wpp,
streamLineParticleCloud& cloud,
trackingData& td
)
{
......
......@@ -49,6 +49,7 @@ namespace Foam
// Forward declaration of friend functions and operators
class streamLineParticle;
class streamLineParticleCloud;
Ostream& operator<<(Ostream&, const streamLineParticle&);
......@@ -64,7 +65,7 @@ public:
class trackingData
:
public particle::TrackingData<Cloud<streamLineParticle>>
public particle::trackingData
{
public:
......@@ -94,7 +95,7 @@ public:
//- Construct from components
trackingData
(
Cloud<streamLineParticle>& cloud,
streamLineParticleCloud& cloud,
const PtrList<interpolation<scalar>>& vsInterp,
const PtrList<interpolation<vector>>& vvInterp,
const label UIndex,
......@@ -106,7 +107,7 @@ public:
List<DynamicList<vectorList>>& allVectors
)
:
particle::TrackingData<Cloud<streamLineParticle>>(cloud),
particle::trackingData(cloud),
vsInterp_(vsInterp),
vvInterp_(vvInterp),
UIndex_(UIndex),
......@@ -206,13 +207,19 @@ public:
// Tracking
//- Track all particles to their end point
bool move(trackingData&, const scalar);
bool move
(
streamLineParticleCloud& cloud,
trackingData&,
const scalar
);
//- Overridable function to handle the particle hitting a patch
// Executed before other patch-hitting functions
bool hitPatch
(
const polyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
......@@ -223,6 +230,7 @@ public:
void hitWedgePatch
(
const wedgePolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......@@ -231,6 +239,7 @@ public:
void hitSymmetryPlanePatch
(
const symmetryPlanePolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......@@ -239,6 +248,7 @@ public:
void hitSymmetryPatch
(
const symmetryPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......@@ -246,6 +256,7 @@ public:
void hitCyclicPatch
(
const cyclicPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......@@ -254,6 +265,7 @@ public:
void hitProcessorPatch
(
const processorPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......@@ -261,6 +273,7 @@ public:
void hitWallPatch
(
const wallPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const tetIndices&
);
......@@ -269,6 +282,7 @@ public:
void hitPatch
(
const polyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......
......@@ -952,7 +952,7 @@ void Foam::DSMCCloud<ParcelType>::evolve()
this->inflowBoundary().inflow();
// Move the particles ballistically with their current velocities
Cloud<ParcelType>::move(td, mesh_.time().deltaTValue());
Cloud<ParcelType>::move(*this, td, mesh_.time().deltaTValue());
// Update cell occupancy
buildCellOccupancy();
......
......@@ -29,16 +29,21 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParcelType>
template<class TrackData>
bool Foam::DSMCParcel<ParcelType>::move(TrackData& td, const scalar trackTime)
template<class TrackCloudType>
bool Foam::DSMCParcel<ParcelType>::move
(
TrackCloudType& cloud,
trackingData& td,
const scalar trackTime
)
{
typename TrackData::cloudType::parcelType& p =
static_cast<typename TrackData::cloudType::parcelType&>(*this);
typename TrackCloudType::parcelType& p =
static_cast<typename TrackCloudType::parcelType&>(*this);
td.switchProcessor = false;
td.keepParticle = true;
const polyMesh& mesh = td.cloud().pMesh();
const polyMesh& mesh = cloud.pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
// For reduced-D cases, the velocity used to track needs to be
......@@ -59,7 +64,7 @@ bool Foam::DSMCParcel<ParcelType>::move(TrackData& td, const scalar trackTime)
meshTools::constrainDirection(mesh, mesh.solutionD(), Utracking);
const scalar f = 1 - p.stepFraction();
p.trackToAndHitFace(f*trackTime*Utracking, f, td);
p.trackToAndHitFace(f*trackTime*Utracking, f, cloud, td);
if (p.onBoundaryFace() && td.keepParticle)
{
......@@ -75,11 +80,12 @@ bool Foam::DSMCParcel<ParcelType>::move(TrackData& td, const scalar trackTime)
template<class ParcelType>
template<class TrackData>
template<class TrackCloudType>
bool Foam::DSMCParcel<ParcelType>::hitPatch
(
const polyPatch&,
TrackData& td,
TrackCloudType& cloud,
trackingData& td,
const label,
const scalar,
const tetIndices&
......@@ -90,11 +96,12 @@ bool Foam::DSMCParcel<ParcelType>::hitPatch
template<class ParcelType>
template<class TrackData>
template<class TrackCloudType>
void Foam::DSMCParcel<ParcelType>::hitProcessorPatch
(
const processorPolyPatch&,
TrackData& td
TrackCloudType& cloud,
trackingData& td
)
{
td.switchProcessor = true;
......@@ -102,11 +109,12 @@ void Foam::DSMCParcel<ParcelType>::hitProcessorPatch
template<class ParcelType>
template<class TrackData>
template<class TrackCloudType>
void Foam::DSMCParcel<ParcelType>::hitWallPatch
(
const wallPolyPatch& wpp,
TrackData& td,
TrackCloudType& cloud,
trackingData& td,
const tetIndices& tetIs
)
{
......@@ -116,9 +124,9 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
const scalar fA = mag(wpp.faceAreas()[wppLocalFace]);
const scalar deltaT = td.cloud().pMesh().time().deltaTValue();
const scalar deltaT = cloud.pMesh().time().deltaTValue();
const constantProperties& constProps(td.cloud().constProps(typeId_));
const constantProperties& constProps(cloud.constProps(typeId_));
scalar m = constProps.mass();
......@@ -131,19 +139,19 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
scalar invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL);
td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
cloud.rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
cloud.rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
td.cloud().linearKEBF()[wppIndex][wppLocalFace] +=
cloud.linearKEBF()[wppIndex][wppLocalFace] +=
0.5*m*(U_ & U_)*invMagUnfA;
td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
cloud.internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
td.cloud().iDofBF()[wppIndex][wppLocalFace] +=
cloud.iDofBF()[wppIndex][wppLocalFace] +=
constProps.internalDegreesOfFreedom()*invMagUnfA;
td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
cloud.momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
// pre-interaction energy
scalar preIE = 0.5*m*(U_ & U_) + Ei_;
......@@ -151,7 +159,7 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
// pre-interaction momentum
vector preIMom = m*U_;
td.cloud().wallInteraction().correct
cloud.wallInteraction().correct
(
static_cast<DSMCParcel<ParcelType> &>(*this),
wpp
......@@ -163,19 +171,19 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL);
td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
cloud.rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
cloud.rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
td.cloud().linearKEBF()[wppIndex][wppLocalFace] +=
cloud.linearKEBF()[wppIndex][wppLocalFace] +=
0.5*m*(U_ & U_)*invMagUnfA;
td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
cloud.internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
td.cloud().iDofBF()[wppIndex][wppLocalFace] +=
cloud.iDofBF()[wppIndex][wppLocalFace] +=
constProps.internalDegreesOfFreedom()*invMagUnfA;
td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
cloud.momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
// post-interaction energy
scalar postIE = 0.5*m*(U_ & U_) + Ei_;
......@@ -183,20 +191,25 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
// post-interaction momentum
vector postIMom = m*U_;
scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA);
scalar deltaQ = cloud.nParticle()*(preIE - postIE)/(deltaT*fA);
vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA);
vector deltaFD = cloud.nParticle()*(preIMom - postIMom)/(deltaT*fA);
td.cloud().qBF()[wppIndex][wppLocalFace] += deltaQ;
cloud.qBF()[wppIndex][wppLocalFace] += deltaQ;
td.cloud().fDBF()[wppIndex][wppLocalFace] += deltaFD;
cloud.fDBF()[wppIndex][wppLocalFace] += deltaFD;
}
template<class ParcelType>
template<class TrackData>
void Foam::DSMCParcel<ParcelType>::hitPatch(const polyPatch&, TrackData& td)
template<class TrackCloudType>
void Foam::DSMCParcel<ParcelType>::hitPatch
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td
)
{
td.keepParticle = false;
}
......