36 scalar treeDataFace::tolSqr =
sqr(1
e-6);
46 const face&
f = mesh_.
faces()[facei];
50 for (
label fp = 1; fp <
f.size(); fp++)
54 bb.min() =
min(bb.min(),
p);
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),
122 isTreeFace_(mesh.nFaces(), 0),
135 mesh_(patch.boundaryMesh().mesh()),
141 isTreeFace_(mesh_.nFaces(), 0),
201 if (info.
index() == -1)
204 <<
"Could not find " << sample <<
" in octree."
214 Pout<<
"getSampleType : sample:" << sample
215 <<
" nearest face:" << facei;
240 Pout<<
" -> face hit:" << curPt
241 <<
" comparing to face normal " << area <<
endl;
248 Pout<<
" -> face miss:" << curPt;
256 const scalar typDimSqr =
mag(area) + vSmall;
275 n /=
mag(
n) + vSmall;
284 <<
" point normal:" << pointNormal
295 if ((
magSqr(fc - curPt)/typDimSqr) < tolSqr)
302 Pout<<
" -> centre hit:" << fc
303 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
319 const edge&
e = mesh_.
edges()[myEdges[myEdgeI]];
341 if (isTreeFace_.
get(eFaces[i]) == 1)
344 n /=
mag(
n) + vSmall;
353 <<
" comparing to edge normal:" << edgeNormal
390 nLeft /=
mag(nLeft) + vSmall;
393 nRight /=
mag(nRight) + vSmall;
397 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
398 <<
" comparing to edge normal "
399 << 0.5*(nLeft + nRight)
407 0.5*(nLeft + nRight),
415 Pout<<
"Did not find sample " << sample
416 <<
" anywhere related to nearest face " << facei <<
endl
421 Pout<<
" vertex:" <<
f[fp] <<
" coord:" <<
points[
f[fp]]
452 if (!cubeBb.
overlaps(calcBb(faceLabels_[index])))
462 label facei = faceLabels_[index];
493 void Foam::treeDataFace::findNearestOp::operator()
498 scalar& nearestDistSqr,
507 const label index = indices[i];
514 if (distSqr < nearestDistSqr)
516 nearestDistSqr = distSqr;
524 void Foam::treeDataFace::findNearestOp::operator()
539 bool Foam::treeDataFace::findIntersectOp::operator()
544 point& intersectionPoint
561 const label facei = shape.faceLabels_[index];
563 const vector dir(end - start);
578 intersectionPoint = inter.
hitPoint();
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
unsigned int get(const label) const
Get value at index I.
const Point & hitPoint() const
Return hit point.
scalar distance() const
Return distance to hit.
const Point & rawPoint() const
Return point with no checking.
bool hit() const
Is there a hit.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
label index() const
Return index.
bool containsAny(const UList< point > &) const
Contains any of the points? (inside or on edge)
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A face is a list of labels corresponding to mesh vertices.
Non-pointer based hierarchical recursive searching.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
A patch is a list of labels that address the faces in the global face list.
Cell-face mesh analysis engine.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
virtual const faceList & faces() const =0
Return faces.
const labelListList & pointFaces() const
virtual const pointField & points() const =0
Return mesh points.
const labelListList & edgeFaces() const
const labelListList & faceEdges() const
const vectorField & faceAreas() const
Standard boundBox + extra functionality for use in octree.
bool overlaps(const boundBox &) const
Overlaps other bounding box?
direction posBits(const point &) const
Position of point relative to bounding box.
findIntersectOp(const indexedOctree< treeDataFace > &tree)
findNearestOp(const indexedOctree< treeDataFace > &tree)
Encapsulation of data needed to search for faces.
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
treeDataFace(const bool cacheBb, const primitiveMesh &, const labelUList &)
Construct from mesh and subset of faces.
const labelList & faceLabels() const
const primitiveMesh & mesh() const
volumeType getVolumeType(const indexedOctree< treeDataFace > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
pointField shapePoints() const
Get representative point cloud for all shapes inside.
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Does triangle intersect bounding box.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
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, &mergedCyclicPolyPatch::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]