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);
90 const label oldFacei = hits_[hiti].index();
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
137 scalar distSqr =
magSqr(points[pointi] - sample);
139 if (distSqr < nearestDistSqr)
141 nearestDistSqr = distSqr;
151 bool Foam::meshSearch::findNearer
157 scalar& nearestDistSqr
164 label pointi = indices[i];
166 scalar distSqr =
magSqr(points[pointi] - sample);
168 if (distSqr < nearestDistSqr)
170 nearestDistSqr = distSqr;
181 Foam::label Foam::meshSearch::findNearestCellTree(
const point& location)
const 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 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];
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const indexedOctree< treeDataFace > & tree_
meshSearch(const polyMesh &mesh, const polyMesh::cellDecomposition=polyMesh::CELL_TETS)
Construct from components. Constructs bb slightly bigger than.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const indexedOctree< treeDataCell > & cellTree() const
Get (demand driven) reference to octree holding all cells.
A face is a list of labels corresponding to mesh vertices.
label findNearestCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find nearest cell in terms of cell centre.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Encapsulation of data needed to search for faces.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Cell-face mesh analysis engine.
static scalar tol_
Tolerance on linear dimensions.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
const List< pointIndexHit > & hits_
void setIndex(const label index)
scalar distance(const vector &p1, const vector &p2)
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
cellDecomposition
Enumeration defining the decomposition of the cell for.
scalar minDist(const List< pointIndexHit > &hitList)
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
void correct()
Correct for mesh geom/topo changes.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
label findCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find cell containing location.
const indexedOctree< treeDataFace > & boundaryTree() const
Get (demand driven) reference to octree holding all.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool hit() const
Is there a hit.
const Type & shapes() const
Reference to shape.
const treeBoundBox & bb() const
Top bounding box.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
defineTypeNameAndDebug(combustionModel, 0)
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
void clearOut()
Delete all storage.
label findNearestBoundaryFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
Find nearest boundary face.
Template functions to aid in the implementation of demand driven data.
Non-pointer based hierarchical recursive searching.
pointHit nearestPoint(const point &p, const pointField &) const
Return nearest point to face.
A cell is defined as a list of faces with extra functionality.
const vectorField & faceAreas() const
virtual const faceList & faces() const =0
Return faces.
Standard boundBox + extra functionality for use in octree.
bool isInside(const point &) const
Determine inside/outside status.
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
scalar distance() const
Return distance to hit.
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.
pointIndexHit intersection(const point &pStart, const point &pEnd) const
Find first intersection of boundary in segment [pStart, pEnd].
label index() const
Return index.
findUniqueIntersectOp(const indexedOctree< treeDataFace > &tree, const List< pointIndexHit > &hits)
Construct from components.
treeBoundBox extend(const scalar s) const
Return asymetrically extended bounding box, with guaranteed.