View Issue Details

IDProjectCategoryView StatusLast Update
0002235OpenFOAMPatchpublic2016-09-04 21:18
ReporterMattijsJAssigned Tohenry 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOpenSuSEOS Version13.2
Product Versiondev 
Fixed in Versiondev 
Summary0002235: polyMesh::movePoints does not clear out cellTreePtr_
DescriptioncellTreePtr_ should be cleared out whenever the mesh moves. There might be cases with a small motion where all cells might remain in the same node but that is extremely rare.

2) We can use the tree directly to search for the cell containing a point. There is no need to search for nearest first.

Attached patch does both.
Steps To Reproducetutorials/multiphase/compressibleInterDyMFoam/ras/sloshingTank2D

and set 'fixedLocations true' in the probes dictionary to enforce re-searching.
TagsNo tags attached.

Activities

MattijsJ

2016-09-04 20:23

reporter  

polyMesh_findCell.patch (2,282 bytes)
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
index 9f1db29..532ed89 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
@@ -1109,6 +1109,9 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
     faceZones_.movePoints(points_);
     cellZones_.movePoints(points_);
 
+    // Cell tree might become invalid
+    cellTreePtr_.clear();
+
     // Reset valid directions (could change with rotation)
     geometricD_ = Zero;
     solutionD_ = Zero;
@@ -1211,60 +1214,13 @@ void Foam::polyMesh::findCellFacePt
 
     const indexedOctree<treeDataCell>& tree = cellTree();
 
-    // Find nearest cell to the point
-    pointIndexHit info = tree.findNearest(p, sqr(GREAT));
+    // Find point inside cell
+    celli = tree.findInside(p);
 
-    if (info.hit())
+    if (celli != -1)
     {
-        label nearestCelli = tree.shapes().cellLabels()[info.index()];
-
         // Check the nearest cell to see if the point is inside.
-        findTetFacePt(nearestCelli, p, tetFacei, tetPti);
-
-        if (tetFacei != -1)
-        {
-            // Point was in the nearest cell
-
-            celli = nearestCelli;
-
-            return;
-        }
-        else
-        {
-            // Check the other possible cells that the point may be in
-
-            labelList testCells = tree.findIndices(p);
-
-            forAll(testCells, pCI)
-            {
-                label testCelli = tree.shapes().cellLabels()[testCells[pCI]];
-
-                if (testCelli == nearestCelli)
-                {
-                    // Don't retest the nearest cell
-
-                    continue;
-                }
-
-                // Check the test cell to see if the point is inside.
-                findTetFacePt(testCelli, p, tetFacei, tetPti);
-
-                if (tetFacei != -1)
-                {
-                    // Point was in the test cell
-
-                    celli = testCelli;
-
-                    return;
-                }
-            }
-        }
-    }
-    else
-    {
-        FatalErrorInFunction
-            << "Did not find nearest cell in search tree."
-            << abort(FatalError);
+        findTetFacePt(celli, p, tetFacei, tetPti);
     }
 }
 
polyMesh_findCell.patch (2,282 bytes)

henry

2016-09-04 21:18

manager   ~0006823

Resolved by commit fec5c063f5ce3691bf6bc37e87f5d97d5a45df69

Issue History

Date Modified Username Field Change
2016-09-04 20:23 MattijsJ New Issue
2016-09-04 20:23 MattijsJ File Added: polyMesh_findCell.patch
2016-09-04 21:18 henry Note Added: 0006823
2016-09-04 21:18 henry Status new => resolved
2016-09-04 21:18 henry Fixed in Version => dev
2016-09-04 21:18 henry Resolution open => fixed
2016-09-04 21:18 henry Assigned To => henry