From 4fd4fadab288500674845e6b20f0791fc5b79420 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Tue, 22 Aug 2017 15:28:04 +0100 Subject: [PATCH] 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. --- .../preProcessing/mapFields/mapLagrangian.C | 2 +- .../mapFieldsPar/mapLagrangian.C | 2 +- .../field/nearWallFields/findCellParticle.C | 11 +- .../field/nearWallFields/findCellParticle.H | 14 +- .../field/nearWallFields/nearWallFields.C | 2 +- .../field/streamLine/streamLine.C | 2 +- .../field/streamLine/streamLineParticle.C | 12 +- .../field/streamLine/streamLineParticle.H | 22 +- .../clouds/Templates/DSMCCloud/DSMCCloud.C | 2 +- .../parcels/Templates/DSMCParcel/DSMCParcel.C | 79 ++++--- .../parcels/Templates/DSMCParcel/DSMCParcel.H | 49 ++--- src/lagrangian/basic/Cloud/Cloud.C | 15 +- src/lagrangian/basic/Cloud/Cloud.H | 10 +- src/lagrangian/basic/particle/particle.H | 131 +++++++----- .../basic/particle/particleTemplates.C | 129 ++++++----- .../Templates/CollidingCloud/CollidingCloud.C | 40 ++-- .../Templates/CollidingCloud/CollidingCloud.H | 19 +- .../Templates/KinematicCloud/KinematicCloud.C | 69 +++--- .../Templates/KinematicCloud/KinematicCloud.H | 24 ++- .../clouds/Templates/MPPICCloud/MPPICCloud.C | 41 ++-- .../clouds/Templates/MPPICCloud/MPPICCloud.H | 10 +- .../Templates/ReactingCloud/ReactingCloud.C | 5 +- .../ReactingMultiphaseCloud.C | 5 +- .../Templates/ThermoCloud/ThermoCloud.C | 5 +- .../CollidingParcel/CollidingParcel.C | 17 +- .../CollidingParcel/CollidingParcel.H | 13 +- .../KinematicParcel/KinematicParcel.C | 137 +++++++----- .../KinematicParcel/KinematicParcel.H | 67 +++--- .../KinematicParcelTrackingDataI.H | 34 ++- .../Templates/MPPICParcel/MPPICParcel.C | 25 +-- .../Templates/MPPICParcel/MPPICParcel.H | 22 +- .../MPPICParcel/MPPICParcelTrackingDataI.H | 43 ++-- .../ReactingMultiphaseParcel.C | 200 +++++++++++------- .../ReactingMultiphaseParcel.H | 44 ++-- .../Templates/ReactingParcel/ReactingParcel.C | 129 ++++++----- .../Templates/ReactingParcel/ReactingParcel.H | 41 ++-- .../ReactingParcelTrackingDataI.H | 13 +- .../Templates/ThermoParcel/ThermoParcel.C | 102 +++++---- .../Templates/ThermoParcel/ThermoParcel.H | 41 ++-- .../ThermoParcel/ThermoParcelTrackingDataI.H | 28 +-- .../InjectionModel/InjectionModel.C | 21 +- .../InjectionModel/InjectionModel.H | 19 +- .../InjectionModel/InjectionModelList.C | 19 +- .../InjectionModel/InjectionModelList.H | 19 +- .../SurfaceFilmModel/SurfaceFilmModel.C | 12 +- .../SurfaceFilmModel/SurfaceFilmModel.H | 4 +- .../molecule/molecule/molecule.C | 15 +- .../molecule/molecule/molecule.H | 10 +- .../molecule/moleculeCloud/moleculeCloud.C | 8 +- src/lagrangian/solidParticle/solidParticle.C | 13 +- src/lagrangian/solidParticle/solidParticle.H | 10 +- .../solidParticle/solidParticleCloud.C | 4 +- src/lagrangian/solidParticle/solidParticleI.H | 4 +- .../clouds/Templates/SprayCloud/SprayCloud.C | 7 +- .../Templates/SprayParcel/SprayParcel.C | 116 +++++----- .../Templates/SprayParcel/SprayParcel.H | 44 ++-- .../meshRefinement/meshRefinementRefine.C | 4 +- .../trackedParticle/trackedParticle.C | 15 +- .../trackedParticle/trackedParticle.H | 22 +- src/sampling/sampledSet/face/faceOnlySet.C | 4 +- .../sampledSet/polyLine/polyLineSet.C | 2 - src/sampling/sampledSet/uniform/uniformSet.C | 2 - 62 files changed, 1193 insertions(+), 837 deletions(-) diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index 45cd8e4bb5..d450795f47 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -143,7 +143,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp) IDLList() ); - particle::TrackingData td(targetParcels); + passiveParticle::trackingData td(targetParcels); label sourceParticleI = 0; diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C b/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C index f5a23a09d2..b0ee45bf6f 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C @@ -132,7 +132,7 @@ void mapLagrangian(const meshToMesh& interp) IDLList() ); - particle::TrackingData td(targetParcels); + passiveParticle::trackingData td(targetParcels); label sourceParticleI = 0; diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.C b/src/functionObjects/field/nearWallFields/findCellParticle.C index 1ec11ad685..19726169e3 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.C +++ b/src/functionObjects/field/nearWallFields/findCellParticle.C @@ -100,6 +100,7 @@ Foam::findCellParticle::findCellParticle bool Foam::findCellParticle::move ( + Cloud& cloud, trackingData& td, const scalar maxTrackLen ) @@ -110,7 +111,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) @@ -128,6 +129,7 @@ bool Foam::findCellParticle::move bool Foam::findCellParticle::hitPatch ( const polyPatch&, + Cloud& cloud, trackingData& td, const label patchi, const scalar trackFraction, @@ -141,6 +143,7 @@ bool Foam::findCellParticle::hitPatch void Foam::findCellParticle::hitWedgePatch ( const wedgePolyPatch&, + Cloud& cloud, trackingData& td ) { @@ -152,6 +155,7 @@ void Foam::findCellParticle::hitWedgePatch void Foam::findCellParticle::hitSymmetryPlanePatch ( const symmetryPlanePolyPatch&, + Cloud& cloud, trackingData& td ) { @@ -163,6 +167,7 @@ void Foam::findCellParticle::hitSymmetryPlanePatch void Foam::findCellParticle::hitSymmetryPatch ( const symmetryPolyPatch&, + Cloud& cloud, trackingData& td ) { @@ -174,6 +179,7 @@ void Foam::findCellParticle::hitSymmetryPatch void Foam::findCellParticle::hitCyclicPatch ( const cyclicPolyPatch&, + Cloud& cloud, trackingData& td ) { @@ -185,6 +191,7 @@ void Foam::findCellParticle::hitCyclicPatch void Foam::findCellParticle::hitProcessorPatch ( const processorPolyPatch&, + Cloud& cloud, trackingData& td ) { @@ -196,6 +203,7 @@ void Foam::findCellParticle::hitProcessorPatch void Foam::findCellParticle::hitWallPatch ( const wallPolyPatch& wpp, + Cloud& cloud, trackingData& td, const tetIndices& ) @@ -208,6 +216,7 @@ void Foam::findCellParticle::hitWallPatch void Foam::findCellParticle::hitPatch ( const polyPatch& wpp, + Cloud& cloud, trackingData& td ) { diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.H b/src/functionObjects/field/nearWallFields/findCellParticle.H index 57cd3ffa46..7c2f205dea 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.H +++ b/src/functionObjects/field/nearWallFields/findCellParticle.H @@ -80,7 +80,7 @@ public: //- Class used to pass tracking data to the trackToFace function class trackingData : - public particle::TrackingData> + public particle::trackingData { labelListList& cellToData_; List>& cellToEnd_; @@ -96,7 +96,7 @@ public: List>& cellToEnd ) : - particle::TrackingData>(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&, trackingData&, const scalar); //- Overridable function to handle the particle hitting a patch @@ -228,6 +228,7 @@ public: bool hitPatch ( const polyPatch&, + Cloud&, trackingData& td, const label patchi, const scalar trackFraction, @@ -238,6 +239,7 @@ public: void hitWedgePatch ( const wedgePolyPatch&, + Cloud&, trackingData& td ); @@ -246,6 +248,7 @@ public: void hitSymmetryPlanePatch ( const symmetryPlanePolyPatch&, + Cloud&, trackingData& td ); @@ -254,6 +257,7 @@ public: void hitSymmetryPatch ( const symmetryPolyPatch&, + Cloud&, trackingData& td ); @@ -261,6 +265,7 @@ public: void hitCyclicPatch ( const cyclicPolyPatch&, + Cloud&, trackingData& td ); @@ -269,6 +274,7 @@ public: void hitProcessorPatch ( const processorPolyPatch&, + Cloud&, trackingData& td ); @@ -276,6 +282,7 @@ public: void hitWallPatch ( const wallPolyPatch&, + Cloud&, trackingData& td, const tetIndices& ); @@ -284,6 +291,7 @@ public: void hitPatch ( const polyPatch&, + Cloud&, trackingData& td ); diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index 3545edf4ff..8e42496ab6 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -171,7 +171,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing() } - cloud.move(td, maxTrackLen); + cloud.move(cloud, td, maxTrackLen); // Rework cell-to-globalpatchface into a map diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C index 2d2512b4da..eb0f8892e6 100644 --- a/src/functionObjects/field/streamLine/streamLine.C +++ b/src/functionObjects/field/streamLine/streamLine.C @@ -272,7 +272,7 @@ void Foam::functionObjects::streamLine::track() const scalar trackTime = Foam::sqrt(GREAT); // Track - particles.move(td, trackTime); + particles.move(particles, td, trackTime); } diff --git a/src/functionObjects/field/streamLine/streamLineParticle.C b/src/functionObjects/field/streamLine/streamLineParticle.C index 4e27773ad3..a15615b3a8 100644 --- a/src/functionObjects/field/streamLine/streamLineParticle.C +++ b/src/functionObjects/field/streamLine/streamLineParticle.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "streamLineParticle.H" +#include "streamLineParticleCloud.H" #include "vectorFieldIOField.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -145,6 +146,7 @@ Foam::streamLineParticle::streamLineParticle bool Foam::streamLineParticle::move ( + streamLineParticleCloud& cloud, trackingData& td, const scalar ) @@ -203,7 +205,7 @@ bool Foam::streamLineParticle::move dt = maxDt; } - trackToAndHitFace(dt*U, 0, td); + trackToAndHitFace(dt*U, 0, cloud, td); if ( @@ -271,6 +273,7 @@ bool Foam::streamLineParticle::move bool Foam::streamLineParticle::hitPatch ( const polyPatch&, + streamLineParticleCloud& cloud, trackingData& td, const label patchi, const scalar trackFraction, @@ -285,6 +288,7 @@ bool Foam::streamLineParticle::hitPatch void Foam::streamLineParticle::hitWedgePatch ( const wedgePolyPatch& pp, + streamLineParticleCloud& cloud, trackingData& td ) { @@ -296,6 +300,7 @@ void Foam::streamLineParticle::hitWedgePatch void Foam::streamLineParticle::hitSymmetryPlanePatch ( const symmetryPlanePolyPatch& pp, + streamLineParticleCloud& cloud, trackingData& td ) { @@ -307,6 +312,7 @@ void Foam::streamLineParticle::hitSymmetryPlanePatch void Foam::streamLineParticle::hitSymmetryPatch ( const symmetryPolyPatch& pp, + streamLineParticleCloud& cloud, trackingData& td ) { @@ -318,6 +324,7 @@ void Foam::streamLineParticle::hitSymmetryPatch void Foam::streamLineParticle::hitCyclicPatch ( const cyclicPolyPatch& pp, + streamLineParticleCloud& cloud, trackingData& td ) { @@ -329,6 +336,7 @@ void Foam::streamLineParticle::hitCyclicPatch void Foam::streamLineParticle::hitProcessorPatch ( const processorPolyPatch&, + streamLineParticleCloud& cloud, trackingData& td ) { @@ -340,6 +348,7 @@ void Foam::streamLineParticle::hitProcessorPatch void Foam::streamLineParticle::hitWallPatch ( const wallPolyPatch& wpp, + streamLineParticleCloud& cloud, trackingData& td, const tetIndices& ) @@ -352,6 +361,7 @@ void Foam::streamLineParticle::hitWallPatch void Foam::streamLineParticle::hitPatch ( const polyPatch& wpp, + streamLineParticleCloud& cloud, trackingData& td ) { diff --git a/src/functionObjects/field/streamLine/streamLineParticle.H b/src/functionObjects/field/streamLine/streamLineParticle.H index 42282e1790..d8f73afec9 100644 --- a/src/functionObjects/field/streamLine/streamLineParticle.H +++ b/src/functionObjects/field/streamLine/streamLineParticle.H @@ -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> + public particle::trackingData { public: @@ -94,7 +95,7 @@ public: //- Construct from components trackingData ( - Cloud& cloud, + streamLineParticleCloud& cloud, const PtrList>& vsInterp, const PtrList>& vvInterp, const label UIndex, @@ -106,7 +107,7 @@ public: List>& allVectors ) : - particle::TrackingData>(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 ); diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index ee87ace3b7..173d21d2d9 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -951,7 +951,7 @@ void Foam::DSMCCloud::evolve() this->inflowBoundary().inflow(); // Move the particles ballistically with their current velocities - Cloud::move(td, mesh_.time().deltaTValue()); + Cloud::move(*this, td, mesh_.time().deltaTValue()); // Update cell occupancy buildCellOccupancy(); diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C index 7df06d3b98..202ff22abf 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C @@ -29,16 +29,21 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -template -bool Foam::DSMCParcel::move(TrackData& td, const scalar trackTime) +template +bool Foam::DSMCParcel::move +( + TrackCloudType& cloud, + trackingData& td, + const scalar trackTime +) { - typename TrackData::cloudType::parcelType& p = - static_cast(*this); + typename TrackCloudType::parcelType& p = + static_cast(*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::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::move(TrackData& td, const scalar trackTime) template -template +template bool Foam::DSMCParcel::hitPatch ( const polyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const label, const scalar, const tetIndices& @@ -90,11 +96,12 @@ bool Foam::DSMCParcel::hitPatch template -template +template void Foam::DSMCParcel::hitProcessorPatch ( const processorPolyPatch&, - TrackData& td + TrackCloudType& cloud, + trackingData& td ) { td.switchProcessor = true; @@ -102,11 +109,12 @@ void Foam::DSMCParcel::hitProcessorPatch template -template +template void Foam::DSMCParcel::hitWallPatch ( const wallPolyPatch& wpp, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const tetIndices& tetIs ) { @@ -116,9 +124,9 @@ void Foam::DSMCParcel::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::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::hitWallPatch // pre-interaction momentum vector preIMom = m*U_; - td.cloud().wallInteraction().correct + cloud.wallInteraction().correct ( static_cast &>(*this), wpp @@ -163,19 +171,19 @@ void Foam::DSMCParcel::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::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 -template -void Foam::DSMCParcel::hitPatch(const polyPatch&, TrackData& td) +template +void Foam::DSMCParcel::hitPatch +( + const polyPatch&, + TrackCloudType& cloud, + trackingData& td +) { td.keepParticle = false; } diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H index bd8080c8da..3fe83c4b60 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H @@ -127,24 +127,8 @@ public: }; - //- Class used to pass kinematic tracking data to the trackToFace function - class trackingData - : - public particle::TrackingData>> - { - public: - - // Constructors - - //- Construct from components - trackingData(DSMCCloud>& cloud) - : - particle::TrackingData>> - ( - cloud - ) - {} - }; + //- Use base tracking data + typedef typename ParcelType::trackingData trackingData; protected: @@ -264,19 +248,25 @@ public: // Tracking //- Move the parcel - template - bool move(TrackData& td, const scalar trackTime); + template + bool move + ( + TrackCloudType& cloud, + trackingData& td, + const scalar trackTime + ); // Patch interactions //- Overridable function to handle the particle hitting a patch // Executed before other patch-hitting functions - template + template bool hitPatch ( const polyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const label patchi, const scalar trackFraction, const tetIndices& tetIs @@ -284,28 +274,31 @@ public: //- Overridable function to handle the particle hitting a // processorPatch - template + template void hitProcessorPatch ( const processorPolyPatch&, - TrackData& td + TrackCloudType& cloud, + trackingData& td ); //- Overridable function to handle the particle hitting a wallPatch - template + template void hitWallPatch ( const wallPolyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const tetIndices& ); //- Overridable function to handle the particle hitting a polyPatch - template + template void hitPatch ( const polyPatch&, - TrackData& td + TrackCloudType& cloud, + trackingData& td ); //- Transform the physical properties of the particle diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index f0f7da835c..b17c8fdbee 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -181,8 +181,13 @@ void Foam::Cloud::cloudReset(const Cloud& c) template -template -void Foam::Cloud::move(TrackData& td, const scalar trackTime) +template +void Foam::Cloud::move +( + TrackCloudType& cloud, + typename ParticleType::trackingData& td, + const scalar trackTime +) { const polyBoundaryMesh& pbm = pMesh().boundaryMesh(); const globalMeshData& pData = polyMesh_.globalData(); @@ -253,7 +258,7 @@ void Foam::Cloud::move(TrackData& td, const scalar trackTime) ParticleType& p = pIter(); // Move the particle - bool keepParticle = p.move(td, trackTime); + bool keepParticle = p.move(cloud, td, trackTime); // If the particle is to be kept // (i.e. it hasn't passed through an inlet or outlet) @@ -282,7 +287,7 @@ void Foam::Cloud::move(TrackData& td, const scalar trackTime) ).neighbProcNo() ]; - p.prepareForParallelTransfer(patchi, td); + p.prepareForParallelTransfer(patchi, cloud, td); particleTransferLists[n].append(this->remove(&p)); @@ -375,7 +380,7 @@ void Foam::Cloud::move(TrackData& td, const scalar trackTime) label patchi = procPatches[receivePatchIndex[pI++]]; - newp.correctAfterParallelTransfer(patchi, td); + newp.correctAfterParallelTransfer(patchi, cloud, td); addParticle(newParticles.remove(&newp)); } diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index aa35eb3b47..04ef10a053 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -253,9 +253,13 @@ public: void cloudReset(const Cloud& c); //- Move the particles - // passing the TrackingData to the track function - template - void move(TrackData& td, const scalar trackTime); + template + void move + ( + TrackCloudType& cloud, + typename ParticleType::trackingData& td, + const scalar trackTime + ); //- Remap the cells of particles corresponding to the // mesh topology change diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index aa6ece54d8..881f09104a 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -106,21 +106,12 @@ class particle public: - template - class TrackingData + class trackingData { - // Private data - - //- Reference to the cloud containing (this) particle - CloudType& cloud_; - - public: // Public data - typedef CloudType cloudType; - //- Flag to switch processor bool switchProcessor; @@ -129,19 +120,9 @@ public: // Constructor - TrackingData(CloudType& cloud) - : - cloud_(cloud) + template + trackingData(const TrackCloudType& cloud) {} - - - // Member functions - - //- Return a reference to the cloud - CloudType& cloud() - { - return cloud_; - } }; @@ -307,75 +288,105 @@ protected: // patch. Executed before other patch-hitting functions. // trackFraction is passed in to allow mesh motion to // interpolate in time to the correct face state. - template + template bool hitPatch ( const polyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const label patchi, const scalar trackFraction, const tetIndices& tetIs ); //- Overridable function to handle the particle hitting a wedgePatch - template - void hitWedgePatch(const wedgePolyPatch&, TrackData& td); + template + void hitWedgePatch + ( + const wedgePolyPatch&, + TrackCloudType& cloud, + trackingData& td + ); //- Overridable function to handle the particle hitting a // symmetryPlanePatch - template + template void hitSymmetryPlanePatch ( const symmetryPlanePolyPatch&, - TrackData& td + TrackCloudType& cloud, + trackingData& td ); //- Overridable function to handle the particle hitting a // symmetryPatch - template - void hitSymmetryPatch(const symmetryPolyPatch&, TrackData& td); + template + void hitSymmetryPatch + ( + const symmetryPolyPatch&, + TrackCloudType& cloud, + trackingData& td + ); //- Overridable function to handle the particle hitting a cyclicPatch - template - void hitCyclicPatch(const cyclicPolyPatch&, TrackData& td); + template + void hitCyclicPatch + ( + const cyclicPolyPatch&, + TrackCloudType& cloud, + trackingData& td + ); //- Overridable function to handle the particle hitting a cyclicAMIPatch - template + template void hitCyclicAMIPatch ( const cyclicAMIPolyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const vector& direction ); //- Overridable function to handle the particle hitting a // cyclicACMIPatch - template + template void hitCyclicACMIPatch ( const cyclicACMIPolyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const vector& direction ); //- Overridable function to handle the particle hitting a // processorPatch - template - void hitProcessorPatch(const processorPolyPatch&, TrackData& td); + template + void hitProcessorPatch + ( + const processorPolyPatch&, + TrackCloudType& cloud, + trackingData& td + ); //- Overridable function to handle the particle hitting a wallPatch - template + template void hitWallPatch ( const wallPolyPatch&, - TrackData& td, + TrackCloudType& cloud, + trackingData& td, const tetIndices& tetIs ); //- Overridable function to handle the particle hitting a // general patch - template - void hitPatch(const polyPatch&, TrackData& td); + template + void hitPatch + ( + const polyPatch&, + TrackCloudType& cloud, + trackingData& td + ); public: @@ -597,20 +608,22 @@ public: //- Hit the current face. If the current face is internal than this // crosses into the next cell. If it is a boundary face then this will // interact the particle with the relevant patch. - template + template void hitFace ( const vector& direction, - TrackData& td + TrackCloudType& cloud, + trackingData& td ); //- Convenience function. Cobines trackToFace and hitFace - template + template void trackToAndHitFace ( const vector& direction, const scalar fraction, - TrackData& td + TrackCloudType& cloud, + trackingData& td ); //- Set the constrained components of the particle position to the @@ -643,13 +656,23 @@ public: //- Convert global addressing to the processor patch // local equivalents - template - void prepareForParallelTransfer(const label patchi, TrackData& td); + template + void prepareForParallelTransfer + ( + const label patchi, + TrackCloudType& cloud, + trackingData& td + ); //- Convert processor patch addressing to the global equivalents // and set the celli to the face-neighbour - template - void correctAfterParallelTransfer(const label patchi, TrackData& td); + template + void correctAfterParallelTransfer + ( + const label patchi, + TrackCloudType& cloud, + trackingData& td + ); // Interaction list referral @@ -687,12 +710,12 @@ public: // I-O //- Read the fields associated with the owner cloud - template - static void readFields(CloudType& c); + template + static void readFields(TrackCloudType& c); //- Write the fields associated with the owner cloud - template - static void writeFields(const CloudType& c); + template + static void writeFields(const TrackCloudType& c); //- Write the particle position and cell void writePosition(Ostream&) const; diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index 72aa0bad98..0f4b204873 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -37,11 +37,12 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template +template void Foam::particle::prepareForParallelTransfer ( const label patchi, - TrackData& td + TrackCloudType& cloud, + trackingData& td ) { // Convert the face index to be local to the processor patch @@ -49,11 +50,12 @@ void Foam::particle::prepareForParallelTransfer } -template +template void Foam::particle::correctAfterParallelTransfer ( const label patchi, - TrackData& td + TrackCloudType& cloud, + trackingData& td ) { const coupledPolyPatch& ppp = @@ -101,8 +103,8 @@ void Foam::particle::correctAfterParallelTransfer // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void Foam::particle::readFields(CloudType& c) +template +void Foam::particle::readFields(TrackCloudType& c) { bool valid = c.size(); @@ -120,7 +122,7 @@ void Foam::particle::readFields(CloudType& c) c.checkFieldIOobject(c, origId); label i = 0; - forAllIter(typename CloudType, c, iter) + forAllIter(typename TrackCloudType, c, iter) { particle& p = iter(); @@ -131,12 +133,12 @@ void Foam::particle::readFields(CloudType& c) } -template -void Foam::particle::writeFields(const CloudType& c) +template +void Foam::particle::writeFields(const TrackCloudType& c) { label np = c.size(); - IOPosition ioP(c); + IOPosition ioP(c); ioP.write(np > 0); IOField