Go to the documentation of this file.
44 Foam::face::calcEdgeVectors(
const UList<point>&
points)
const
47 auto& edgeVecs = tedgeVecs.ref();
52 edgeVecs[i].normalise();
59 Foam::label Foam::face::mostConcaveAngle
61 const UList<point>&
points,
73 const vector& leftEdge = edges[rcIndex(i)];
74 const vector& rightEdge = edges[i];
76 vector edgeNormal = (rightEdge ^ leftEdge);
79 scalar edgeCos = (leftEdge & rightEdge);
80 scalar edgeAngle =
acos(
max(-1.0,
min(1.0, edgeCos)));
84 if ((edgeNormal &
n) > 0)
107 Foam::label Foam::face::split
109 const face::splitMode
mode,
110 const UList<point>&
points,
117 const label oldIndices = (triI + quadI);
122 <<
"Serious problem: asked to split a face with < 3 vertices"
125 else if (size() == 3)
128 if (
mode == COUNTTRIANGLE ||
mode == COUNTQUAD)
134 triFaces[triI++] = *
this;
137 else if (size() == 4)
139 if (
mode == COUNTTRIANGLE)
143 if (
mode == COUNTQUAD)
147 else if (
mode == SPLITTRIANGLE)
153 label startIndex = mostConcaveAngle(
points, edges, minAngle);
155 label nextIndex = fcIndex(startIndex);
156 label splitIndex = fcIndex(nextIndex);
160 triFace[0] = operator[](startIndex);
161 triFace[1] = operator[](nextIndex);
162 triFace[2] = operator[](splitIndex);
166 triFace[0] = operator[](splitIndex);
167 triFace[1] = operator[](fcIndex(splitIndex));
168 triFace[2] = operator[](startIndex);
174 quadFaces[quadI++] = *
this;
184 label startIndex = mostConcaveAngle(
points, edges, minAngle);
186 scalar bisectAngle = minAngle/2;
187 const vector& rightEdge = edges[startIndex];
194 label index = fcIndex(fcIndex(startIndex));
196 label minIndex = index;
199 for (label i = 0; i < size() - 3; i++)
204 -
points[
operator[](startIndex)]
206 splitEdge.normalise();
208 const scalar splitCos = splitEdge & rightEdge;
209 const scalar splitAngle =
acos(
max(-1.0,
min(1.0, splitCos)));
210 const scalar
angleDiff = fabs(splitAngle - bisectAngle);
219 index = fcIndex(index);
229 if (minIndex > startIndex)
231 diff = minIndex - startIndex;
236 diff = minIndex + size() - startIndex;
239 label nPoints1 =
diff + 1;
240 label nPoints2 = size() -
diff + 1;
243 face face1(nPoints1);
246 for (label i = 0; i < nPoints1; i++)
248 face1[i] = operator[](index);
249 index = fcIndex(index);
253 face face2(nPoints2);
256 for (label i = 0; i < nPoints2; i++)
258 face2[i] = operator[](index);
259 index = fcIndex(index);
263 face1.split(
mode,
points, triI, quadI, triFaces, quadFaces);
264 face2.split(
mode,
points, triI, quadI, triFaces, quadFaces);
267 return (triI + quadI - oldIndices);
287 const label sizeA = a.size();
288 const label sizeB =
b.size();
303 return (a[0] ==
b[0] ? 1 : 0);
312 if (aCirc() == bCirc())
333 if (aCirc() != bCirc())
361 if (aCirc() != bCirc())
384 const label sizeA = a.size();
385 const label sizeB =
b.size();
395 return (a[0] ==
b[0]);
404 if (a[i] == a[j]) aOcc++;
411 if (a[i] ==
b[j]) bOcc++;
415 if (aOcc != bOcc)
return false;
426 label len =
f.size();
436 return op(
f[0], seed);
441 for (label i = 1; i < len; ++i)
450 if (
f.fcValue(pivot) <
f.rcValue(pivot))
455 seed = op(
f[pivot], seed);
456 pivot =
f.fcIndex(pivot);
464 seed = op(
f[pivot], seed);
465 pivot =
f.rcIndex(pivot);
480 for (label i=1; i<size(); i++)
482 if (
operator[](i) != operator[](ci))
484 operator[](++ci) = operator[](i);
488 if (
operator[](ci) !=
operator[](0))
502 const label
n = size();
506 for (label i=1; i < (
n+1)/2; ++i)
508 std::swap(
operator[](i),
operator[](
n-i));
535 for (label pI=0; pI<
nPoints; ++pI)
537 centrePoint +=
points[operator[](pI)];
544 for (label pI=0; pI<
nPoints; ++pI)
559 (
points[
operator[](pI)] - centrePoint)
560 ^ (nextPoint - centrePoint)
569 return sumAc/(3.0*sumA);
601 for (pI = 0; pI <
nPoints; ++pI)
603 centrePoint +=
p[operator[](pI)];
609 point nextPoint = centrePoint;
611 for (pI = 0; pI <
nPoints; ++pI)
615 nextPoint =
p[operator[](pI + 1)];
619 nextPoint =
p[operator[](0)];
642 const label len = origFace.
size();
647 newFace[0] = origFace[0];
648 for (label i=1; i < len; ++i)
650 newFace[i] = origFace[len - i];
694 point centreOldPoint = centre(oldPoints);
695 point centreNewPoint = centre(newPoints);
705 oldPoints[
operator[](
pi)],
706 oldPoints[
operator[](
pi + 1)]
712 newPoints[
operator[](
pi)],
713 newPoints[
operator[](
pi + 1)]
721 oldPoints[
operator[](
nPoints-1)],
722 oldPoints[
operator[](0)]
728 newPoints[
operator[](
nPoints-1)],
729 newPoints[
operator[](0)]
752 ).inertia(refPt, density);
755 const point ctr = centre(
p);
764 p[
operator[](fcIndex(i))],
766 ).inertia(refPt, density);
776 const label nVerts = verts.size();
781 theEdges.last().first() = verts.last();
782 theEdges.last().second() = verts[0];
784 for (label verti = 0; verti < nVerts - 1; ++verti)
786 theEdges[verti].first() = verts[verti];
787 theEdges[verti].second() = verts[verti + 1];
797 const label nVerts = verts.size();
802 theEdges.first().first() = verts[0];
803 theEdges.first().second() = verts.last();
805 for (label verti = 1; verti < nVerts; ++verti)
807 theEdges[verti].first() = verts[nVerts - verti];
808 theEdges[verti].second() = verts[nVerts - verti - 1];
817 const label idx =
find(
e.first());
821 if (
e.second() == nextLabel(idx))
return 1;
822 if (
e.second() == prevLabel(idx))
return -1;
845 return split(SPLITTRIANGLE,
points, triI, quadI, triFaces, quadFaces);
859 return split(COUNTQUAD,
points, triI, quadI, triFaces, quadFaces);
872 return split(SPLITQUAD,
points, triI, quadI, triFaces, quadFaces);
879 const label nVerts = verts.size();
882 label longest = nVerts - 1;
883 scalar longestLen =
Foam::edge(verts.first(), verts.last()).
mag(pts);
886 for (label edgei = 0; edgei < nVerts - 1; ++edgei)
888 scalar edgeLen =
Foam::edge(verts[edgei], verts[edgei + 1]).
mag(pts);
890 if (longestLen < edgeLen)
893 longestLen = edgeLen;
static const char *const typeName
points setSize(newPointi)
face reverseFace() const
Return face with reverse direction.
scalar mag(const UList< point > &pts) const
Return scalar magnitude of the edge.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
Walks over a container as if it were circular. The container must have the following members defined:
tensor inertia(const UList< point > &p, const point &refPt=vector::zero, scalar density=1.0) const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label thisLabel(const label i) const
static bool sameVertices(const face &a, const face &b)
Return true if the faces have the same vertices.
label longestEdge(const UList< point > &pts) const
Find the longest edge on a face.
void setIteratorToFulcrum()
Set the iterator to the current position of the fulcrum.
label nTriangles() const
Number of triangles after splitting.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static int compare(const face &a, const face &b)
Compare faces.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
A triangle primitive used to calculate face normals and swept volumes.
label trianglesQuads(const UList< point > &points, label &triI, label &quadI, faceList &triFaces, faceList &quadFaces) const
Split into triangles and quads.
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
point centre(const UList< point > &points) const
Centre point of face.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
vector areaNormal(const UList< point > &p) const
The area normal - with magnitude equal to area of face.
void flip()
Flip the face in-place.
edgeList edges() const
Return list of edges in forward walk order.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Find index of the first occurrence that satisfies the predicate.
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
label triangles(const UList< point > &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
edgeList rcEdges() const
Return list of edges in reverse walk order.
static unsigned symmhash_code(const UList< label > &f, unsigned seed=0)
The symmetric hash value for face.
label nextLabel(const label i) const
Next vertex on face.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr scalar pi(M_PI)
label nTrianglesQuads(const UList< point > &points, label &nTris, label &nQuads) const
Number of triangles and quads after splitting.
A triangular face using a FixedList of labels corresponding to mesh vertices.
List< face > faceList
A List of faces.
dimensionedScalar acos(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
pointField points(const UList< point > &pts) const
Return the points corresponding to this face.
const dimensionedScalar e
Elementary charge.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
static bool split(const std::string &line, std::string &key, std::string &val)
label collapse()
Collapse face by removing duplicate point labels.
A face is a list of labels corresponding to mesh vertices.
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
void size(const label n)
Older name for setAddressableSize.
constexpr face() noexcept=default
Default construct.
int edgeDirection(const Foam::edge &e) const
Test the edge direction on the face.
bool circulate(const CirculatorBase::direction dir=NONE)
Circulate around the list in the given direction.
triangle< point, const point & > triPointRef
A triangle using referred points.
static scalar angleDiff(scalar angle1, scalar angle2)
scalar sweptVol(const UList< point > &oldPoints, const UList< point > &newPoints) const
Return the volume swept out by the face when its points move.