Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

BUG: patchCloudSet: only take hits. Use local bounding box for tree

  • Loading branch information...
commit 4385da96e172ba189d29c8336b7dc4a95295fad2 1 parent c0f4804
authored July 14, 2011
63  src/sampling/sampledSet/patchCloud/patchCloudSet.C
@@ -26,14 +26,13 @@ License
26 26
 #include "patchCloudSet.H"
27 27
 #include "polyMesh.H"
28 28
 #include "addToRunTimeSelectionTable.H"
29  
-#include "pointIndexHit.H"
30  
-#include "Tuple2.H"
31 29
 #include "treeBoundBox.H"
32  
-#include "indexedOctree.H"
33 30
 #include "treeDataFace.H"
34 31
 #include "Time.H"
35 32
 #include "meshTools.H"
36 33
 #include "wordReList.H"
  34
+// For 'nearInfo' helper class only
  35
+#include "directMappedPatchBase.H"
37 36
 
38 37
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 38
 
@@ -41,36 +40,6 @@ namespace Foam
41 40
 {
42 41
     defineTypeNameAndDebug(patchCloudSet, 0);
43 42
     addToRunTimeSelectionTable(sampledSet, patchCloudSet, word);
44  
-
45  
-
46  
-    //- Helper class for finding nearest
47  
-    // Nearest:
48  
-    //  - point+local index
49  
-    //  - sqr(distance)
50  
-    //  - processor
51  
-    typedef Tuple2<pointIndexHit, Tuple2<scalar, label> > nearInfo;
52  
-
53  
-    class nearestEqOp
54  
-    {
55  
-
56  
-    public:
57  
-
58  
-        void operator()(nearInfo& x, const nearInfo& y) const
59  
-        {
60  
-            if (y.first().hit())
61  
-            {
62  
-                if (!x.first().hit())
63  
-                {
64  
-                    x = y;
65  
-                }
66  
-                else if (y.second().first() < x.second().first())
67  
-                {
68  
-                    x = y;
69  
-                }
70  
-            }
71  
-        }
72  
-    };
73  
-    
74 43
 }
75 44
 
76 45
 
@@ -116,7 +85,8 @@ void Foam::patchCloudSet::calcSamples
116 85
             patchFaces[sz++] = pp.start()+i;
117 86
         }
118 87
 
119  
-        const boundBox patchBb(pp.localPoints());
  88
+        // Do not do reduction.
  89
+        const boundBox patchBb(pp.localPoints(), false);
120 90
 
121 91
         bb.min() = min(bb.min(), patchBb.min());
122 92
         bb.max() = max(bb.max(), patchBb.max());
@@ -127,6 +97,7 @@ void Foam::patchCloudSet::calcSamples
127 97
     // Make bb asymetric just to avoid problems on symmetric meshes
128 98
     bb = bb.extend(rndGen, 1E-4);
129 99
 
  100
+    // Make sure bb is 3D.
130 101
     bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
131 102
     bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
132 103
 
@@ -148,7 +119,7 @@ void Foam::patchCloudSet::calcSamples
148 119
 
149 120
 
150 121
     // All the info for nearest. Construct to miss
151  
-    List<nearInfo> nearest(sampleCoords_.size());
  122
+    List<directMappedPatchBase::nearInfo> nearest(sampleCoords_.size());
152 123
 
153 124
     forAll(sampleCoords_, sampleI)
154 125
     {
@@ -157,7 +128,15 @@ void Foam::patchCloudSet::calcSamples
157 128
         pointIndexHit& nearInfo = nearest[sampleI].first();
158 129
 
159 130
         // Find the nearest locally
160  
-        nearInfo = patchTree.findNearest(sample, magSqr(bb.span()));
  131
+        if (patchFaces.size())
  132
+        {
  133
+            nearInfo = patchTree.findNearest(sample, magSqr(bb.span()));
  134
+        }
  135
+        else
  136
+        {
  137
+            nearInfo.setMiss();
  138
+        }
  139
+
161 140
 
162 141
         // Fill in the distance field and the processor field
163 142
         if (!nearInfo.hit())
@@ -181,7 +160,7 @@ void Foam::patchCloudSet::calcSamples
181 160
 
182 161
 
183 162
     // Find nearest.
184  
-    Pstream::listCombineGather(nearest, nearestEqOp());
  163
+    Pstream::listCombineGather(nearest, directMappedPatchBase::nearestEqOp());
185 164
     Pstream::listCombineScatter(nearest);
186 165
 
187 166
 
@@ -212,10 +191,14 @@ void Foam::patchCloudSet::calcSamples
212 191
     // Store the sampling locations on the nearest processor
213 192
     forAll(nearest, sampleI)
214 193
     {
215  
-        if (nearest[sampleI].second().second() == Pstream::myProcNo())
216  
-        {
217  
-            const pointIndexHit& nearInfo = nearest[sampleI].first();
  194
+        const pointIndexHit& nearInfo = nearest[sampleI].first();
218 195
 
  196
+        if
  197
+        (
  198
+            nearInfo.hit()
  199
+         && nearest[sampleI].second().second() == Pstream::myProcNo()
  200
+        )
  201
+        {
219 202
             label faceI = nearInfo.index();
220 203
 
221 204
             samplingPts.append(nearInfo.hitPoint());

0 notes on commit 4385da9

Please sign in to comment.
Something went wrong with that request. Please try again.