Go to the documentation of this file.
51 scalar& nearestDistSqr
60 if (distSqr < nearestDistSqr)
62 nearestDistSqr = distSqr;
78 scalar& nearestDistSqr
85 label pointI = indices[i];
89 if (distSqr < nearestDistSqr)
91 nearestDistSqr = distSqr;
125 label nearestIndex = 0;
126 scalar minProximity =
magSqr(centres[nearestIndex] - location);
143 const point& location,
144 const label seedCellI
155 label curCellI = seedCellI;
156 scalar distanceSqr =
magSqr(mesh_.cellCentres()[curCellI] - location);
167 mesh_.cellCells()[curCellI],
199 const cell& ownFaces = mesh_.cells()[info.
index()];
201 label nearestFaceI = ownFaces[0];
202 scalar minProximity =
magSqr(centres[nearestFaceI] - location);
222 label nearestFaceI = 0;
223 scalar minProximity =
magSqr(centres[nearestFaceI] - location);
240 const point& location,
241 const label seedFaceI
255 label curFaceI = seedFaceI;
256 scalar distanceSqr =
magSqr(centres[curFaceI] - location);
260 label betterFaceI = curFaceI;
266 mesh_.cells()[mesh_.faceOwner()[curFaceI]],
271 if (mesh_.isInternalFace(curFaceI))
277 mesh_.cells()[mesh_.faceNeighbour()[curFaceI]],
283 if (betterFaceI == curFaceI)
288 curFaceI = betterFaceI;
297 bool cellFound =
false;
302 while ((!cellFound) && (
n < mesh_.nCells()))
304 if (mesh_.pointInCell(location,
n, cellDecompMode_))
328 const point& location,
329 const label seedCellI
338 if (mesh_.pointInCell(location, seedCellI, cellDecompMode_))
344 label curCellI = seedCellI;
345 scalar nearestDistSqr =
magSqr(mesh_.cellCentres()[curCellI] - location);
351 const cell& cFaces = mesh_.cells()[curCellI];
353 label nearestCellI = -1;
357 label faceI = cFaces[i];
359 if (mesh_.isInternalFace(faceI))
361 label cellI = mesh_.faceOwner()[faceI];
362 if (cellI == curCellI)
364 cellI = mesh_.faceNeighbour()[faceI];
368 if (mesh_.pointInCell(location, cellI, cellDecompMode_))
374 scalar distSqr =
magSqr(mesh_.cellCentres()[cellI] - location);
376 if (distSqr < nearestDistSqr)
378 nearestDistSqr = distSqr;
379 nearestCellI = cellI;
384 if (nearestCellI == -1)
390 curCellI = nearestCellI;
399 const point& location,
400 const label seedFaceI
411 label curFaceI = seedFaceI;
413 const face&
f = mesh_.faces()[curFaceI];
415 scalar minDist =
f.nearestPoint
430 label lastFaceI = curFaceI;
432 const labelList& myEdges = mesh_.faceEdges()[curFaceI];
436 const labelList& neighbours = mesh_.edgeFaces()[myEdges[myEdgeI]];
443 label faceI = neighbours[nI];
447 (faceI >= mesh_.nInternalFaces())
448 && (faceI != lastFaceI)
451 const face&
f = mesh_.faces()[faceI];
483 label ownerCellI = mesh_.faceOwner()[bFaceI];
485 const point&
c = mesh_.cellCentres()[ownerCellI];
488 scalar typDim =
mag(
c - bPoint);
490 return tol_*typDim*dir;
503 cellDecompMode_(cellDecompMode)
526 cellDecompMode_(cellDecompMode)
555 if (!boundaryTreePtr_.valid())
561 if (!overallBbPtr_.valid())
572 overallBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
573 overallBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
577 labelList bndFaces(mesh_.nFaces()-mesh_.nInternalFaces());
580 bndFaces[i] = mesh_.nInternalFaces() + i;
583 boundaryTreePtr_.reset
601 return boundaryTreePtr_();
608 if (!cellTreePtr_.valid())
614 if (!overallBbPtr_.valid())
625 overallBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
626 overallBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
647 return cellTreePtr_();
739 const point& location,
740 const label seedCellI,
741 const bool useTreeSearch
748 return findNearestCellTree(location);
752 return findNearestCellLinear(location);
757 return findNearestCellWalk(location, seedCellI);
764 const point& location,
765 const label seedFaceI,
766 const bool useTreeSearch
773 return findNearestFaceTree(location);
777 return findNearestFaceLinear(location);
782 return findNearestFaceWalk(location, seedFaceI);
789 const point& location,
790 const label seedCellI,
791 const bool useTreeSearch
799 return cellTree().findInside(location);
803 return findCellLinear(location);
808 return findCellWalk(location, seedCellI);
815 const point& location,
816 const label seedFaceI,
817 const bool useTreeSearch
834 info = boundaryTree().findNearest
845 scalar minDist = GREAT;
851 label faceI = mesh_.nInternalFaces();
852 faceI < mesh_.nFaces();
856 const face&
f = mesh_.faces()[faceI];
876 return findNearestBoundaryFaceWalk(location, seedFaceI);
887 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd);
892 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
906 vector edgeVec = pEnd - pStart;
907 edgeVec /=
mag(edgeVec);
920 const vector& area = mesh_.faceAreas()[bHit.
index()];
937 }
while (bHit.
hit());
955 boundaryTreePtr_.clear();
956 cellTreePtr_.clear();
957 overallBbPtr_.clear();
Simple random number generator.
label index() const
Return index.
cellDecomposition
Enumeration defining the decomposition of the cell for.
void setIndex(const label index)
const point & max() const
Maximum describing the bounding box.
label findNearestFaceLinear(const point &) const
#define forAll(list, i)
Loop across all elements in list.
This class describes the interaction of a face and a point. It carries the info of a successful hit a...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
Template functions to aid in the implementation of demand driven data.
Standard boundBox + extra functionality for use in octree.
bool hit() const
Is there a hit.
const Type & shapes() const
Reference to shape.
label findNearestBoundaryFace(const point &location, const label seedFaceI=-1, const bool useTreeSearch=true) const
Find nearest boundary face.
static bool findNearer(const point &sample, const pointField &points, label &nearestI, scalar &nearestDistSqr)
Updates nearestI, nearestDistSqr from any closer ones.
dimensioned< scalar > mag(const dimensioned< Type > &)
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.
label findCellWalk(const point &, const label) const
Walk from seed. Does not 'go around' boundary, just returns.
Mesh consisting of general polyhedral cells.
const indexedOctree< treeDataCell > & cellTree() const
Get (demand driven) reference to octree holding all cells.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
void clearOut()
Delete all storage.
void correct()
Correct for mesh geom/topo changes.
scalar distance() const
Return distance to hit.
label findNearestFace(const point &location, const label seedFaceI=-1, const bool useTreeSearch=true) const
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
label findCellLinear(const point &) const
Cell containing location. Linear search.
label findNearestCellWalk(const point &, const label) const
Walk from seed. Does not 'go around' boundary, just returns.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
const Point & hitPoint() const
Return hit point.
Non-pointer based hierarchical recursive searching.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
const point & min() const
Minimum describing the bounding box.
label findNearestBoundaryFaceWalk(const point &location, const label seedFaceI) const
Walk from seed to find nearest boundary face. Gets stuck in.
label findNearestCell(const point &location, const label seedCellI=-1, const bool useTreeSearch=true) const
Find nearest cell in terms of cell centre.
bool isInside(const point &) const
Determine inside/outside status.
vector offset(const point &bPoint, const label bFaceI, const vector &dir) const
Calculate offset vector in direction dir with as length a.
const double e
Elementary charge.
label findNearestFaceTree(const point &) const
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const treeBoundBox & bb() const
Top bounding box.
label findNearestCellLinear(const point &) const
Nearest cell centre going through all cells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensionedScalar sqrt(const dimensionedScalar &ds)
label findCell(const point &location, const label seedCellI=-1, const bool useTreeSearch=true) const
Find cell containing location.
Encapsulation of data needed to search for faces.
const dimensionedScalar c
Speed of light in a vacuum.
void findNearest(const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint, const FindNearestOp &fnOp) const
Find nearest point to line.
A face is a list of labels corresponding to mesh vertices.
vector point
Point is a vector.
meshSearch(const meshSearch &)
Disallow default bitwise copy construct.
label findNearestFaceWalk(const point &, const label) const
pointIndexHit intersection(const point &pStart, const point &pEnd) const
Find first intersection of boundary in segment [pStart, pEnd].
defineTypeNameAndDebug(combustionModel, 0)
A cell is defined as a list of faces with extra functionality.
const indexedOctree< treeDataFace > & boundaryTree() const
Get (demand driven) reference to octree holding all.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
cachedRandom rndGen(label(0), -1)
label findNearestCellTree(const point &) const
Nearest cell centre using octree.
static scalar tol_
Tolerance on linear dimensions.