77 point& intersectionPoint
87 const label newFacei =
tree_.shapes().objectIndex(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()
127bool Foam::meshSearch::findNearer
132 scalar& nearestDistSqr
139 scalar distSqr = sample.distSqr(
points[pointi]);
141 if (distSqr < nearestDistSqr)
143 nearestDistSqr = distSqr;
153bool Foam::meshSearch::findNearer
159 scalar& nearestDistSqr
164 for (
const label pointi : indices)
166 scalar distSqr = sample.distSqr(
points[pointi]);
168 if (distSqr < nearestDistSqr)
170 nearestDistSqr = distSqr;
181Foam::label Foam::meshSearch::findNearestCellTree(
const point& location)
const
195Foam::label Foam::meshSearch::findNearestCellLinear(
const point& location)
const
199 label nearestIndex = 0;
200 scalar minProximity = location.distSqr(centres[nearestIndex]);
214Foam::label Foam::meshSearch::findNearestCellWalk
216 const point& location,
217 const label seedCelli
228 label curCelli = seedCelli;
229 scalar distanceSqr = location.distSqr(mesh_.cellCentres()[curCelli]);
240 mesh_.cellCells()[curCelli],
250Foam::label Foam::meshSearch::findNearestFaceTree(
const point& location)
const
267 const cell& ownFaces = mesh_.cells()[info.index()];
269 label nearestFacei = ownFaces[0];
270 scalar minProximity = location.distSqr(centres[nearestFacei]);
285Foam::label Foam::meshSearch::findNearestFaceLinear(
const point& location)
const
289 label nearestFacei = 0;
290 scalar minProximity = location.distSqr(centres[nearestFacei]);
304Foam::label Foam::meshSearch::findNearestFaceWalk
306 const point& location,
307 const label seedFacei
321 label curFacei = seedFacei;
322 scalar distanceSqr = location.distSqr(centres[curFacei]);
326 label betterFacei = curFacei;
332 mesh_.cells()[mesh_.faceOwner()[curFacei]],
337 if (mesh_.isInternalFace(curFacei))
343 mesh_.cells()[mesh_.faceNeighbour()[curFacei]],
349 if (betterFacei == curFacei)
354 curFacei = betterFacei;
361Foam::label Foam::meshSearch::findCellLinear(
const point& location)
const
363 bool cellFound =
false;
368 while ((!cellFound) && (
n < mesh_.nCells()))
370 if (mesh_.pointInCell(location,
n, cellDecompMode_))
389Foam::label Foam::meshSearch::findCellWalk
391 const point& location,
392 const label seedCelli
401 if (mesh_.pointInCell(location, seedCelli, cellDecompMode_))
407 label curCelli = seedCelli;
408 scalar nearestDistSqr = location.distSqr(mesh_.cellCentres()[curCelli]);
414 const cell& cFaces = mesh_.cells()[curCelli];
416 label nearestCelli = -1;
420 label facei = cFaces[i];
422 if (mesh_.isInternalFace(facei))
424 label celli = mesh_.faceOwner()[facei];
425 if (celli == curCelli)
427 celli = mesh_.faceNeighbour()[facei];
431 if (mesh_.pointInCell(location, celli, cellDecompMode_))
437 scalar distSqr = location.distSqr(mesh_.cellCentres()[celli]);
439 if (distSqr < nearestDistSqr)
441 nearestDistSqr = distSqr;
442 nearestCelli = celli;
447 if (nearestCelli == -1)
453 curCelli = nearestCelli;
460Foam::label Foam::meshSearch::findNearestBoundaryFaceWalk
462 const point& location,
463 const label seedFacei
474 label curFacei = seedFacei;
476 const face&
f = mesh_.faces()[curFacei];
478 scalar minDist =
f.nearestPoint
493 label lastFacei = curFacei;
495 const labelList& myEdges = mesh_.faceEdges()[curFacei];
499 const labelList& neighbours = mesh_.edgeFaces()[myEdges[myEdgeI]];
506 label facei = neighbours[nI];
510 (facei >= mesh_.nInternalFaces())
511 && (facei != lastFacei)
514 const face&
f = mesh_.faces()[facei];
523 if (curHit.distance() < minDist)
525 minDist = curHit.distance();
540Foam::meshSearch::meshSearch
547 cellDecompMode_(cellDecompMode)
556 (void)
mesh.tetBasePtIs();
561Foam::meshSearch::meshSearch
569 cellDecompMode_(cellDecompMode)
580 (void)
mesh.tetBasePtIs();
611 return *overallBbPtr_;
618 if (!boundaryTreePtr_)
623 mesh_.nInternalFaces(),
624 mesh_.nBoundaryFaces()
627 boundaryTreePtr_.reset
641 return *boundaryTreePtr_;
649 if (!nonCoupledBoundaryTreePtr_)
654 labelList bndFaces(mesh_.nBoundaryFaces());
663 bndFaces[bndi++] =
pp.start()+i;
669 nonCoupledBoundaryTreePtr_.reset
683 return *nonCoupledBoundaryTreePtr_;
710 return *cellTreePtr_;
716 const point& location,
717 const label seedCelli,
718 const bool useTreeSearch
725 return findNearestCellTree(location);
729 return findNearestCellLinear(location);
733 return findNearestCellWalk(location, seedCelli);
739 const point& location,
740 const label seedFacei,
741 const bool useTreeSearch
748 return findNearestFaceTree(location);
752 return findNearestFaceLinear(location);
756 return findNearestFaceWalk(location, seedFacei);
762 const point& location,
763 const label seedCelli,
764 const bool useTreeSearch
772 return cellTree().findInside(location);
776 return findCellLinear(location);
780 return findCellWalk(location, seedCelli);
786 const point& location,
787 const label seedFacei,
788 const bool useTreeSearch
812 return tree.shapes().objectIndex(info.
index());
816 scalar minDist = GREAT;
822 label facei = mesh_.nInternalFaces();
823 facei < mesh_.nFaces();
827 const face&
f = mesh_.faces()[facei];
846 return findNearestBoundaryFaceWalk(location, seedFacei);
880 if (!curHit.
hit())
break;
902 boundaryTreePtr_.clear();
903 cellTreePtr_.clear();
904 overallBbPtr_.clear();
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
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 resize(const label len)
Adjust allocated size of list.
scalar distance() const noexcept
Return distance to hit.
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?
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
A cell is defined as a list of faces with extra functionality.
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.
A range or interval of labels defined by a start and a size.
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
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
Demand-driven reference to octree holding all non-coupled boundary faces.
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 registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
cellDecomposition
Enumeration defining the decomposition of the cell for.
A patch is a list of labels that address the faces in the global face list.
Cell-face mesh analysis engine.
Standard boundBox with extra functionality for use in octree.
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 for searching on 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.
PointHit< point > pointHit
A PointHit with a 3D point.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Tree tree(triangles.begin(), triangles.end())
#define forAll(list, i)
Loop across all elements in list.