77 point& intersectionPoint
87 const label newFacei =
tree_.shapes().faceLabels()[index];
88 const face& newFace =
mesh.faces()[newFacei];
89 const scalar newDot =
mesh.faceAreas()[newFacei] & (
end - start);
92 const label oldFacei =
hits_[hiti].index();
93 const face& oldFace =
mesh.faces()[oldFacei];
95 mesh.faceAreas()[oldFacei] & (
end - start);
99 hits_[hiti].index() == newFacei
111 treeDataFace::findIntersectOp::operator()
127 bool Foam::meshSearch::findNearer
132 scalar& nearestDistSqr
141 if (distSqr < nearestDistSqr)
143 nearestDistSqr = distSqr;
153 bool Foam::meshSearch::findNearer
159 scalar& nearestDistSqr
166 label pointi = indices[i];
170 if (distSqr < nearestDistSqr)
172 nearestDistSqr = distSqr;
183 Foam::label Foam::meshSearch::findNearestCellTree(
const point& location)
const
185 const indexedOctree<treeDataCell>& tree = cellTree();
190 magSqr(tree.bb().max()-tree.bb().min())
195 info = tree.findNearest(location,
Foam::sqr(GREAT));
201 Foam::label Foam::meshSearch::findNearestCellLinear(
const point& location)
const
205 label nearestIndex = 0;
206 scalar minProximity =
magSqr(centres[nearestIndex] - location);
220 Foam::label Foam::meshSearch::findNearestCellWalk
222 const point& location,
223 const label seedCelli
234 label curCelli = seedCelli;
235 scalar distanceSqr =
magSqr(mesh_.cellCentres()[curCelli] - location);
246 mesh_.cellCells()[curCelli],
256 Foam::label Foam::meshSearch::findNearestFaceTree(
const point& location)
const
259 const indexedOctree<treeDataCell>& tree = cellTree();
265 magSqr(tree.bb().max()-tree.bb().min())
271 info = tree.findNearest(location,
Foam::sqr(GREAT));
277 const cell& ownFaces = mesh_.cells()[info.index()];
279 label nearestFacei = ownFaces[0];
280 scalar minProximity =
magSqr(centres[nearestFacei] - location);
295 Foam::label Foam::meshSearch::findNearestFaceLinear(
const point& location)
const
299 label nearestFacei = 0;
300 scalar minProximity =
magSqr(centres[nearestFacei] - location);
314 Foam::label Foam::meshSearch::findNearestFaceWalk
316 const point& location,
317 const label seedFacei
331 label curFacei = seedFacei;
332 scalar distanceSqr =
magSqr(centres[curFacei] - location);
336 label betterFacei = curFacei;
342 mesh_.cells()[mesh_.faceOwner()[curFacei]],
347 if (mesh_.isInternalFace(curFacei))
353 mesh_.cells()[mesh_.faceNeighbour()[curFacei]],
359 if (betterFacei == curFacei)
364 curFacei = betterFacei;
371 Foam::label Foam::meshSearch::findCellLinear(
const point& location)
const
373 bool cellFound =
false;
378 while ((!cellFound) && (
n < mesh_.nCells()))
380 if (mesh_.pointInCell(location,
n, cellDecompMode_))
399 Foam::label Foam::meshSearch::findCellWalk
401 const point& location,
402 const label seedCelli
411 if (mesh_.pointInCell(location, seedCelli, cellDecompMode_))
417 label curCelli = seedCelli;
418 scalar nearestDistSqr =
magSqr(mesh_.cellCentres()[curCelli] - location);
424 const cell& cFaces = mesh_.cells()[curCelli];
426 label nearestCelli = -1;
430 label facei = cFaces[i];
432 if (mesh_.isInternalFace(facei))
434 label celli = mesh_.faceOwner()[facei];
435 if (celli == curCelli)
437 celli = mesh_.faceNeighbour()[facei];
441 if (mesh_.pointInCell(location, celli, cellDecompMode_))
447 scalar distSqr =
magSqr(mesh_.cellCentres()[celli] - location);
449 if (distSqr < nearestDistSqr)
451 nearestDistSqr = distSqr;
452 nearestCelli = celli;
457 if (nearestCelli == -1)
463 curCelli = nearestCelli;
470 Foam::label Foam::meshSearch::findNearestBoundaryFaceWalk
472 const point& location,
473 const label seedFacei
484 label curFacei = seedFacei;
486 const face&
f = mesh_.faces()[curFacei];
488 scalar minDist =
f.nearestPoint
503 label lastFacei = curFacei;
505 const labelList& myEdges = mesh_.faceEdges()[curFacei];
509 const labelList& neighbours = mesh_.edgeFaces()[myEdges[myEdgeI]];
516 label facei = neighbours[nI];
520 (facei >= mesh_.nInternalFaces())
521 && (facei != lastFacei)
524 const face&
f = mesh_.faces()[facei];
533 if (curHit.distance() < minDist)
535 minDist = curHit.distance();
550 Foam::meshSearch::meshSearch
557 cellDecompMode_(cellDecompMode)
571 Foam::meshSearch::meshSearch
579 cellDecompMode_(cellDecompMode)
623 return *overallBbPtr_;
630 if (!boundaryTreePtr_)
635 identity(mesh_.nBoundaryFaces(), mesh_.nInternalFaces())
638 boundaryTreePtr_.reset
656 return *boundaryTreePtr_;
664 if (!nonCoupledBoundaryTreePtr_)
669 labelList bndFaces(mesh_.nBoundaryFaces());
678 bndFaces[bndi++] = pp.start()+i;
682 bndFaces.setSize(bndi);
684 nonCoupledBoundaryTreePtr_.reset
702 return *nonCoupledBoundaryTreePtr_;
729 return *cellTreePtr_;
735 const point& location,
736 const label seedCelli,
737 const bool useTreeSearch
744 return findNearestCellTree(location);
748 return findNearestCellLinear(location);
752 return findNearestCellWalk(location, seedCelli);
758 const point& location,
759 const label seedFacei,
760 const bool useTreeSearch
767 return findNearestFaceTree(location);
771 return findNearestFaceLinear(location);
775 return findNearestFaceWalk(location, seedFacei);
781 const point& location,
782 const label seedCelli,
783 const bool useTreeSearch
791 return cellTree().findInside(location);
795 return findCellLinear(location);
799 return findCellWalk(location, seedCelli);
805 const point& location,
806 const label seedFacei,
807 const bool useTreeSearch
824 info = boundaryTree().findNearest
835 scalar minDist = GREAT;
841 label facei = mesh_.nInternalFaces();
842 facei < mesh_.nFaces();
846 const face&
f = mesh_.faces()[facei];
865 return findNearestBoundaryFaceWalk(location, seedFacei);
875 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd);
880 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
898 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd, iop);
899 if (!curHit.
hit())
break;
902 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
921 boundaryTreePtr_.clear();
922 cellTreePtr_.clear();
923 overallBbPtr_.clear();