41 Foam::face::calcEdges(
const pointField& points)
const 53 vector vec(nextPt - thisPt);
63 Foam::scalar Foam::face::edgeCos
69 label leftEdgeI = left(index);
70 label rightEdgeI = right(index);
73 return -(edges[leftEdgeI] & edges[rightEdgeI]);
91 label leftEdgeI = left(i);
92 label rightEdgeI = right(i);
94 vector edgeNormal = edges[rightEdgeI] ^ edges[leftEdgeI];
96 scalar edgeCos = edges[leftEdgeI] & edges[rightEdgeI];
97 scalar edgeAngle =
acos(
max(-1.0,
min(1.0, edgeCos)));
101 if ((edgeNormal &
n) > 0)
113 if (angle > maxAngle)
126 const face::splitMode mode,
134 label oldIndices = (triI + quadI);
141 "(const face::splitMode, const pointField&, label&, label&" 142 ", faceList&, faceList&)" 144 <<
"Serious problem: asked to split a face with < 3 vertices" 150 if (mode == COUNTTRIANGLE || mode == COUNTQUAD)
156 triFaces[triI++] = *
this;
159 else if (
size() == 4)
161 if (mode == COUNTTRIANGLE)
165 if (mode == COUNTQUAD)
169 else if (mode == SPLITTRIANGLE)
175 label startIndex = mostConcaveAngle(points, edges, minAngle);
196 quadFaces[quadI++] = *
this;
206 label startIndex = mostConcaveAngle(points, edges, minAngle);
208 scalar bisectAngle = minAngle/2;
209 vector rightEdge = edges[right(startIndex)];
218 label minIndex = index;
225 points[
operator[](index)]
226 - points[
operator[](startIndex)]
228 splitEdge /=
Foam::mag(splitEdge) + VSMALL;
230 const scalar splitCos = splitEdge & rightEdge;
231 const scalar splitAngle =
acos(
max(-1.0,
min(1.0, splitCos)));
232 const scalar angleDiff = fabs(splitAngle - bisectAngle);
234 if (angleDiff < minDiff)
251 if (minIndex > startIndex)
253 diff = minIndex - startIndex;
258 diff = minIndex +
size() - startIndex;
261 label nPoints1 = diff + 1;
265 face face1(nPoints1);
268 for (
label i = 0; i < nPoints1; i++)
275 face face2(nPoints2);
278 for (
label i = 0; i < nPoints2; i++)
285 face1.split(mode, points, triI, quadI, triFaces, quadFaces);
286 face2.split(mode, points, triI, quadI, triFaces, quadFaces);
289 return (triI + quadI - oldIndices);
313 if (sizeA != sizeB || sizeA == 0)
335 if (aCirc() == bCirc())
356 if (aCirc() != bCirc())
384 if (aCirc() != bCirc())
434 if (a[i] == a[j]) aOcc++;
441 if (a[i] == b[j]) bOcc++;
445 if (aOcc != bOcc)
return false;
467 if (
operator[](ci) !=
operator[](0))
485 for (
label i=1; i < (n+1)/2; ++i)
487 Swap(
operator[](i),
operator[](n-i));
530 points[
operator[](pI)]
538 (points[
operator[](pI)] - centrePoint)
539 ^ (nextPoint - centrePoint)
548 return sumAc/(3.0*sumA);
581 for (pI = 0; pI <
nPoints; ++pI)
589 point nextPoint = centrePoint;
591 for (pI = 0; pI <
nPoints; ++pI)
593 if (pI < nPoints - 1)
626 for (
label pointI = 1; pointI < newList.
size(); pointI++)
628 newList[pointI] = f[
size() - pointI];
641 if (f[localIdx] == globalIndex)
698 oldPoints[
operator[](
pi)],
699 oldPoints[
operator[](
pi + 1)]
705 newPoints[
operator[](
pi)],
706 newPoints[
operator[](
pi + 1)]
714 oldPoints[
operator[](nPoints-1)],
715 oldPoints[
operator[](0)]
721 newPoints[
operator[](nPoints-1)],
722 newPoints[
operator[](0)]
745 ).inertia(refPt, density);
759 ).inertia(refPt, density);
772 for (
label pointI = 0; pointI < points.
size() - 1; ++pointI)
774 e[pointI] =
edge(points[pointI], points[pointI + 1]);
778 e.last() =
edge(points.
last(), points[0]);
788 if (
operator[](i) == e.
start())
804 else if (
operator[](i) == e.
end())
844 return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
858 return split(COUNTQUAD, points, triI, quadI, triFaces, quadFaces);
871 return split(SPLITQUAD, points, triI, quadI, triFaces, quadFaces);
879 label longestEdgeI = -1;
880 scalar longestEdgeLength = -SMALL;
884 scalar edgeLength = eds[edI].mag(pts);
886 if (edgeLength > longestEdgeLength)
889 longestEdgeLength = edgeLength;
label which(const label globalIndex) const
Navigation through face vertices.
label trianglesQuads(const pointField &points, label &triI, label &quadI, faceList &triFaces, faceList &quadFaces) const
Split into triangles and quads.
vector point
Point is a vector.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
dimensioned< scalar > mag(const dimensioned< Type > &)
face reverseFace() const
Return face with reverse direction.
Walks over a container as if it were circular. The container must have the following members defined:...
T & last()
Return the last element of the list.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
edgeList edges() const
Return edges in face point ordering,.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label collapse()
Collapse face by removing duplicate point labels.
point centre(const pointField &) const
Centre point of face.
vectorField pointField
pointField is a vectorField.
A triangle primitive used to calculate face normals and swept volumes.
triangle< point, const point & > triPointRef
A face is a list of labels corresponding to mesh vertices.
scalar sweptVol(const pointField &oldPoints, const pointField &newPoints) const
Return the volume swept out by the face when its points move.
T & operator[](const label)
Return element of UList.
static bool sameVertices(const face &, const face &)
Return true if the faces have the same vertices.
const double e
Elementary charge.
void setSize(const label)
Reset size of List.
tensor inertia(const pointField &, const point &refPt=vector::zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
void setIteratorToFulcrum()
Set the iterator to the current position of the fulcrum.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensionedScalar acos(const dimensionedScalar &ds)
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
errorManip< error > abort(error &err)
label nTrianglesQuads(const pointField &points, label &nTris, label &nQuads) const
Number of triangles and quads after splitting.
label longestEdge(const face &f, const pointField &pts)
Find the longest edge on a face. Face point labels index into pts.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
void flip()
Flip the face in-place.
int edgeDirection(const edge &) const
Return the edge direction on the face.
vector normal(const pointField &) const
Vector normal; magnitude is equal to area of face.
label end() const
Return end vertex label.
label size() const
Return the number of elements in the UList.
bool circulate(const CirculatorBase::direction dir=NONE)
Circulate around the list in the given direction.
A triangular face using a FixedList of labels corresponding to mesh vertices.
Vector< scalar > vector
A scalar version of the templated Vector.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
label start() const
Return start vertex label.
static const char *const typeName
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label nTriangles() const
Number of triangles after splitting.
label triangles(const pointField &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
A class for managing temporary objects.
static int compare(const face &, const face &)
Compare faces.