Bug fix: fixed cell bounding box search

This commit is contained in:
Hrvoje Jasak 2015-07-04 21:30:35 +01:00
parent 2f05fe31af
commit 2c21b8b9f7

View file

@ -25,39 +25,18 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "cell.H" #include "cell.H"
#include "boundBox.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Is the point in the cell bounding box // Is the point in the cell bounding box
bool Foam::primitiveMesh::pointInCellBB(const point& p, label celli) const bool Foam::primitiveMesh::pointInCellBB(const point& p, label celli) const
{ {
const pointField& points = this->points(); // Make bounding box for check. All points are local, so no reduce is
const faceList& f = faces(); // needed
const vectorField& centres = cellCentres(); boundBox bb(cells()[celli].points(faces(), points()), false);
const cellList& cf = cells();
labelList cellVertices = cf[celli].labels(f); return bb.contains(p);
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;
}
} }