From d7ff97f49029f83dc3b841adbbd43a1837f3a20f Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Tue, 12 Sep 2017 08:39:58 +0100 Subject: [PATCH] lagrangian: Optimised reduced-dimension constraints The 4.x tracking enforces reduced dimensionality on the parcels by moving them to the centre of the mesh at the start of each track, without considering the topology. This can leave the parcel outside it's associated tetrahedron. The barycentric algorithm isn't tolerant to incorrect topology, so instead of changing position, it was written to track to the mesh centre. This worked, but effectively doubled the number of tracking calls. This additional cost has now been removed by absorbing the constraint displacement into the existing motion track, so that the same number of tracking steps are performed as before. Partially resolves bug report https://bugs.openfoam.org/view.php?id=2688 --- .../parcels/Templates/DSMCParcel/DSMCParcel.C | 8 +++---- src/lagrangian/basic/particle/particle.C | 22 ++++++------------- src/lagrangian/basic/particle/particle.H | 7 +++--- .../KinematicParcel/KinematicParcel.C | 8 +++---- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.C index c5c4e56234..cdc5ec680c 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::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 e52ab0ba19..904f4c5723 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