From 1277b4b8c447cf14d1d33afce823f119a63f4ac0 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Mon, 29 Feb 2016 12:09:46 +0000
Subject: [PATCH] sampledSets: use smallDist consistently between
 getTrackingPoint and other tracking functions

Use different hit-tolerances between sampling methods to account for the
difference in the "offset" definition.
---
 src/sampling/sampledSet/face/faceOnlySet.C      |  6 ++++--
 src/sampling/sampledSet/face/faceOnlySet.H      | 10 +++++++++-
 src/sampling/sampledSet/polyLine/polyLineSet.C  |  6 ++++--
 src/sampling/sampledSet/polyLine/polyLineSet.H  |  9 ++++++++-
 src/sampling/sampledSet/sampledSet/sampledSet.C |  7 +------
 src/sampling/sampledSet/sampledSet/sampledSet.H | 11 ++---------
 src/sampling/sampledSet/uniform/uniformSet.C    |  6 ++++--
 src/sampling/sampledSet/uniform/uniformSet.H    | 10 +++++++++-
 8 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/src/sampling/sampledSet/face/faceOnlySet.C b/src/sampling/sampledSet/face/faceOnlySet.C
index d8aedfee9aa..0225658febd 100644
--- a/src/sampling/sampledSet/face/faceOnlySet.C
+++ b/src/sampling/sampledSet/face/faceOnlySet.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -36,6 +36,8 @@ namespace Foam
 {
     defineTypeNameAndDebug(faceOnlySet, 0);
     addToRunTimeSelectionTable(sampledSet, faceOnlySet, word);
+
+    const scalar faceOnlySet::tol = 1e-6;
 }
 
 
