Go to the documentation of this file.
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;
158 mesh.faceOwner()[faceI]
161 const scalar faceAreaSqr =
magSqr(
mesh.faceAreas()[faceI]);
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);
pointHit nearestPoint(const point &p) const
Return nearest point to p on tetrahedron. Is p itself.
tetPointRef tet(const polyMesh &mesh) const
Return the geometry corresponding to this tet from the.
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
void findTriangle(const polyMesh &mesh, const vector &position, const label faceI)
static scalar tol
Tolerance used in calculating barycentric co-ordinates.
#define forAll(list, i)
Loop across all elements in list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
void findTetrahedron(const polyMesh &mesh, const vector &position, const label cellI)
Mesh consisting of general polyhedral cells.
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]
scalar barycentric(const point &pt, List< scalar > &bary) const
Calculate the barycentric coordinates of the given.
label facePtB() const
Return face point B.
static int debug
Debug switch.
scalar distance() const
Return distance to hit.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the.
label face() const
Return the face.
label faceBasePt() const
Return the face base point.
int debugSwitch(const char *name, const int defaultValue=0)
Lookup debug switch or add default value.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
cellPointWeight(const polyMesh &mesh, const vector &position, const label cellI, const label faceI=-1)
Construct from components.
prefixOSstream Pout(cout, "Pout")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label facePtA() const
Return face point A.
A face is a list of labels corresponding to mesh vertices.
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
scalar barycentric(const point &pt, List< scalar > &bary) const
Calculate the barycentric coordinates of the given.
dimensioned< scalar > magSqr(const dimensioned< Type > &)