47 Pout<<
nl <<
"Foam::cellPointWeight::findTetrahedron" <<
nl 48 <<
"position = " << position <<
nl 49 <<
"celli = " << celli <<
endl;
59 const scalar cellVolume = mesh.
cellVolumes()[celli];
70 if (
mag(det/cellVolume) > tol)
72 const scalar& u = weights_[0];
73 const scalar& v = weights_[1];
74 const scalar& w = weights_[2];
81 && (u + v + w < 1 + tol)
85 faceVertices_[1] = f[tetIs.
facePtA()];
86 faceVertices_[2] = f[tetIs.
facePtB()];
96 scalar minNearDist = VGREAT;
98 label nearestTetI = -1;
106 if (nearDist < minNearDist)
108 minNearDist = nearDist;
116 Pout<<
"cellPointWeight::findTetrahedron" <<
nl 117 <<
" Tetrahedron search failed; using closest tet to point " 125 const tetIndices& tetIs = cellTets[nearestTetI];
135 faceVertices_[1] = f[tetIs.
facePtA()];
136 faceVertices_[2] = f[tetIs.
facePtB()];
149 Pout<<
"\nbool Foam::cellPointWeight::findTriangle" <<
nl 150 <<
"position = " << position <<
nl 151 <<
"facei = " << facei <<
endl;
174 if (0.25*
mag(det)/faceAreaSqr > tol)
176 const scalar& u = triWeights[0];
177 const scalar& v = triWeights[1];
188 weights_[1] = triWeights[0];
189 weights_[2] = triWeights[1];
190 weights_[3] = triWeights[2];
193 faceVertices_[1] = f[tetIs.
facePtA()];
194 faceVertices_[2] = f[tetIs.
facePtB()];
203 scalar minNearDist = VGREAT;
205 label nearestTetI = -1;
213 if (nearDist < minNearDist)
215 minNearDist = nearDist;
223 Pout<<
"cellPointWeight::findTriangle" <<
nl 224 <<
" Triangle search failed; using closest tri to point " 231 const tetIndices& tetIs = faceTets[nearestTetI];
243 weights_[1] = triWeights[0];
244 weights_[2] = triWeights[1];
245 weights_[3] = triWeights[2];
248 faceVertices_[1] = f[tetIs.
facePtA()];
249 faceVertices_[2] = f[tetIs.
facePtB()];
270 findTetrahedron(mesh, position, celli);
275 findTriangle(mesh, position, facei);
#define forAll(list, i)
Loop across all elements in list.
static scalar tol
Tolerance used in calculating barycentric co-ordinates.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label facePtA() const
Return face point A.
A face is a list of labels corresponding to mesh vertices.
static int debug
Debug switch.
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const vectorField & faceAreas() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
scalar barycentric(const point &pt, List< scalar > &bary) const
Calculate the barycentric coordinates of the given.
label faceBasePt() const
Return the face base point.
cellPointWeight(const polyMesh &mesh, const vector &position, const label celli, const label facei=-1)
Construct from components.
scalar distance() const
Return distance to hit.
label facePtB() const
Return face point B.
int debugSwitch(const char *name, const int defaultValue=0)
Lookup debug switch or add default value.
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]
void findTetrahedron(const polyMesh &mesh, const vector &position, const label celli)
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
label face() const
Return the face.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
prefixOSstream Pout(cout,"Pout")
const scalarField & cellVolumes() const
void findTriangle(const polyMesh &mesh, const vector &position, const label facei)
pointHit nearestPoint(const point &p) const
Return nearest point to p on tetrahedron. Is p itself.
scalar barycentric(const point &pt, List< scalar > &bary) const
Calculate the barycentric coordinates of the given.
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
tetPointRef tet(const polyMesh &mesh) const
Return the geometry corresponding to this tet from the.