diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C index c5c4e56234bcbe8cebbb051b23626cf71793f220..cdc5ec680c77ef187546eff4fe6949912a3b9e5e 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C @@ -53,17 +53,17 @@ bool Foam::DSMCParcel<ParcelType>::move while (td.keepParticle && !td.switchProcessor && p.stepFraction() < 1) { - // Apply correction to position for reduced-D cases - p.constrainToMeshCentre(); - Utracking = U_; // Apply correction to velocity to constrain tracking for // reduced-D cases meshTools::constrainDirection(mesh, mesh.solutionD(), Utracking); + // Deviation from the mesh centre for reduced-D cases + const vector d = p.deviationFromMeshCentre(); + const scalar f = 1 - p.stepFraction(); - p.trackToAndHitFace(f*trackTime*Utracking, f, cloud, td); + p.trackToAndHitFace(f*trackTime*Utracking - d, f, cloud, td); } return td.keepParticle; diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index e52ab0ba198fbe1c2e5ee2ed012d876c6f53e41d..904f4c5723549c1bddc67d9a39473750b095a04f 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -984,25 +984,17 @@ Foam::scalar Foam::particle::trackToTri } -void Foam::particle::constrainToMeshCentre() +Foam::vector Foam::particle::deviationFromMeshCentre() const { - const Vector<label>& dirs = mesh_.geometricD(); - - bool isConstrained = false; - forAll(dirs, dirI) + if (cmptMin(mesh_.geometricD()) == -1) { - if (dirs[dirI] == -1) - { - isConstrained = true; - break; - } + vector pos = position(), posC = pos; + meshTools::constrainToMeshCentre(mesh_, posC); + return pos - posC; } - - if (isConstrained) + else { - vector pos = position(); - meshTools::constrainToMeshCentre(mesh_, pos); - track(pos - position(), 0); + return vector::zero; } } diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 21a8536b05abe7141a39be6ce08c377e0ef499cf..67c4dc393d1ae392e756e27053b1114ef87aece4 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -598,9 +598,10 @@ public: trackingData& td ); - //- Set the constrained components of the particle position to the - // mesh centre. - void constrainToMeshCentre(); + //- Get the displacement from the mesh centre. Used to correct the + // particle position in cases with reduced dimensionality. Returns a + // zero vector for three-dimensional cases. + vector deviationFromMeshCentre() const; // Patch data diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index bc5d13c69efa8ced5929ff027b2cb07a85be6a13..394cf8ce2a7bfba700632699d376c1e69620a438 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -276,9 +276,6 @@ bool Foam::KinematicParcel<ParcelType>::move while (ttd.keepParticle && !ttd.switchProcessor && p.stepFraction() < 1) { - // Apply correction to position for reduced-D cases - p.constrainToMeshCentre(); - // Cache the current position, cell and step-fraction const point start = p.position(); const scalar sfrac = p.stepFraction(); @@ -289,6 +286,9 @@ bool Foam::KinematicParcel<ParcelType>::move // Cell length scale const scalar l = cellLengthScale[p.cell()]; + // Deviation from the mesh centre for reduced-D cases + const vector d = p.deviationFromMeshCentre(); + // Fraction of the displacement to track in this loop. This is limited // to ensure that the both the time and distance tracked is less than // maxCo times the total value. @@ -298,7 +298,7 @@ bool Foam::KinematicParcel<ParcelType>::move if (p.active()) { // Track to the next face - p.trackToFace(f*s, f); + p.trackToFace(f*s - d, f); } else {