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()),
127 isTreeFace_(mesh_.nFaces(),
false),
160 cc[i] = mesh_.faceCentres()[faceLabels_[i]];
187 if (info.
index() == -1)
190 <<
"Could not find " << sample <<
" in octree."
196 label facei = faceLabels_[info.
index()];
200 Pout<<
"getSampleType : sample:" << sample
201 <<
" nearest face:" << facei;
209 const face&
f = mesh_.faces()[facei];
210 const vector&
area = mesh_.faceAreas()[facei];
211 const point& fc = mesh_.faceCentres()[facei];
226 Pout<<
" -> face hit:" << curPt
227 <<
" comparing to face normal " <<
area <<
endl;
234 Pout<<
" -> face miss:" << curPt;
242 const scalar typDimSqr =
mag(
area) + VSMALL;
256 for (
const label facei :
pFaces)
258 if (isTreeFace_.test(facei))
260 pointNormal +=
normalised(mesh_.faceAreas()[facei]);
267 <<
" point normal:" << pointNormal
278 if ((
magSqr(fc - curPt)/typDimSqr) < tolSqr)
285 Pout<<
" -> centre hit:" << fc
286 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
298 const labelList& myEdges = mesh_.faceEdges()[facei];
302 const edge&
e = mesh_.edges()[myEdges[myEdgeI]];
309 ).nearestDist(sample);
318 const labelList& eFaces = mesh_.edgeFaces()[myEdges[myEdgeI]];
322 for (
const label facei : eFaces)
324 if (isTreeFace_.test(facei))
326 edgeNormal +=
normalised(mesh_.faceAreas()[facei]);
333 <<
" comparing to edge normal:" << edgeNormal
374 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
375 <<
" comparing to edge normal "
376 << 0.5*(nLeft + nRight)
384 0.5*(nLeft + nRight),
392 Pout<<
"Did not find sample " << sample
393 <<
" anywhere related to nearest face " << facei <<
endl
398 Pout<<
" vertex:" <<
f[fp] <<
" coord:" <<
points[
f[fp]]
429 if (!cubeBb.
overlaps(calcBb(faceLabels_[index])))
439 label facei = faceLabels_[index];
441 const face&
f = mesh_.faces()[facei];
449 const point& fc = mesh_.faceCentres()[facei];
471 void Foam::treeDataFace::findNearestOp::operator()
476 scalar& nearestDistSqr,
483 for (
const label index : indices)
490 if (distSqr < nearestDistSqr)
492 nearestDistSqr = distSqr;
500 void Foam::treeDataFace::findNearestOp::operator()
515 bool Foam::treeDataFace::findIntersectOp::operator()
520 point& intersectionPoint
537 const label facei = shape.faceLabels_[index];
554 intersectionPoint = inter.
hitPoint();
int debug
Static debugging option.
bool overlaps(const boundBox &bb) const
Overlaps other bounding box?
label index() const
Return index.
bool hit() const
Is there a hit.
virtual const pointField & points() const =0
Return mesh points.
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)
label nFaces() const
Number of mesh faces.
const Point & rawPoint() const
Return point with no checking.
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...
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelList & faceLabels() const
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
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)
Does triangle intersect 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...
scalar distance() const
Return distance to hit.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
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]=cellShape(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]
A patch is a list of labels that address the faces in the global face list.
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.
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.
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)
const Point & hitPoint() const
Return hit point.
findIntersectOp(const indexedOctree< treeDataFace > &tree)
Cell-face mesh analysis engine.