indexing fixes

This commit is contained in:
mattijs
2008-09-09 17:12:55 +01:00
parent 40d72633ce
commit 0d1d3014c3
2 changed files with 34 additions and 34 deletions

View File

@ -86,7 +86,7 @@ bool Foam::meshSearch::findNearer
if (distSqr < nearestDistSqr) if (distSqr < nearestDistSqr)
{ {
nearestDistSqr = distSqr; nearestDistSqr = distSqr;
nearestI = i; nearestI = pointI;
nearer = true; nearer = true;
} }
} }
@ -117,18 +117,18 @@ Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const
{ {
const vectorField& centres = mesh_.cellCentres(); const vectorField& centres = mesh_.cellCentres();
label nearestCelli = 0; label nearestIndex = 0;
scalar minProximity = magSqr(centres[nearestCelli] - location); scalar minProximity = magSqr(centres[nearestIndex] - location);
findNearer findNearer
( (
location, location,
centres, centres,
nearestCelli, nearestIndex,
minProximity minProximity
); );
return nearestCelli; return nearestIndex;
} }
@ -147,30 +147,27 @@ Foam::label Foam::meshSearch::findNearestCellWalk
) << "illegal seedCell:" << seedCellI << exit(FatalError); ) << "illegal seedCell:" << seedCellI << exit(FatalError);
} }
const vectorField& centres = mesh_.cellCentres();
const labelListList& cc = mesh_.cellCells();
// Walk in direction of face that decreases distance // Walk in direction of face that decreases distance
label curCell = seedCellI; label curCellI = seedCellI;
scalar distanceSqr = magSqr(centres[curCell] - location); scalar distanceSqr = magSqr(mesh_.cellCentres()[curCellI] - location);
bool closer; bool closer;
do do
{ {
// Try neighbours of curCellI
closer = findNearer closer = findNearer
( (
location, location,
centres, mesh_.cellCentres(),
cc[curCell], mesh_.cellCells()[curCellI],
curCell, curCellI,
distanceSqr distanceSqr
); );
} while (closer); } while (closer);
return curCell; return curCellI;
} }
@ -195,6 +192,7 @@ Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
// Now check any of the faces of the nearest cell // Now check any of the faces of the nearest cell
const vectorField& centres = mesh_.faceCentres(); const vectorField& centres = mesh_.faceCentres();
const cell& ownFaces = mesh_.cells()[info.index()]; const cell& ownFaces = mesh_.cells()[info.index()];
label nearestFaceI = ownFaces[0]; label nearestFaceI = ownFaces[0];
scalar minProximity = magSqr(centres[nearestFaceI] - location); scalar minProximity = magSqr(centres[nearestFaceI] - location);
@ -251,43 +249,43 @@ Foam::label Foam::meshSearch::findNearestFaceWalk
// Walk in direction of face that decreases distance // Walk in direction of face that decreases distance
label curFace = seedFaceI; label curFaceI = seedFaceI;
scalar distanceSqr = magSqr(centres[curFace] - location); scalar distanceSqr = magSqr(centres[curFaceI] - location);
while (true) while (true)
{ {
label betterFace = curFace; label betterFaceI = curFaceI;
findNearer findNearer
( (
location, location,
centres, centres,
mesh_.cells()[mesh_.faceOwner()[curFace]], mesh_.cells()[mesh_.faceOwner()[curFaceI]],
betterFace, betterFaceI,
distanceSqr distanceSqr
); );
if (mesh_.isInternalFace(curFace)) if (mesh_.isInternalFace(curFaceI))
{ {
findNearer findNearer
( (
location, location,
centres, centres,
mesh_.cells()[mesh_.faceNeighbour()[curFace]], mesh_.cells()[mesh_.faceNeighbour()[curFaceI]],
betterFace, betterFaceI,
distanceSqr distanceSqr
); );
} }
if (betterFace == curFace) if (betterFaceI == curFaceI)
{ {
break; break;
} }
curFace = betterFace; curFaceI = betterFaceI;
} }
return curFace; return curFaceI;
} }
@ -463,18 +461,20 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
treeBoundBox overallBb(mesh_.points()); treeBoundBox overallBb(mesh_.points());
Random rndGen(123456);
boundaryTreePtr_ = new indexedOctree<treeDataFace> boundaryTreePtr_ = new indexedOctree<treeDataFace>
( (
treeDataFace // all information needed to search faces treeDataFace // all information needed to search faces
( (
false, // do not cache bb false, // do not cache bb
mesh_, mesh_,
bndFaces // boundary faces only bndFaces // boundary faces only
), ),
overallBb, // overall search domain overallBb.extend(rndGen, 1E-3), // overall search domain
8, // maxLevel 8, // maxLevel
10, // leafsize 10, // leafsize
3.0 // duplicity 3.0 // duplicity
); );
} }

View File

@ -215,8 +215,8 @@ public:
label findNearestFace label findNearestFace
( (
const point& location, const point& location,
const label seedFaceI, const label seedFaceI = -1,
const bool useTreeSearch const bool useTreeSearch = true
) const; ) const;
//- Find cell containing (using pointInCell) location. //- Find cell containing (using pointInCell) location.