49 Pout<<
nl <<
"Foam::cellPointWeight::findTetrahedron" <<
nl
50 <<
"position = " << position <<
nl
51 <<
"celli = " << celli <<
endl;
60 const scalar cellVolume =
mesh.cellVolumes()[celli];
80 && (u + v + w < 1 +
tol)
94 scalar minNearDist = VGREAT;
96 label nearestTetI = -1;
100 const tetIndices& tetIs = cellTets[tetI];
102 scalar nearDist = tetIs.tet(
mesh).nearestPoint(position).distance();
104 if (nearDist < minNearDist)
106 minNearDist = nearDist;
114 Pout<<
"cellPointWeight::findTetrahedron" <<
nl
115 <<
" Tetrahedron search failed; using closest tet to point "
123 const tetIndices& tetIs = cellTets[nearestTetI];
128 weights_ = tetIs.tet(
mesh).pointToBarycentric(position);
143 Pout<<
"\nbool Foam::cellPointWeight::findTriangle" <<
nl
144 <<
"position = " << position <<
nl
145 <<
"facei = " << facei <<
endl;
152 mesh.faceOwner()[facei]
155 const scalar faceAreaSqr =
magSqr(
mesh.faceAreas()[facei]);
159 const tetIndices& tetIs = faceTets[tetI];
164 tetIs.faceTri(
mesh).pointToBarycentric(position, triWeights);
166 if (0.25*
mag(
det)/faceAreaSqr > tol)
168 const scalar& u = triWeights[0];
169 const scalar& v = triWeights[1];
180 weights_[1] = triWeights[0];
181 weights_[2] = triWeights[1];
182 weights_[3] = triWeights[2];
184 faceVertices_ = tetIs.faceTriIs(
mesh);
193 scalar minNearDist = VGREAT;
195 label nearestTetI = -1;
203 if (nearDist < minNearDist)
205 minNearDist = nearDist;
213 Pout<<
"cellPointWeight::findTriangle" <<
nl
214 <<
" Triangle search failed; using closest tri to point "
221 const tetIndices& tetIs = faceTets[nearestTetI];
228 tetIs.faceTri(
mesh).pointToBarycentric(position);
232 weights_[1] = triWeights[0];
233 weights_[2] = triWeights[1];
234 weights_[3] = triWeights[2];
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
scalar distance() const noexcept
Return distance to hit.
void findTetrahedron(const polyMesh &mesh, const vector &position, const label celli)
void findTriangle(const polyMesh &mesh, const vector &position, const label facei)
triFace faceVertices_
Face vertex indices.
static scalar tol
Tolerance used in calculating barycentric coordinates.
barycentric weights_
Weights applied to tet vertices.
cellPointWeight(const polyMesh &mesh, const vector &position, const label celli, const label facei=-1)
Construct from components.
static int debug
Debug switch.
const label celli_
Cell index.
static List< tetIndices > cellTetIndices(const polyMesh &mesh, label cI)
Return the tet decomposition of the given cell, see.
static List< tetIndices > faceTetIndices(const polyMesh &mesh, label fI, label cI)
Return the tet decomposition of the given face, with.
Mesh consisting of general polyhedral cells.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
triFace faceTriIs(const polyMesh &mesh, const bool warn=true) const
The indices corresponding to the tri on the face for this tet. The normal of the tri points out of th...
tetPointRef tet(const polyMesh &mesh) const
The tet geometry for this tet, where point0 is the cell centre.
triPointRef faceTri(const polyMesh &mesh) const
The triangle geometry for the face for this tet. The normal of the tri points out of the cell.
barycentric pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
pointHit nearestPoint(const point &p) const
Return nearest point to p on tetrahedron. Is p itself.
barycentric2D pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
Namespace for handling debugging switches.
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.