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 & a) > 0)
113 if (angle > maxAngle)
126 const face::splitMode mode,
134 label oldIndices = (triI + quadI);
139 <<
"Serious problem: asked to split a face with < 3 vertices" 145 if (mode == COUNTTRIANGLE || mode == COUNTQUAD)
151 triFaces[triI++] = *
this;
154 else if (
size() == 4)
156 if (mode == COUNTTRIANGLE)
160 if (mode == COUNTQUAD)
164 else if (mode == SPLITTRIANGLE)
170 label startIndex = mostConcaveAngle(points, edges, minAngle);
191 quadFaces[quadI++] = *
this;
201 label startIndex = mostConcaveAngle(points, edges, minAngle);
203 scalar bisectAngle = minAngle/2;
204 vector rightEdge = edges[right(startIndex)];
213 label minIndex = index;
220 points[
operator[](index)]
221 - points[
operator[](startIndex)]
223 splitEdge /=
Foam::mag(splitEdge) + vSmall;
225 const scalar splitCos = splitEdge & rightEdge;
226 const scalar splitAngle =
acos(
max(-1.0,
min(1.0, splitCos)));
227 const scalar angleDiff = fabs(splitAngle - bisectAngle);
229 if (angleDiff < minDiff)
246 if (minIndex > startIndex)
248 diff = minIndex - startIndex;
253 diff = minIndex +
size() - startIndex;
256 label nPoints1 = diff + 1;
260 face face1(nPoints1);
263 for (
label i = 0; i < nPoints1; i++)
270 face face2(nPoints2);
273 for (
label i = 0; i < nPoints2; i++)
280 face1.split(mode, points, triI, quadI, triFaces, quadFaces);
281 face2.split(mode, points, triI, quadI, triFaces, quadFaces);
284 return (triI + quadI - oldIndices);
308 if (sizeA != sizeB || sizeA == 0)
330 if (aCirc() == bCirc())
351 if (aCirc() != bCirc())
379 if (aCirc() != bCirc())
429 if (a[i] == a[j]) aOcc++;
436 if (a[i] == b[j]) bOcc++;
440 if (aOcc != bOcc)
return false;
462 if (
operator[](ci) !=
operator[](0))
480 for (
label i=1; i < (n+1)/2; ++i)
482 Swap(
operator[](i),
operator[](n-i));
525 points[
operator[](pI)]
533 (points[
operator[](pI)] - centrePoint)
534 ^ (nextPoint - centrePoint)
543 return sumAc/(3.0*sumA);
576 for (pI = 0; pI <
nPoints; ++pI)
584 point nextPoint = centrePoint;
586 for (pI = 0; pI <
nPoints; ++pI)
588 if (pI < nPoints - 1)
615 return maga > 0 ? a/maga :
Zero;
629 for (
label pointi = 1; pointi < newList.
size(); pointi++)
631 newList[pointi] = f[
size() - pointi];
634 return face(move(newList));
644 if (f[localIdx] == globalIndex)
701 oldPoints[
operator[](
pi)],
702 oldPoints[
operator[](
pi + 1)]
708 newPoints[
operator[](
pi)],
709 newPoints[
operator[](
pi + 1)]
717 oldPoints[
operator[](nPoints-1)],
718 oldPoints[
operator[](0)]
724 newPoints[
operator[](nPoints-1)],
725 newPoints[
operator[](0)]
748 ).inertia(refPt, density);
762 ).inertia(refPt, density);
775 for (
label pointi = 0; pointi < points.
size() - 1; ++pointi)
777 e[pointi] =
edge(points[pointi], points[pointi + 1]);
781 e.last() =
edge(points.
last(), points[0]);
791 if (
operator[](i) == e.
start())
807 else if (
operator[](i) == e.
end())
846 return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
860 return split(COUNTQUAD, points, triI, quadI, triFaces, quadFaces);
873 return split(SPLITQUAD, points, triI, quadI, triFaces, quadFaces);
881 label longestEdgeI = -1;
882 scalar longestEdgeLength = -small;
886 scalar edgeLength = eds[edI].mag(pts);
888 if (edgeLength > longestEdgeLength)
891 longestEdgeLength = edgeLength;
label nTrianglesQuads(const pointField &points, label &nTris, label &nQuads) const
Number of triangles and quads after splitting.
dimensionedScalar acos(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
A triangle primitive used to calculate face areas and swept volumes.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A face is a list of labels corresponding to mesh vertices.
edgeList edges() const
Return edges in face point ordering,.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
T & operator[](const label)
Return element of UList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
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.
tensor inertia(const pointField &, const point &refPt=vector::zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
point centre(const pointField &) const
Centre point of face.
label which(const label globalIndex) const
Navigation through face vertices.
Vector< scalar > vector
A scalar version of the templated Vector.
void setIteratorToFulcrum()
Set the iterator to the current position of the fulcrum.
label triangles(const pointField &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
vector normal(const pointField &) const
Return unit normal.
label collapse()
Collapse face by removing duplicate point labels.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
face reverseFace() const
Return face with reverse direction.
vectorField pointField
pointField is a vectorField.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
int edgeDirection(const edge &) const
Return the edge direction on the face.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
A triangular face using a FixedList of labels corresponding to mesh vertices.
static int compare(const face &, const face &)
Compare faces.
label trianglesQuads(const pointField &points, label &triI, label &quadI, faceList &triFaces, faceList &quadFaces) const
Split into triangles and quads.
errorManip< error > abort(error &err)
vector area(const pointField &) const
Return vector area.
static const char *const typeName
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
scalar sweptVol(const pointField &oldPoints, const pointField &newPoints) const
Return the volume swept out by the face when its points move.
label longestEdge(const face &f, const pointField &pts)
Find the longest edge on a face. Face point labels index into pts.
static bool sameVertices(const face &, const face &)
Return true if the faces have the same vertices.
void setSize(const label)
Reset size of List.
bool circulate(const CirculatorBase::direction dir=CirculatorBase::direction::none)
Circulate around the list in the given direction.
vector point
Point is a vector.
label end() const
Return end vertex label.
void flip()
Flip the face in-place.
triangle< point, const point & > triPointRef
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
const doubleScalar e
Elementary charge.
Walks over a container as if it were circular. The container must have the following members defined:...
label nTriangles() const
Number of triangles after splitting.
A class for managing temporary objects.
T & last()
Return the last element of the list.
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
label size() const
Return the number of elements in the UList.
label start() const
Return start vertex label.