77 point& intersectionPoint
87 const label newFacei =
tree_.shapes().faceLabels()[index];
89 const scalar newDot =
mesh.
faceAreas()[newFacei] & (end - start);
92 const label oldFacei =
hits_[hiti].index();
99 hits_[hiti].index() == newFacei
127bool Foam::meshSearch::findNearer
132 scalar& nearestDistSqr
141 if (distSqr < nearestDistSqr)
143 nearestDistSqr = distSqr;
153bool Foam::meshSearch::findNearer
159 scalar& nearestDistSqr
166 label pointi = indices[i];
170 if (distSqr < nearestDistSqr)
172 nearestDistSqr = distSqr;
183Foam::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));
201Foam::label Foam::meshSearch::findNearestCellLinear(
const point& location)
const
205 label nearestIndex = 0;
206 scalar minProximity =
magSqr(centres[nearestIndex] - location);
220Foam::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],
256Foam::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);
295Foam::label Foam::meshSearch::findNearestFaceLinear(
const point& location)
const
299 label nearestFacei = 0;
300 scalar minProximity =
magSqr(centres[nearestFacei] - location);
314Foam::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;
371Foam::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_))
399Foam::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;
470Foam::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();
557 cellDecompMode_(cellDecompMode)
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;
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();
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void append(const T &val)
Copy append an element to the end of this list.
Minimal example by using system/controlDict.functions:
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label n)
Alias for resize()
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
scalar distance() const noexcept
Return distance to hit.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
void setIndex(const label index) noexcept
Set the index.
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum describing the bounding box.
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
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 treeBoundBox & bb() const
Top bounding box.
const Type & shapes() const
Reference to shape.
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.
const indexedOctree< treeDataFace > & boundaryTree() const
Demand-driven reference to octree holding all boundary faces.
const polyMesh & mesh() const
void correct()
Correct for mesh geom/topo changes.
bool isInside(const point &) const
Determine inside/outside status.
const indexedOctree< treeDataFace > & nonCoupledBoundaryTree() const
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
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.
void clearOut()
Delete all storage.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
cellDecomposition
Enumeration defining the decomposition of the cell for.
virtual const faceList & faces() const
Return raw faces.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
A patch is a list of labels that address the faces in the global face list.
Cell-face mesh analysis engine.
const vectorField & faceAreas() const
Standard boundBox with extra functionality for use in octree.
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
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.
@ INSIDE
A location inside the volume.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
PointHit< point > pointHit
A PointIndexHit for 3D points.
Field< vector > vectorField
Specialisation of Field<T> for vector.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
#define forAll(list, i)
Loop across all elements in list.