From 9d3f0eaefb021db3ad0e765589d7e5f9ebb3c05f Mon Sep 17 00:00:00 2001
From: graham <g.macpherson@opencfd.co.uk>
Date: Thu, 24 Sep 2009 10:33:29 +0100
Subject: [PATCH] Adding constraint of tracking motion in reduced dimension
 cases. Saving the full 3D velocity before constraining for tracking, then
 restoring afterwards.

---
 src/lagrangian/dsmc/Make/options                   |  6 ++++--
 .../dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/lagrangian/dsmc/Make/options b/src/lagrangian/dsmc/Make/options
index 15874b7b55a..55865dfabcd 100644
--- a/src/lagrangian/dsmc/Make/options
+++ b/src/lagrangian/dsmc/Make/options
@@ -1,7 +1,9 @@
 EXE_INC = \
     -I$(LIB_SRC)/finiteVolume/lnInclude \
-    -I$(LIB_SRC)/lagrangian/basic/lnInclude
+    -I$(LIB_SRC)/lagrangian/basic/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude
 
 LIB_LIBS = \
     -llagrangian \
-    -lfiniteVolume
+    -lfiniteVolume \
+    -lmeshTools
diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C
index ffd7c67d428..3742f3f8ea8 100644
--- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C
+++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C
@@ -25,6 +25,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "DsmcParcel.H"
+#include "meshTools.H"
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
@@ -47,8 +48,18 @@ bool Foam::DsmcParcel<ParcelType>::move
     scalar tEnd = (1.0 - p.stepFraction())*deltaT;
     const scalar dtMax = tEnd;
 
+    // Save the velocity to re-apply it after tracking
+    vector U_save = U_;
+
+    // Apply correction to velocity to constrain tracking for
+    // reduced-D cases
+    meshTools::constrainDirection(mesh, mesh.solutionD(), U_);
+
     while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL)
     {
+        // Apply correction to position for reduced-D cases
+        meshTools::constrainToMeshCentre(mesh, p.position());
+
         // Set the Lagrangian time-step
         scalar dt = min(dtMax, tEnd);
 
@@ -67,6 +78,9 @@ bool Foam::DsmcParcel<ParcelType>::move
         }
     }
 
+    // Restore the correct value of velocity
+    U_ = U_save;
+
     return td.keepParticle;
 }
 
-- 
GitLab