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),
136 faceLabels_(
identityMap(patch.start(), patch.size())),
137 isTreeFace_(mesh_.nFaces(), 0),
197 if (info.
index() == -1)
200 <<
"Could not find " << sample <<
" in octree."
210 Pout<<
"getSampleType : sample:" << sample
211 <<
" nearest face:" << facei;
236 Pout<<
" -> face hit:" << curPt
237 <<
" comparing to face normal " <<
area <<
endl;
244 Pout<<
" -> face miss:" << curPt;
252 const scalar typDimSqr =
mag(
area) + vSmall;
271 n /=
mag(
n) + vSmall;
280 <<
" point normal:" << pointNormal
291 if ((
magSqr(fc - curPt)/typDimSqr) < tolSqr)
298 Pout<<
" -> centre hit:" << fc
299 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
315 const edge&
e = mesh_.
edges()[myEdges[myEdgeI]];
337 if (isTreeFace_.
get(eFaces[i]) == 1)
340 n /=
mag(
n) + vSmall;
349 <<
" comparing to edge normal:" << edgeNormal
386 nLeft /=
mag(nLeft) + vSmall;
389 nRight /=
mag(nRight) + vSmall;
393 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
394 <<
" comparing to edge normal "
395 << 0.5*(nLeft + nRight)
403 0.5*(nLeft + nRight),
411 Pout<<
"Did not find sample " << sample
412 <<
" anywhere related to nearest face " << facei <<
endl
417 Pout<<
" vertex:" <<
f[fp] <<
" coord:" <<
points[
f[fp]]
448 if (!cubeBb.
overlaps(calcBb(faceLabels_[index])))
458 label facei = faceLabels_[index];
489 void Foam::treeDataFace::findNearestOp::operator()
494 scalar& nearestDistSqr,
503 const label index = indices[i];
510 if (distSqr < nearestDistSqr)
512 nearestDistSqr = distSqr;
520 void Foam::treeDataFace::findNearestOp::operator()
535 bool Foam::treeDataFace::findIntersectOp::operator()
540 point& intersectionPoint
557 const label facei = shape.faceLabels_[index];
559 const vector dir(end - start);
574 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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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.
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.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
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]