75 point& intersectionPoint
85 const label newFacei =
tree_.shapes().faceLabels()[index];
86 const face& newFace = mesh.
faces()[newFacei];
87 const scalar newDot = mesh.
faceAreas()[newFacei] & (end - start);
91 const face& oldFace = mesh.
faces()[oldFacei];
93 mesh.
faceAreas()[oldFacei] & (end - start);
97 hits_[hiti].index() == newFacei
109 treeDataFace::findIntersectOp::operator()
125 bool Foam::meshSearch::findNearer
130 scalar& nearestDistSqr
139 if (distSqr < nearestDistSqr)
141 nearestDistSqr = distSqr;
151 bool Foam::meshSearch::findNearer
157 scalar& nearestDistSqr
164 label pointi = indices[i];
168 if (distSqr < nearestDistSqr)
170 nearestDistSqr = distSqr;
181 Foam::label Foam::meshSearch::findNearestCellTree(
const point& location)
const
183 const indexedOctree<treeDataCell>& tree = cellTree();
188 magSqr(tree.bb().max()-tree.bb().min())
193 info = tree.findNearest(location,
Foam::sqr(great));
199 Foam::label Foam::meshSearch::findNearestCellLinear(
const point& location)
const
203 label nearestIndex = 0;
204 scalar minProximity =
magSqr(centres[nearestIndex] - location);
220 const point& location,
221 const label seedCelli
232 label curCelli = seedCelli;
233 scalar distanceSqr =
magSqr(mesh_.cellCentres()[curCelli] - location);
244 mesh_.cellCells()[curCelli],
254 Foam::label Foam::meshSearch::findNearestFaceTree(
const point& location)
const
257 const indexedOctree<treeDataCell>& tree = cellTree();
263 magSqr(tree.bb().max()-tree.bb().min())
269 info = tree.findNearest(location,
Foam::sqr(great));
275 const cell& ownFaces = mesh_.cells()[info.index()];
277 label nearestFacei = ownFaces[0];
278 scalar minProximity =
magSqr(centres[nearestFacei] - location);
293 Foam::label Foam::meshSearch::findNearestFaceLinear(
const point& location)
const
297 label nearestFacei = 0;
298 scalar minProximity =
magSqr(centres[nearestFacei] - location);
314 const point& location,
315 const label seedFacei
329 label curFacei = seedFacei;
330 scalar distanceSqr =
magSqr(centres[curFacei] - location);
334 label betterFacei = curFacei;
340 mesh_.cells()[mesh_.faceOwner()[curFacei]],
345 if (mesh_.isInternalFace(curFacei))
351 mesh_.cells()[mesh_.faceNeighbour()[curFacei]],
357 if (betterFacei == curFacei)
362 curFacei = betterFacei;
371 bool cellFound =
false;
376 while ((!cellFound) && (
n < mesh_.nCells()))
378 if (mesh_.pointInCell(location,
n, cellDecompMode_))
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];
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)
557 cellDecompMode_(cellDecompMode)
578 cellDecompMode_(cellDecompMode)
607 if (!boundaryTreePtr_.valid())
613 if (!overallBbPtr_.valid())
623 overallBb = overallBb.
extend(1
e-4);
627 labelList bndFaces(mesh_.nFaces()-mesh_.nInternalFaces());
630 bndFaces[i] = mesh_.nInternalFaces() + i;
633 boundaryTreePtr_.reset
651 return boundaryTreePtr_();
658 if (!cellTreePtr_.valid())
664 if (!overallBbPtr_.valid())
674 overallBb = overallBb.
extend(1
e-4);
695 return cellTreePtr_();
701 const point& location,
702 const label seedCelli,
703 const bool useTreeSearch
710 return findNearestCellTree(location);
714 return findNearestCellLinear(location);
719 return findNearestCellWalk(location, seedCelli);
726 const point& location,
727 const label seedFacei,
728 const bool useTreeSearch
735 return findNearestFaceTree(location);
739 return findNearestFaceLinear(location);
744 return findNearestFaceWalk(location, seedFacei);
751 const point& location,
752 const label seedCelli,
753 const bool useTreeSearch
761 return cellTree().findInside(location);
765 return findCellLinear(location);
770 return findCellWalk(location, seedCelli);
777 const point& location,
778 const label seedFacei,
779 const bool useTreeSearch
796 info = boundaryTree().findNearest
813 label facei = mesh_.nInternalFaces();
814 facei < mesh_.nFaces();
818 const face&
f = mesh_.faces()[facei];
838 return findNearestBoundaryFaceWalk(location, seedFacei);
849 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd);
854 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
874 curHit = boundaryTree().findLine(pStart, pEnd, iop);
875 if (!curHit.
hit())
break;
878 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
897 boundaryTreePtr_.clear();
898 cellTreePtr_.clear();
899 overallBbPtr_.clear();
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
scalar distance() const
Return distance to hit.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
label index() const
Return index.
bool hit() const
Is there a hit.
void setIndex(const label index)
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
A face is a list of labels corresponding to mesh vertices.
const List< pointIndexHit > & hits_
findUniqueIntersectOp(const indexedOctree< treeDataFace > &tree, const List< pointIndexHit > &hits)
Construct from components.
const indexedOctree< treeDataFace > & tree_
Non-pointer based hierarchical recursive searching.
const Type & shapes() const
Reference to shape.
const treeBoundBox & bb() const
Top bounding box.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
label findNearestBoundaryFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
Find nearest boundary face.
pointIndexHit intersection(const point &pStart, const point &pEnd) const
Find first intersection of boundary in segment [pStart, pEnd].
const indexedOctree< treeDataFace > & boundaryTree() const
Get (demand driven) reference to octree holding all.
void correct()
Correct for mesh geom/topo changes.
bool isInside(const point &) const
Determine inside/outside status.
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.
label findCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find cell containing location.
const indexedOctree< treeDataCell > & cellTree() const
Get (demand driven) reference to octree holding all cells.
static scalar tol_
Tolerance on linear dimensions.
label findNearestCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find nearest cell in terms of cell centre.
const polyMesh & mesh() const
void clearOut()
Delete all storage.
meshSearch(const polyMesh &mesh, const polyMesh::cellDecomposition=polyMesh::CELL_TETS)
Construct from components. Constructs bb slightly bigger than.
Mesh consisting of general polyhedral cells.
cellDecomposition
Enumeration defining the decomposition of the cell for.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Cell-face mesh analysis engine.
virtual const faceList & faces() const =0
Return faces.
const vectorField & faceAreas() const
Standard boundBox + extra functionality for use in octree.
treeBoundBox extend(const scalar s) const
Return asymmetrically extended bounding box, with guaranteed.
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
findIntersectOp(const indexedOctree< treeDataFace > &tree)
Encapsulation of data needed to search for faces.
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
scalar minDist(const List< pointIndexHit > &hitList)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
defineTypeNameAndDebug(combustionModel, 0)
PointHit< point > pointHit
Field< vector > vectorField
Specialisation of Field<T> for vector.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
dimensioned< scalar > magSqr(const dimensioned< Type > &)