diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index bc59306401..69475c98e6 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,9 +35,9 @@ License namespace Foam { -defineTypeNameAndDebug(meshSearch, 0); + defineTypeNameAndDebug(meshSearch, 0); -scalar meshSearch::tol_ = 1e-3; + scalar meshSearch::tol_ = 1e-3; } @@ -117,7 +117,6 @@ Foam::label Foam::meshSearch::findNearestCellTree(const point& location) const } -// linear searching Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const { 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 ( const point& location, @@ -174,7 +172,6 @@ Foam::label Foam::meshSearch::findNearestCellWalk } -// tree based searching Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const { // 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 { 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 ( const point& location, @@ -322,7 +317,6 @@ Foam::label Foam::meshSearch::findCellLinear(const point& location) const } -// walking from seed Foam::label Foam::meshSearch::findCellWalk ( const point& location, @@ -502,7 +496,10 @@ Foam::meshSearch::meshSearch mesh_(mesh), cellDecompMode_(cellDecompMode) { - if (cellDecompMode_ == polyMesh::FACE_DIAG_TRIS) + if + ( + cellDecompMode_ == polyMesh::FACE_DIAG_TRIS + || cellDecompMode_ == polyMesh::CELL_TETS) { // Force construction of face diagonals (void)mesh.tetBasePtIs(); @@ -510,7 +507,6 @@ Foam::meshSearch::meshSearch } -// Construct with a custom bounding box Foam::meshSearch::meshSearch ( const polyMesh& mesh, @@ -523,7 +519,11 @@ Foam::meshSearch::meshSearch { 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 (void)mesh.tetBasePtIs(); @@ -541,8 +541,8 @@ Foam::meshSearch::~meshSearch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::indexedOctree& Foam::meshSearch::boundaryTree() - const +const Foam::indexedOctree& +Foam::meshSearch::boundaryTree() const { if (!boundaryTreePtr_.valid()) { @@ -594,8 +594,8 @@ const Foam::indexedOctree& Foam::meshSearch::boundaryTree() } -const Foam::indexedOctree& Foam::meshSearch::cellTree() -const +const Foam::indexedOctree& +Foam::meshSearch::cellTree() const { 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 ( const point& location, @@ -941,7 +855,6 @@ bool Foam::meshSearch::isInside(const point& p) const } -// Delete all storage void Foam::meshSearch::clearOut() { boundaryTreePtr_.clear();