@@ -146,10 +148,10 @@ void Foam::faceOnlySet::calcSamples
 
     getTrackingPoint
     (
-        offset,
         start_,
         bPoint,
         bFaceI,
+        smallDist,
 
         trackPt,
         trackCellI,
diff --git a/src/sampling/sampledSet/face/faceOnlySet.H b/src/sampling/sampledSet/face/faceOnlySet.H
index fdb47d4d435..61f20c7ce79 100644
--- a/src/sampling/sampledSet/face/faceOnlySet.H
+++ b/src/sampling/sampledSet/face/faceOnlySet.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -96,6 +96,14 @@ public:
     //- Runtime type information
     TypeName("face");
 
+
+    // Static data
+
+        //- Tolerance when comparing points relative to difference between
+        //  start_ and end_
+        static const scalar tol;
+
+
     // Constructors
 
         //- Construct from components
diff --git a/src/sampling/sampledSet/polyLine/polyLineSet.C b/src/sampling/sampledSet/polyLine/polyLineSet.C
index 7ce2e3fdc23..f5ff5b461bb 100644
--- a/src/sampling/sampledSet/polyLine/polyLineSet.C
+++ b/src/sampling/sampledSet/polyLine/polyLineSet.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -36,6 +36,8 @@ namespace Foam
 {
     defineTypeNameAndDebug(polyLineSet, 0);
     addToRunTimeSelectionTable(sampledSet, polyLineSet, word);
+
+    const scalar polyLineSet::tol = 1e-6;
 }
 
 
@@ -205,10 +207,10 @@ void Foam::polyLineSet::calcSamples
             bool isSample =
                 getTrackingPoint
                 (
-                    sampleCoords_[sampleI+1] - sampleCoords_[sampleI],
                     sampleCoords_[sampleI],
                     bPoint,
                     bFaceI,
+                    smallDist,
 
                     trackPt,
                     trackCellI,
diff --git a/src/sampling/sampledSet/polyLine/polyLineSet.H b/src/sampling/sampledSet/polyLine/polyLineSet.H
index 3dc880246a8..c97ff9fc7d0 100644
--- a/src/sampling/sampledSet/polyLine/polyLineSet.H
+++ b/src/sampling/sampledSet/polyLine/polyLineSet.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -95,6 +95,13 @@ public:
     TypeName("polyLine");
 
 
+    // Static data
+
+        //- Tolerance when comparing points relative to difference between
+        //  start_ and end_
+        static const scalar tol;
+
+
     // Constructors
 
         //- Construct from components
diff --git a/src/sampling/sampledSet/sampledSet/sampledSet.C b/src/sampling/sampledSet/sampledSet/sampledSet.C
index 00f843d5705..ff58cef6bf0 100644
--- a/src/sampling/sampledSet/sampledSet/sampledSet.C
+++ b/src/sampling/sampledSet/sampledSet/sampledSet.C
@@ -34,8 +34,6 @@ License
 
 namespace Foam
 {
-    const scalar sampledSet::tol = 1e-3;
-
     defineTypeNameAndDebug(sampledSet, 0);
     defineRunTimeSelectionTable(sampledSet, word);
 }
@@ -227,18 +225,16 @@ Foam::point Foam::sampledSet::pushIn
 
 bool Foam::sampledSet::getTrackingPoint
 (
-    const vector& offset,
     const point& samplePt,
     const point& bPoint,
     const label bFaceI,
+    const scalar smallDist,
 
     point& trackPt,
     label& trackCellI,
     label& trackFaceI
 ) const
 {
-    const scalar smallDist = mag(tol*offset);
-
     bool isGoodSample = false;
 
     if (bFaceI == -1)
@@ -311,7 +307,6 @@ bool Foam::sampledSet::getTrackingPoint
     if (debug)
     {
         InfoInFunction
-            << " offset:" << offset
             << " samplePt:" << samplePt
             << " bPoint:" << bPoint
             << " bFaceI:" << bFaceI
diff --git a/src/sampling/sampledSet/sampledSet/sampledSet.H b/src/sampling/sampledSet/sampledSet/sampledSet.H
index 810d4565edc..005ef61c1cb 100644
--- a/src/sampling/sampledSet/sampledSet/sampledSet.H
+++ b/src/sampling/sampledSet/sampledSet/sampledSet.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -125,10 +125,10 @@ protected:
         //  trackFaceI, trackCellI (-1 if no tracking point found)
         bool getTrackingPoint
         (
-            const vector& offset,
             const point& samplePt,
             const point& bPoint,
             const label bFaceI,
+            const scalar smallDist,
 
             point& trackPt,
             label& trackCellI,
@@ -193,13 +193,6 @@ public:
         };
 
 
-    // Static data
-
-        //- Tolerance when comparing points. Usually relative to difference
-        //  between start_ and end_
-        static const scalar tol;
-
-
     // Constructors
 
         //- Construct from components
diff --git a/src/sampling/sampledSet/uniform/uniformSet.C b/src/sampling/sampledSet/uniform/uniformSet.C
index 295a3e79e36..75376d27787 100644
--- a/src/sampling/sampledSet/uniform/uniformSet.C
+++ b/src/sampling/sampledSet/uniform/uniformSet.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -36,6 +36,8 @@ namespace Foam
 {
     defineTypeNameAndDebug(uniformSet, 0);
     addToRunTimeSelectionTable(sampledSet, uniformSet, word);
+
+    const scalar uniformSet::tol = 1e-3;
 }
 
 
@@ -260,10 +262,10 @@ void Foam::uniformSet::calcSamples
     bool isSample =
         getTrackingPoint
         (
-            offset,
             start_,
             bPoint,
             bFaceI,
+            smallDist,
 
             trackPt,
             trackCellI,
diff --git a/src/sampling/sampledSet/uniform/uniformSet.H b/src/sampling/sampledSet/uniform/uniformSet.H
index edd5212e517..a9f29ed2b9a 100644
--- a/src/sampling/sampledSet/uniform/uniformSet.H
+++ b/src/sampling/sampledSet/uniform/uniformSet.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -112,6 +112,14 @@ public:
     //- Runtime type information
     TypeName("uniform");
 
+
+    // Static data
+
+        //- Tolerance when comparing points relative to difference between
+        //  start_ and end_
+        static const scalar tol;
+
+
     // Constructors
 
         //- Construct from components
-- 
GitLab