From 2c21b8b9f74962299e3598deab64559fa355a7a3 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Sat, 4 Jul 2015 21:30:35 +0100 Subject: [PATCH] Bug fix: fixed cell bounding box search --- .../primitiveMesh/primitiveMeshFindCell.C | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C index b7c366fc4..907432cee 100644 --- a/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C +++ b/src/foam/meshes/primitiveMesh/primitiveMeshFindCell.C @@ -25,39 +25,18 @@ License #include "primitiveMesh.H" #include "cell.H" - +#include "boundBox.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Is the point in the cell bounding box bool Foam::primitiveMesh::pointInCellBB(const point& p, label celli) const { - const pointField& points = this->points(); - const faceList& f = faces(); - const vectorField& centres = cellCentres(); - const cellList& cf = cells(); + // Make bounding box for check. All points are local, so no reduce is + // needed + boundBox bb(cells()[celli].points(faces(), points()), false); - labelList cellVertices = cf[celli].labels(f); - - vector bbmax = -GREAT*vector::one; - vector bbmin = GREAT*vector::one; - - forAll (cellVertices, vertexI) - { - bbmax = max(bbmax, points[cellVertices[vertexI]]); - bbmin = min(bbmin, points[cellVertices[vertexI]]); - } - - scalar distance = mag(centres[celli] - p); - - if ((distance - mag(bbmax - bbmin)) < SMALL) - { - return true; - } - else - { - return false; - } + return bb.contains(p); }