Go to the documentation of this file.
39 scalar treeDataFace::tolSqr =
sqr(1
e-6);
47 return treeBoundBox(mesh_.
points(), mesh_.
faces()[facei]);
51 void Foam::treeDataFace::update()
53 isTreeFace_.set(faceLabels_);
57 bbs_.setSize(faceLabels_.size());
61 bbs_[i] = calcBb(faceLabels_[i]);
77 faceLabels_(faceLabels),
93 faceLabels_(std::move(faceLabels)),
108 faceLabels_(
identity(mesh_.nFaces())),
122 mesh_(
patch.boundaryMesh().mesh()),
124 isTreeFace_(mesh_.nFaces(),
false),
157 cc[i] = mesh_.faceCentres()[faceLabels_[i]];
184 if (info.
index() == -1)
187 <<
"Could not find " <<
sample <<
" in octree."
193 label facei = faceLabels_[info.
index()];
198 <<
" nearest face:" << facei;
206 const face&
f = mesh_.faces()[facei];
207 const vector&
area = mesh_.faceAreas()[facei];
208 const point& fc = mesh_.faceCentres()[facei];
223 Pout<<
" -> face hit:" << curPt
224 <<
" comparing to face normal " <<
area <<
endl;
231 Pout<<
" -> face miss:" << curPt;
239 const scalar typDimSqr =
mag(
area) + VSMALL;
253 for (
const label facei :
pFaces)
255 if (isTreeFace_.test(facei))
257 pointNormal +=
normalised(mesh_.faceAreas()[facei]);
264 <<
" point normal:" << pointNormal
275 if ((
magSqr(fc - curPt)/typDimSqr) < tolSqr)
282 Pout<<
" -> centre hit:" << fc
283 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
295 const labelList& myEdges = mesh_.faceEdges()[facei];
299 const edge&
e = mesh_.edges()[myEdges[myEdgeI]];
315 const labelList& eFaces = mesh_.edgeFaces()[myEdges[myEdgeI]];
319 for (
const label facei : eFaces)
321 if (isTreeFace_.test(facei))
323 edgeNormal +=
normalised(mesh_.faceAreas()[facei]);
330 <<
" comparing to edge normal:" << edgeNormal
371 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
372 <<
" comparing to edge normal "
373 << 0.5*(nLeft + nRight)
381 0.5*(nLeft + nRight),
390 <<
" anywhere related to nearest face " << facei <<
endl
395 Pout<<
" vertex:" <<
f[fp] <<
" coord:" <<
points[
f[fp]]
426 if (!cubeBb.
overlaps(calcBb(faceLabels_[index])))
436 label facei = faceLabels_[index];
438 const face&
f = mesh_.faces()[facei];
446 const point& fc = mesh_.faceCentres()[facei];
468 void Foam::treeDataFace::findNearestOp::operator()
473 scalar& nearestDistSqr,
480 for (
const label index : indices)
487 if (distSqr < nearestDistSqr)
489 nearestDistSqr = distSqr;
497 void Foam::treeDataFace::findNearestOp::operator()
512 bool Foam::treeDataFace::findIntersectOp::operator()
517 point& intersectionPoint
534 const label facei = shape.faceLabels_[index];
551 intersectionPoint = inter.
hitPoint();
int debug
Static debugging option.
bool overlaps(const boundBox &bb) const
Overlaps other bounding box?
virtual const pointField & points() const =0
Return mesh points.
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
static constexpr const zero Zero
Global zero (0)
virtual const faceList & faces() const =0
Return faces.
bool containsAny(const UList< point > &points) const
Contains any of the points? (inside or on edge)
Standard boundBox with extra functionality for use in octree.
volumeType getVolumeType(const indexedOctree< treeDataFace > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
scalar distance() const noexcept
Return distance to hit.
const point_type & hitPoint() const
Return the hit point. Fatal if not hit.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelList & faceLabels() const
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const primitiveMesh & mesh() const
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Intersect triangle with bounding box.
direction posBits(const point &pt) const
Position of point relative to bounding box.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
An enumeration wrapper for classification of a location as being inside/outside of a volume.
A patch is a list of labels that address the faces in the global face list.
const point_type & rawPoint() const noexcept
The point, no checks.
Non-pointer based hierarchical recursive searching.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
errorManip< error > abort(error &err)
VectorSpace< Form, Cmpt, Ncmpts > normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
pointField shapePoints() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
const std::string patch
OpenFOAM patch number as a std::string.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
label index() const noexcept
Return the hit index.
Encapsulation of data needed to search for faces.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const vectorField & faceCentres() const
const dimensionedScalar e
Elementary charge.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
const wordList area
Standard area field types (scalar, vector, tensor, etc)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
label nFaces() const noexcept
Number of mesh faces.
A face is a list of labels corresponding to mesh vertices.
findNearestOp(const indexedOctree< treeDataFace > &tree)
treeDataFace(const bool cacheBb, const primitiveMesh &mesh, const labelUList &faceLabels)
Construct from mesh, copying subset of faces.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
defineTypeNameAndDebug(combustionModel, 0)
bool hit() const noexcept
Is there a hit.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
findIntersectOp(const indexedOctree< treeDataFace > &tree)
Minimal example by using system/controlDict.functions:
Cell-face mesh analysis engine.