37 label tetLabelCandidate[],
38 label tetPointLabels[],
40 scalar phiCandidate[],
45 bool foundTet =
false;
47 const labelList& thisFacePoints = this->mesh_.faces()[nFace];
48 tetPoints[2] = this->mesh_.faceCentres()[nFace];
52 while (pointi < thisFacePoints.size() && !foundTet)
54 label nextPointLabel = (pointi + 1) % thisFacePoints.size();
56 tetPointLabels[0] = thisFacePoints[pointi];
57 tetPointLabels[1] = thisFacePoints[nextPointLabel];
59 tetPoints[0] = this->mesh_.points()[tetPointLabels[0]];
60 tetPoints[1] = this->mesh_.points()[tetPointLabels[1]];
71 vector referencePoint, faceNormal;
72 referencePoint = tetPoints[p1];
75 (tetPoints[p3] - tetPoints[p1])
76 ^ (tetPoints[p2] - tetPoints[p1]);
78 faceNormal /=
mag(faceNormal);
81 vector v0 = tetPoints[
n] - referencePoint;
82 scalar
correct = v0 & faceNormal;
85 faceNormal = -faceNormal;
89 scalar rightSide = v1 & faceNormal;
93 inside = inside && (rightSide >= 0);
95 scalar phiLength = (
position - referencePoint) & faceNormal;
98 max(vSmall, (tetPoints[
n] - referencePoint) & faceNormal);
100 phi[
n] = phiLength/maxLength;
107 if (
mag(dist - 1.0) < minDistance)
109 minDistance =
mag(dist - 1.0);
112 for (
label i=0; i<4; i++)
114 phiCandidate[i] = phi[i];
117 tetLabelCandidate[0] = tetPointLabels[0];
118 tetLabelCandidate[1] = tetPointLabels[1];
141 label tetPointLabels[],
145 bool foundTriangle =
false;
147 const labelList& facePoints = this->mesh_.faces()[nFace];
148 tetPoints[2] = this->mesh_.faceCentres()[nFace];
152 while (pointi < facePoints.size() && !foundTriangle)
156 label nextPointLabel = (pointi + 1) % facePoints.size();
158 tetPointLabels[0] = facePoints[pointi];
159 tetPointLabels[1] = facePoints[nextPointLabel];
161 tetPoints[0] = this->mesh_.points()[tetPointLabels[0]];
162 tetPoints[1] = this->mesh_.points()[tetPointLabels[1]];
164 vector fc = (tetPoints[0] + tetPoints[1] + tetPoints[2])/3.0;
170 vector edge[3], normal[3];
171 for (
label i=0; i<3; i++)
173 label ip0 = (i+1) % 3;
174 label ipp = (i+2) % 3;
175 edge[i] = tetPoints[ipp]-tetPoints[ip0];
178 vector triangleFaceNormal = edge[1] ^ edge[2];
181 for (
label i=0; i<3; i++)
183 normal[i] = triangleFaceNormal ^ edge[i];
184 normal[i] /=
mag(normal[i]) + vSmall;
189 for (
label i=0; i<3; i++)
191 label ip = (i+1) % 3;
192 inside = inside && (((newPos - tetPoints[ip]) & edge[i]) >= 0);
197 foundTriangle =
true;
200 for (
label i=0; i<3; i++)
202 label ip = (i+1) % 3;
203 scalar phiMax =
max(vSmall, normal[i] & edge[ip]);
204 scalar phiLength = (
position-tetPoints[ip]) & normal[i];
205 phi[i] = phiLength/phiMax;
212 return foundTriangle;
238 psis_(i.psis_.
clone())
254 scalar phi[4], phiCandidate[4];
255 label tetLabelCandidate[2], tetPointLabels[2];
262 const vector& cellCentre = this->mesh_.cellCentres()[celli];
263 const labelList& cellFaces = this->mesh_.cells()[celli];
266 tetPoints[3] = cellCentre;
273 bool foundTet =
false;
274 label closestFace = -1;
275 scalar minDistance = great;
279 label nFace = cellFaces[facei];
281 vector normal = this->mesh_.faceAreas()[nFace];
282 normal /=
mag(normal);
284 const vector& faceCentreTmp = this->mesh_.faceCentres()[nFace];
286 scalar multiplierNumerator = (faceCentreTmp - cellCentre) & normal;
287 scalar multiplierDenominator = projection & normal;
291 if (
mag(multiplierDenominator) > small)
293 scalar multiplier = multiplierNumerator/multiplierDenominator;
294 vector iPoint = cellCentre + multiplier*projection;
297 if (dist < minDistance)
312 if (closestFace != -1)
314 label nFace = closestFace;
332 if (minDistance < 1.0e-5)
335 for (
label i=0; i<4; i++)
337 phi[i] = phiCandidate[i];
339 tetPointLabels[0] = tetLabelCandidate[0];
340 tetPointLabels[1] = tetLabelCandidate[1];
353 while (facei < cellFaces.
size() && !foundTet)
355 label nFace = cellFaces[facei];
356 if (nFace < this->mesh_.faceAreas().size())
379 if (minDistance < 1.0e-3)
382 for (
label i=0; i<4; i++)
384 phi[i] = phiCandidate[i];
386 tetPointLabels[0] = tetLabelCandidate[0];
387 tetPointLabels[1] = tetLabelCandidate[1];
398 for (
label i=0; i<2; i++)
400 ts[i] = this->psip_[tetPointLabels[i]];
403 if (closestFace < psis_.size())
405 ts[2] = psis_[closestFace];
410 this->mesh_.boundary().whichPatch(closestFace);
414 if (this->psi_.boundaryField()[
patchi].size())
416 ts[2] = this->psi_.boundaryField()[
patchi]
418 this->mesh_.boundary()[
patchi].whichFace
426 ts[2] = this->psi_[celli];
430 ts[3] = this->psi_[celli];
434 phi[
n] =
min(1.0, phi[
n]);
435 phi[
n] =
max(0.0, phi[
n]);
443 <<
"search failed; using closest cellFace value" <<
endl
444 <<
"cell number " << celli <<
tab
447 if (closestFace < psis_.size())
449 t = psis_[closestFace];
454 this->mesh_.boundary().whichPatch(closestFace);
458 if (this->psi_.boundaryField()[
patchi].size())
460 t = this->psi_.boundaryField()[
patchi]
462 this->mesh_.boundary()[
patchi].whichFace
470 t = this->psi_[celli];
477 bool foundTriangle = findTriangle
488 for (
label i=0; i<2; i++)
490 Type vel = this->psip_[tetPointLabels[i]];
495 if (facei < psis_.size())
497 t += phi[2]*psis_[facei];
501 label patchi = this->mesh_.boundary().whichPatch(facei);
505 if (this->psi_.boundaryField()[
patchi].size())
507 t += phi[2]*this->psi_.boundaryField()[
patchi]
508 [this->mesh_.boundary()[
patchi].whichFace(facei)];
512 t += phi[2]*this->psi_[celli];
519 if (facei < psis_.size())
525 label patchi = this->mesh_.boundary().whichPatch(facei);
529 if (this->psi_.boundaryField()[
patchi].size())
531 t = this->psi_.boundaryField()[
patchi]
532 [this->mesh_.boundary()[
patchi].whichFace(facei)];
536 t = this->psi_[celli];
#define forAll(list, i)
Loop across all elements in list.
Generic GeometricField class.
void size(const label)
Override size to be inconsistent with allocated storage.
Piecewise-linear interpolation method. Uses volPointInterpolation to create values on the points and ...
cellPointFace(const VolField< Type > &psi)
Construct from components.
Type interpolate(const vector &position, const label celli, const label facei=-1) const
Interpolate field to the given point in the given cell.
Base class for interpolations that require a vol-point interpolated field.
const volScalarField & psi
#define InfoInFunction
Report an information message using Foam::Info.
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp)
point position(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the position given the coordinates and tet topology.
List< label > labelList
A List of labels.
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.
tmp< SurfaceField< Type > > linearInterpolate(const VolField< Type > &vf)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)