43 Foam::face::calcEdgeVectors(
const UList<point>&
points)
const 46 auto& edgeVecs = tedgeVecs.ref();
51 edgeVecs[i].normalise();
58 Foam::label Foam::face::mostConcaveAngle
60 const UList<point>&
points,
72 const vector& leftEdge = edges[rcIndex(i)];
73 const vector& rightEdge = edges[i];
75 vector edgeNormal = (rightEdge ^ leftEdge);
78 scalar edgeCos = (leftEdge & rightEdge);
79 scalar edgeAngle =
acos(
clamp(edgeCos, -1, 1));
83 if ((edgeNormal &
n) > 0)
106 Foam::label Foam::face::split
108 const face::splitMode
mode,
109 const UList<point>&
points,
116 const label oldIndices = (triI + quadI);
121 <<
"Serious problem: asked to split a face with < 3 vertices" 124 else if (size() == 3)
127 if (
mode == COUNTTRIANGLE ||
mode == COUNTQUAD)
133 triFaces[triI++] = *
this;
136 else if (size() == 4)
138 if (
mode == COUNTTRIANGLE)
142 if (
mode == COUNTQUAD)
146 else if (
mode == SPLITTRIANGLE)
152 label startIndex = mostConcaveAngle(
points, edges, minAngle);
154 label nextIndex = fcIndex(startIndex);
155 label splitIndex = fcIndex(nextIndex);
159 triFace[0] = operator[](startIndex);
160 triFace[1] = operator[](nextIndex);
161 triFace[2] = operator[](splitIndex);
165 triFace[0] = operator[](splitIndex);
166 triFace[1] = operator[](fcIndex(splitIndex));
167 triFace[2] = operator[](startIndex);
173 quadFaces[quadI++] = *
this;
183 label startIndex = mostConcaveAngle(
points, edges, minAngle);
185 scalar bisectAngle = minAngle/2;
186 const vector& rightEdge = edges[startIndex];
193 label index = fcIndex(fcIndex(startIndex));
195 label minIndex = index;
198 for (label i = 0; i < size() - 3; i++)
203 -
points[
operator[](startIndex)]
205 splitEdge.normalise();
207 const scalar splitCos = splitEdge & rightEdge;
208 const scalar splitAngle =
acos(
clamp(splitCos, -1, 1));
209 const scalar
angleDiff = fabs(splitAngle - bisectAngle);
218 index = fcIndex(index);
228 if (minIndex > startIndex)
230 diff = minIndex - startIndex;
235 diff = minIndex + size() - startIndex;
238 label nPoints1 =
diff + 1;
239 label nPoints2 = size() -
diff + 1;
242 face face1(nPoints1);
245 for (label i = 0; i < nPoints1; i++)
247 face1[i] = operator[](index);
248 index = fcIndex(index);
252 face face2(nPoints2);
255 for (label i = 0; i < nPoints2; i++)
257 face2[i] = operator[](index);
258 index = fcIndex(index);
262 face1.split(
mode,
points, triI, quadI, triFaces, quadFaces);
263 face2.split(
mode,
points, triI, quadI, triFaces, quadFaces);
266 return (triI + quadI - oldIndices);
286 const label sizeA = a.
size();
287 const label sizeB =
b.size();
302 return (a[0] ==
b[0] ? 1 : 0);
305 ConstCirculator<face> aCirc(a);
306 ConstCirculator<face> bCirc(
b);
311 if (aCirc() == bCirc())
314 bCirc.setFulcrumToIterator();
324 if (!bCirc.circulate())
332 if (*aCirc != *bCirc)
344 if (!aCirc.circulate())
351 aCirc.setIteratorToFulcrum();
352 bCirc.setIteratorToFulcrum();
360 if (*aCirc != *bCirc)
372 if (!aCirc.circulate())
383 const label sizeA = a.size();
384 const label sizeB =
b.size();
394 return (a[0] ==
b[0]);
403 if (a[i] == a[j]) aOcc++;
410 if (a[i] ==
b[j]) bOcc++;
414 if (aOcc != bOcc)
return false;
425 label len =
f.
size();
435 return op(
f[0], seed);
440 for (label i = 1; i < len; ++i)
454 seed = op(
f[pivot], seed);
463 seed = op(
f[pivot], seed);
479 for (label i=1; i<size(); i++)
481 if (
operator[](i) != operator[](ci))
483 operator[](++ci) = operator[](i);
487 if (
operator[](ci) !=
operator[](0))
501 const label
n = size();
505 for (label i=1; i < (
n+1)/2; ++i)
507 std::swap(
operator[](i),
operator[](
n-i));
533 for (label pI=0; pI<
nPoints; ++pI)
535 centrePoint +=
points[operator[](pI)];
542 for (label pI=0; pI<
nPoints; ++pI)
557 (
points[
operator[](pI)] - centrePoint)
558 ^ (nextPoint - centrePoint)
567 return sumAc/(3.0*sumA);
599 for (pI = 0; pI <
nPoints; ++pI)
601 centrePoint +=
p[operator[](pI)];
607 point nextPoint = centrePoint;
609 for (pI = 0; pI <
nPoints; ++pI)
613 nextPoint =
p[operator[](pI + 1)];
617 nextPoint =
p[operator[](0)];
640 const label len = origFace.
size();
645 newFace[0] = origFace[0];
646 for (label i=1; i < len; ++i)
648 newFace[i] = origFace[len - i];
658 const UList<point>& oldPoints,
659 const UList<point>& newPoints
692 point centreOldPoint = centre(oldPoints);
693 point centreNewPoint = centre(newPoints);
703 oldPoints[
operator[](
pi)],
704 oldPoints[
operator[](
pi + 1)]
710 newPoints[
operator[](
pi)],
711 newPoints[
operator[](
pi + 1)]
719 oldPoints[
operator[](
nPoints-1)],
720 oldPoints[
operator[](0)]
726 newPoints[
operator[](
nPoints-1)],
727 newPoints[
operator[](0)]
750 ).inertia(refPt, density);
753 const point ctr = centre(
p);
762 p[
operator[](fcIndex(i))],
764 ).inertia(refPt, density);
774 const label nVerts = verts.
size();
779 theEdges.back().first() = verts.back();
780 theEdges.back().second() = verts.front();
782 for (label verti = 0; verti < nVerts - 1; ++verti)
784 theEdges[verti].first() = verts[verti];
785 theEdges[verti].second() = verts[verti + 1];
795 const label nVerts = verts.
size();
800 theEdges.front().first() = verts.front();
801 theEdges.front().second() = verts.back();
803 for (label verti = 1; verti < nVerts; ++verti)
805 theEdges[verti].first() = verts[nVerts - verti];
806 theEdges[verti].second() = verts[nVerts - verti - 1];
815 const label idx =
find(
e.first());
819 if (
e.second() == nextLabel(idx))
return 1;
820 if (
e.second() == prevLabel(idx))
return -1;
843 return split(SPLITTRIANGLE,
points, triI, quadI, triFaces, quadFaces);
857 return split(COUNTQUAD,
points, triI, quadI, triFaces, quadFaces);
870 return split(SPLITQUAD,
points, triI, quadI, triFaces, quadFaces);
877 const label nVerts = verts.
size();
880 label longest = nVerts - 1;
884 for (label edgei = 0; edgei < nVerts - 1; ++edgei)
886 scalar edgeLen =
pts[verts[edgei]].distSqr(
pts[verts[edgei+1]]);
888 if (longestLen < edgeLen)
891 longestLen = edgeLen;
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
void size(const label n)
Older name for setAddressableSize.
dimensionedScalar acos(const dimensionedScalar &ds)
A face is a list of labels corresponding to mesh vertices.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
edgeList edges() const
Return list of edges in forward walk order.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
label triangles(const UList< point > &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
constexpr face() noexcept=default
Default construct.
T & front()
Access first element of the list, position [0].
label nextLabel(const label i) const
Next vertex on face.
vector areaNormal(const UList< point > &p) const
The area normal - with magnitude equal to area of face.
static unsigned symmhash_code(const UList< label > &f, unsigned seed=0)
The symmetric hash value for face.
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
points setSize(newPointi)
List< face > faceList
List of faces.
label collapse()
Collapse face by removing duplicate vertex labels.
pointField points(const UList< point > &pts) const
Return the points corresponding to this face.
face reverseFace() const
Return face with reverse direction.
const dimensionedScalar e
Elementary charge.
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
int edgeDirection(const Foam::edge &e) const
Test the edge direction on the face.
A triangular face using a FixedList of labels corresponding to mesh vertices.
label longestEdge(const UList< point > &pts) const
Find the longest edge on a face.
scalar sweptVol(const UList< point > &oldPoints, const UList< point > &newPoints) const
Return the volume swept out by the face when its points move.
static scalar angleDiff(scalar angle1, scalar angle2)
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Point centre() const
Return centre (centroid)
constexpr scalar pi(M_PI)
tensor inertia(const UList< point > &p, const point &refPt=vector::zero, scalar density=1.0) const
Return the inertia tensor, with optional reference point and density specification.
label trianglesQuads(const UList< point > &points, label &triI, label &quadI, faceList &triFaces, faceList &quadFaces) const
Split into triangles and quads.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
label size() const noexcept
The number of elements in the List.
static const char *const typeName
static bool split(const std::string &line, std::string &key, std::string &val)
vector point
Point is a vector.
label nTrianglesQuads(const UList< point > &points, label &nTris, label &nQuads) const
Number of triangles and quads after splitting.
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
void flip()
Flip the face in-place.
triangle< point, const point & > triPointRef
A triangle using referred points.
edgeList rcEdges() const
Return list of edges in reverse walk order.
T & back()
Access last element of the list, position [size()-1].
label thisLabel(const label i) const
The vertex on face - identical to operator[], but with naming similar to nextLabel(), prevLabel()
Field< vector > vectorField
Specialisation of Field<T> for vector.
point centre(const UList< point > &points) const
Centre point of face.
label nTriangles() const
Number of triangles after splitting.
static int compare(const face &a, const face &b)
Compare faces.
List< label > labelList
A List of labels.
A class for managing temporary objects.
static bool sameVertices(const face &a, const face &b)
True if the faces have all the same vertices.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
Tensor of scalars, i.e. Tensor<scalar>.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list)
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
static constexpr const zero Zero
Global zero (0)