meshSearch: Add support for cell decomposition mode CELL_TETS

Resolves bug-report https://bugs.openfoam.org/view.php?id=2428
This commit is contained in:
Henry Weller
2017-01-20 10:47:15 +00:00
parent 8632583934
commit 3ca17d43a2

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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -117,7 +117,6 @@ Foam::label Foam::meshSearch::findNearestCellTree(const point& location) const
} }
// linear searching
Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const
{ {
const vectorField& centres = mesh_.cellCentres(); const vectorField& centres = mesh_.cellCentres();
@ -137,7 +136,6 @@ Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const
} }
// walking from seed
Foam::label Foam::meshSearch::findNearestCellWalk Foam::label Foam::meshSearch::findNearestCellWalk
( (
const point& location, const point& location,
@ -174,7 +172,6 @@ Foam::label Foam::meshSearch::findNearestCellWalk
} }
// tree based searching
Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
{ {
// Search nearest cell centre. // Search nearest cell centre.
@ -214,7 +211,6 @@ Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
} }
// linear searching
Foam::label Foam::meshSearch::findNearestFaceLinear(const point& location) const Foam::label Foam::meshSearch::findNearestFaceLinear(const point& location) const
{ {
const vectorField& centres = mesh_.faceCentres(); const vectorField& centres = mesh_.faceCentres();
@ -234,7 +230,6 @@ Foam::label Foam::meshSearch::findNearestFaceLinear(const point& location) const
} }
// walking from seed
Foam::label Foam::meshSearch::findNearestFaceWalk Foam::label Foam::meshSearch::findNearestFaceWalk
( (
const point& location, const point& location,
@ -322,7 +317,6 @@ Foam::label Foam::meshSearch::findCellLinear(const point& location) const
} }
// walking from seed
Foam::label Foam::meshSearch::findCellWalk Foam::label Foam::meshSearch::findCellWalk
( (
const point& location, const point& location,
@ -502,7 +496,10 @@ Foam::meshSearch::meshSearch
mesh_(mesh), mesh_(mesh),
cellDecompMode_(cellDecompMode) cellDecompMode_(cellDecompMode)
{ {
if (cellDecompMode_ == polyMesh::FACE_DIAG_TRIS) if
(
cellDecompMode_ == polyMesh::FACE_DIAG_TRIS
|| cellDecompMode_ == polyMesh::CELL_TETS)
{ {
// Force construction of face diagonals // Force construction of face diagonals
(void)mesh.tetBasePtIs(); (void)mesh.tetBasePtIs();
@ -510,7 +507,6 @@ Foam::meshSearch::meshSearch
} }
// Construct with a custom bounding box
Foam::meshSearch::meshSearch Foam::meshSearch::meshSearch
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -523,7 +519,11 @@ Foam::meshSearch::meshSearch
{ {
overallBbPtr_.reset(new treeBoundBox(bb)); overallBbPtr_.reset(new treeBoundBox(bb));
if (cellDecompMode_ == polyMesh::FACE_DIAG_TRIS) if
(
cellDecompMode_ == polyMesh::FACE_DIAG_TRIS
|| cellDecompMode_ == polyMesh::CELL_TETS
)
{ {
// Force construction of face diagonals // Force construction of face diagonals
(void)mesh.tetBasePtIs(); (void)mesh.tetBasePtIs();
@ -541,8 +541,8 @@ Foam::meshSearch::~meshSearch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree() const Foam::indexedOctree<Foam::treeDataFace>&
const Foam::meshSearch::boundaryTree() const
{ {
if (!boundaryTreePtr_.valid()) if (!boundaryTreePtr_.valid())
{ {
@ -594,8 +594,8 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
} }
const Foam::indexedOctree<Foam::treeDataCell>& Foam::meshSearch::cellTree() const Foam::indexedOctree<Foam::treeDataCell>&
const Foam::meshSearch::cellTree() const
{ {
if (!cellTreePtr_.valid()) if (!cellTreePtr_.valid())
{ {
@ -640,92 +640,6 @@ const
} }
//// Is the point in the cell
//// Works by checking if there is a face inbetween the point and the cell
//// centre.
//// Check for internal uses proper face decomposition or just average normal.
//bool Foam::meshSearch::pointInCell(const point& p, label celli) const
//{
// if (faceDecomp_)
// {
// const point& ctr = mesh_.cellCentres()[celli];
//
// vector dir(p - ctr);
// scalar magDir = mag(dir);
//
// // Check if any faces are hit by ray from cell centre to p.
// // If none -> p is in cell.
// const labelList& cFaces = mesh_.cells()[celli];
//
// // Make sure half_ray does not pick up any faces on the wrong
// // side of the ray.
// scalar oldTol = intersection::setPlanarTol(0.0);
//
// forAll(cFaces, i)
// {
// label facei = cFaces[i];
//
// pointHit inter = mesh_.faces()[facei].ray
// (
// ctr,
// dir,
// mesh_.points(),
// intersection::HALF_RAY,
// intersection::VECTOR
// );
//
// if (inter.hit())
// {
// scalar dist = inter.distance();
//
// if (dist < magDir)
// {
// // Valid hit. Hit face so point is not in cell.
// intersection::setPlanarTol(oldTol);
//
// return false;
// }
// }
// }
//
// intersection::setPlanarTol(oldTol);
//
// // No face inbetween point and cell centre so point is inside.
// return true;
// }
// else
// {
// const labelList& f = mesh_.cells()[celli];
// const labelList& owner = mesh_.faceOwner();
// const vectorField& cf = mesh_.faceCentres();
// const vectorField& Sf = mesh_.faceAreas();
//
// forAll(f, facei)
// {
// label nFace = f[facei];
// vector proj = p - cf[nFace];
// vector normal = Sf[nFace];
// if (owner[nFace] == celli)
// {
// if ((normal & proj) > 0)
// {
// return false;
// }
// }
// else
// {
// if ((normal & proj) < 0)
// {
// return false;
// }
// }
// }
//
// return true;
// }
//}
Foam::label Foam::meshSearch::findNearestCell Foam::label Foam::meshSearch::findNearestCell
( (
const point& location, const point& location,
@ -941,7 +855,6 @@ bool Foam::meshSearch::isInside(const point& p) const
} }
// Delete all storage
void Foam::meshSearch::clearOut() void Foam::meshSearch::clearOut()
{ {
boundaryTreePtr_.clear(); boundaryTreePtr_.clear();