36 scalar treeDataFace::tolSqr =
sqr(1
e-6);
46 const face& f = mesh_.faces()[faceI];
48 treeBoundBox bb(points[f[0]], points[f[0]]);
50 for (
label fp = 1; fp < f.size(); fp++)
52 const point& p = points[f[fp]];
55 bb.max() =
max(bb.max(),
p);
61 void Foam::treeDataFace::update()
65 isTreeFace_.set(faceLabels_[i], 1);
70 bbs_.setSize(faceLabels_.size());
74 bbs_[i] = calcBb(faceLabels_[i]);
90 faceLabels_(faceLabels),
91 isTreeFace_(mesh.
nFaces(), 0),
106 faceLabels_(faceLabels),
107 isTreeFace_(mesh.
nFaces(), 0),
121 faceLabels_(
identity(mesh_.nFaces())),
122 isTreeFace_(mesh.
nFaces(), 0),
141 isTreeFace_(mesh_.nFaces(), 0),
174 cc[i] = mesh_.faceCentres()[faceLabels_[i]];
203 if (info.
index() == -1)
207 "treeDataFace::getSampleType" 208 "(indexedOctree<treeDataFace>&, const point&)" 209 ) <<
"Could not find " << sample <<
" in octree." 219 Pout<<
"getSampleType : sample:" << sample
220 <<
" nearest face:" << faceI;
228 const face& f = mesh_.faces()[faceI];
229 const vector& area = mesh_.faceAreas()[faceI];
230 const point& fc = mesh_.faceCentres()[faceI];
245 Pout<<
" -> face hit:" << curPt
246 <<
" comparing to face normal " << area <<
endl;
253 Pout<<
" -> face miss:" << curPt;
261 const scalar typDimSqr =
mag(area) + VSMALL;
265 if ((
magSqr(points[f[fp]] - curPt)/typDimSqr) < tolSqr)
277 if (isTreeFace_.get(pFaces[i]) == 1)
279 vector n = mesh_.faceAreas()[pFaces[i]];
280 n /=
mag(n) + VSMALL;
288 Pout<<
" -> face point hit :" << points[f[fp]]
289 <<
" point normal:" << pointNormal
291 <<
magSqr(points[f[fp]] - curPt)/typDimSqr <<
endl;
300 if ((
magSqr(fc - curPt)/typDimSqr) < tolSqr)
307 Pout<<
" -> centre hit:" << fc
308 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
320 const labelList& myEdges = mesh_.faceEdges()[faceI];
324 const edge&
e = mesh_.edges()[myEdges[myEdgeI]];
331 ).nearestDist(sample);
340 const labelList& eFaces = mesh_.edgeFaces()[myEdges[myEdgeI]];
346 if (isTreeFace_.get(eFaces[i]) == 1)
348 vector n = mesh_.faceAreas()[eFaces[i]];
349 n /=
mag(n) + VSMALL;
358 <<
" comparing to edge normal:" << edgeNormal
383 ).nearestDist(sample);
391 vector ePrev = points[f[f.rcIndex(fp)]] - fc;
392 vector eNext = points[f[f.fcIndex(fp)]] - fc;
395 nLeft /=
mag(nLeft) + VSMALL;
397 vector nRight = e ^ eNext;
398 nRight /=
mag(nRight) + VSMALL;
402 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
403 <<
" comparing to edge normal " 404 << 0.5*(nLeft + nRight)
412 0.5*(nLeft + nRight),
420 Pout<<
"Did not find sample " << sample
421 <<
" anywhere related to nearest face " << faceI <<
endl 426 Pout<<
" vertex:" << f[fp] <<
" coord:" << points[f[fp]]
457 if (!cubeBb.
overlaps(calcBb(faceLabels_[index])))
467 label faceI = faceLabels_[index];
469 const face& f = mesh_.faces()[faceI];
477 const point& fc = mesh_.faceCentres()[faceI];
498 void Foam::treeDataFace::findNearestOp::operator()
503 scalar& nearestDistSqr,
512 const label index = indices[i];
519 if (distSqr < nearestDistSqr)
521 nearestDistSqr = distSqr;
529 void Foam::treeDataFace::findNearestOp::operator()
542 "treeDataFace::findNearestOp::operator()" 544 " const labelUList&," 545 " const linePointRef&," 555 bool Foam::treeDataFace::findIntersectOp::operator()
560 point& intersectionPoint
577 const label faceI = shape.faceLabels_[index];
579 const vector dir(end - start);
594 intersectionPoint = inter.
hitPoint();
const Point & rawPoint() const
Return point with no checking.
virtual const pointField & points() const =0
Return mesh points.
treeDataFace(const bool cacheBb, const primitiveMesh &, const labelUList &)
Construct from mesh and subset of faces.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
findIntersectOp(const indexedOctree< treeDataFace > &tree)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
pointField shapePoints() const
Get representative point cloud for all shapes inside.
const Point & hitPoint() const
Return hit point.
A simple container for copying or transferring objects of type <T>.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool containsAny(const UList< point > &) const
Contains any of the points? (inside or on edge)
Standard boundBox + extra functionality for use in octree.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
virtual const faceList & faces() const =0
Return faces.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Encapsulation of data needed to search for faces.
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...
label index() const
Return index.
vectorField pointField
pointField is a vectorField.
A patch is a list of labels that address the faces in the global face list.
A face is a list of labels corresponding to mesh vertices.
Cell-face mesh analysis engine.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const labelList & faceLabels() const
findNearestOp(const indexedOctree< treeDataFace > &tree)
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
errorManip< error > abort(error &err)
direction posBits(const point &) const
Position of point relative to bounding box.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Non-pointer based hierarchical recursive searching.
scalar distance() const
Return distance to hit.
label start() const
Return start label of this patch in the polyMesh face list.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
pointHit nearestPoint(const point &p, const pointField &) const
Return nearest point to face.
const polyMesh & mesh() const
Return the mesh reference.
label end() const
Return end vertex label.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool hit() const
Is there a hit.
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Does triangle intersect bounding box.
label start() const
Return start vertex label.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints,-1);const cellModel &hex=*(cellModeller::lookup("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]
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
bool overlaps(const boundBox &) const
Overlaps/touches boundingBox?
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
const primitiveMesh & mesh() const
const vectorField & faceCentres() const