ENH: primitive/poly-Mesh - updated find cell routines

This commit is contained in:
andy
2013-11-19 15:34:11 +00:00
parent 0a5eacf72c
commit 0db70bd8bd
2 changed files with 55 additions and 21 deletions

View File

@ -1351,8 +1351,10 @@ bool Foam::polyMesh::pointInCell
case FACECENTRETETS: case FACECENTRETETS:
{ {
const point& cc = cellCentres()[cellI]; // only test that point is on inside of plane defined by cell face
// triangles
const cell& cFaces = cells()[cellI]; const cell& cFaces = cells()[cellI];
forAll(cFaces, cFaceI) forAll(cFaces, cFaceI)
{ {
label faceI = cFaces[cFaceI]; label faceI = cFaces[cFaceI];
@ -1376,31 +1378,61 @@ bool Foam::polyMesh::pointInCell
nextPointI = f[fp]; nextPointI = f[fp];
} }
if const point& p0 = points()[pointI];
( const point& p1 = points()[nextPointI];
tetPointRef const point& p2 = fc;
(
points()[nextPointI], vector twoFaceArea = (p1 - p0)^(p2 - p0);
points()[pointI], point centre = (p0 + p1 + p2)/3.0;
fc, vector proj = p - centre;
cc
).inside(p) if ((twoFaceArea & proj) > 0)
)
{ {
return true; return false;
} }
} }
} }
return false; return true;
} }
break; break;
case FACEDIAGTETS: case FACEDIAGTETS:
{ {
label tetFaceI, tetPtI; // only test that point is on inside of plane defined by cell face
findTetFacePt(cellI, p, tetFaceI, tetPtI); // triangles
const cell& cFaces = cells()[cellI];
return tetFaceI != -1; forAll(cFaces, cFaceI)
{
label faceI = cFaces[cFaceI];
const face& f = faces_[faceI];
for (label tetPtI = 1; tetPtI < f.size() - 1; tetPtI++)
{
// Get tetIndices of face triangle
tetIndices faceTetIs
(
polyMeshTetDecomposition::triangleTetIndices
(
*this,
faceI,
cellI,
tetPtI
)
);
triPointRef faceTri = faceTetIs.faceTri(*this);
vector proj = p - faceTri.centre();
if ((faceTri.normal() & proj) > 0)
{
return false;
}
}
}
return true;
} }
break; break;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,8 +66,6 @@ bool Foam::primitiveMesh::pointInCell(const point& p, label celli) const
const vectorField& cf = faceCentres(); const vectorField& cf = faceCentres();
const vectorField& Sf = faceAreas(); const vectorField& Sf = faceAreas();
bool inCell = true;
forAll(f, facei) forAll(f, facei)
{ {
label nFace = f[facei]; label nFace = f[facei];
@ -77,10 +75,14 @@ bool Foam::primitiveMesh::pointInCell(const point& p, label celli) const
{ {
normal = -normal; normal = -normal;
} }
inCell = inCell && ((normal & proj) <= 0);
if ((normal & proj) > 0)
{
return false;
}
} }
return inCell; return true;
} }