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()
127 bool Foam::meshSearch::findNearer
132 scalar& nearestDistSqr
139 scalar distSqr = sample.distSqr(
points[pointi]);
141 if (distSqr < nearestDistSqr)
143 nearestDistSqr = distSqr;
153 bool 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;
181 Foam::label Foam::meshSearch::findNearestCellTree(
const point& location)
const 183 const indexedOctree<treeDataCell>&
tree = cellTree();
195 Foam::label Foam::meshSearch::findNearestCellLinear(
const point& location)
const 199 label nearestIndex = 0;
200 scalar minProximity = location.distSqr(centres[nearestIndex]);
214 Foam::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],
250 Foam::label Foam::meshSearch::findNearestFaceTree(
const point& location)
const 253 const indexedOctree<treeDataCell>&
tree = cellTree();
267 const cell& ownFaces = mesh_.cells()[info.index()];
269 label nearestFacei = ownFaces[0];
270 scalar minProximity = location.distSqr(centres[nearestFacei]);
285 Foam::label Foam::meshSearch::findNearestFaceLinear(
const point& location)
const 289 label nearestFacei = 0;
290 scalar minProximity = location.distSqr(centres[nearestFacei]);
304 Foam::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;
361 Foam::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_))
389 Foam::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;
460 Foam::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();
540 Foam::meshSearch::meshSearch
547 cellDecompMode_(cellDecompMode)
561 Foam::meshSearch::meshSearch
569 cellDecompMode_(cellDecompMode)
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;
667 bndFaces.resize(bndi);
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
805 info = boundaryTree().findNearest
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);
856 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd);
861 curHit.
setIndex(boundaryTree().shapes().objectIndex(curHit.
index()));
879 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd, iop);
880 if (!curHit.
hit())
break;
883 curHit.
setIndex(boundaryTree().shapes().objectIndex(curHit.
index()));
902 boundaryTreePtr_.clear();
903 cellTreePtr_.clear();
904 overallBbPtr_.clear();
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
void reset(const label beg, const label end, const bool adjustStart) noexcept
Reset start and length, enforces non-negative size.
const indexedOctree< treeDataFace > & tree_
errorManipArg< error, int > exit(error &err, const int errNo=1)
const indexedOctree< treeDataCell > & cellTree() const
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.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Encapsulation of data for searching on faces.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
Cell-face mesh analysis engine.
static scalar tol_
Tolerance on linear dimensions.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A range or interval of labels defined by a start and a size.
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
const List< pointIndexHit > & hits_
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
scalar distance(const vector &p1, const vector &p2)
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
const polyMesh & mesh() const
cellDecomposition
Enumeration defining the decomposition of the cell for.
const indexedOctree< treeDataFace > & nonCoupledBoundaryTree() const
Demand-driven reference to octree holding all non-coupled boundary faces.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
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
Demand-driven reference to octree holding all boundary faces.
Tree tree(triangles.begin(), triangles.end())
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
A location inside the volume.
void append(const T &val)
Copy append an element to the end of this list.
label index() const noexcept
Return the hit index.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
defineTypeNameAndDebug(combustionModel, 0)
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
void setIndex(const label index) noexcept
Set the index.
void clearOut()
Delete all storage.
label findNearestBoundaryFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
Find nearest boundary face.
bool hit() const noexcept
Is there a hit?
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
scalar distance() const noexcept
Return distance to hit.
const polyBoundaryMesh & patches
Standard boundBox with extra functionality for use in octree.
Field< vector > vectorField
Specialisation of Field<T> for vector.
bool isInside(const point &) const
Determine inside/outside status.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.
A patch is a list of labels that address the faces in the global face list.
pointIndexHit intersection(const point &pStart, const point &pEnd) const
Find first intersection of boundary in segment [pStart, pEnd].
findIntersectOp(const indexedOctree< treeDataFace > &tree)
findUniqueIntersectOp(const indexedOctree< treeDataFace > &tree, const List< pointIndexHit > &hits)
Construct from components.
PointHit< point > pointHit
A PointHit with a 3D point.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())