Go to the documentation of this file.
43 Foam::face::calcEdges(
const UList<point>&
points)
const
50 label ni = fcIndex(i);
55 vector vec(nextPt - thisPt);
65 Foam::scalar Foam::face::edgeCos
71 label leftEdgeI = left(index);
72 label rightEdgeI = right(index);
75 return -(edges[leftEdgeI] & edges[rightEdgeI]);
79 Foam::label Foam::face::mostConcaveAngle
81 const UList<point>&
points,
93 label leftEdgeI = left(i);
94 label rightEdgeI = right(i);
96 vector edgeNormal = edges[rightEdgeI] ^ edges[leftEdgeI];
98 scalar edgeCos = edges[leftEdgeI] & edges[rightEdgeI];
99 scalar edgeAngle =
acos(
max(-1.0,
min(1.0, edgeCos)));
103 if ((edgeNormal &
n) > 0)
115 if (angle > maxAngle)
126 Foam::label Foam::face::split
128 const face::splitMode
mode,
129 const UList<point>&
points,
136 label oldIndices = (triI + quadI);
141 <<
"Serious problem: asked to split a face with < 3 vertices"
147 if (
mode == COUNTTRIANGLE ||
mode == COUNTQUAD)
153 triFaces[triI++] = *
this;
156 else if (size() == 4)
158 if (
mode == COUNTTRIANGLE)
162 if (
mode == COUNTQUAD)
166 else if (
mode == SPLITTRIANGLE)
172 label startIndex = mostConcaveAngle(
points, edges, minAngle);
174 label nextIndex = fcIndex(startIndex);
175 label splitIndex = fcIndex(nextIndex);
179 triFace[0] = operator[](startIndex);
180 triFace[1] = operator[](nextIndex);
181 triFace[2] = operator[](splitIndex);
185 triFace[0] = operator[](splitIndex);
186 triFace[1] = operator[](fcIndex(splitIndex));
187 triFace[2] = operator[](startIndex);
193 quadFaces[quadI++] = *
this;
203 label startIndex = mostConcaveAngle(
points, edges, minAngle);
205 scalar bisectAngle = minAngle/2;
206 vector rightEdge = edges[right(startIndex)];
213 label index = fcIndex(fcIndex(startIndex));
215 label minIndex = index;
218 for (label i = 0; i < size() - 3; i++)
223 -
points[
operator[](startIndex)]
225 splitEdge /=
Foam::mag(splitEdge) + VSMALL;
227 const scalar splitCos = splitEdge & rightEdge;
228 const scalar splitAngle =
acos(
max(-1.0,
min(1.0, splitCos)));
229 const scalar
angleDiff = fabs(splitAngle - bisectAngle);
238 index = fcIndex(index);
248 if (minIndex > startIndex)
250 diff = minIndex - startIndex;
255 diff = minIndex + size() - startIndex;
258 label nPoints1 =
diff + 1;
259 label nPoints2 = size() -
diff + 1;
262 face face1(nPoints1);
265 for (label i = 0; i < nPoints1; i++)
267 face1[i] = operator[](index);
268 index = fcIndex(index);
272 face face2(nPoints2);
275 for (label i = 0; i < nPoints2; i++)
277 face2[i] = operator[](index);
278 index = fcIndex(index);
282 face1.split(
mode,
points, triI, quadI, triFaces, quadFaces);
283 face2.split(
mode,
points, triI, quadI, triFaces, quadFaces);
286 return (triI + quadI - oldIndices);
307 label sizeA = a.size();
308 label sizeB =
b.size();
310 if (sizeA != sizeB || sizeA == 0)
332 if (aCirc() == bCirc())
353 if (aCirc() != bCirc())
381 if (aCirc() != bCirc())
404 const label sizeA = a.size();
405 const label sizeB =
b.size();
415 return (a[0] ==
b[0]);
424 if (a[i] == a[j]) aOcc++;
431 if (a[i] ==
b[j]) bOcc++;
435 if (aOcc != bOcc)
return false;
449 for (label i=1; i<size(); i++)
451 if (
operator[](i) != operator[](ci))
453 operator[](++ci) = operator[](i);
457 if (
operator[](ci) !=
operator[](0))
471 const label
n = size();
475 for (label i=1; i < (
n+1)/2; ++i)
477 Swap(
operator[](i),
operator[](
n-i));
504 for (label pI=0; pI<
nPoints; ++pI)
506 centrePoint +=
points[operator[](pI)];
513 for (label pI=0; pI<
nPoints; ++pI)
528 (
points[
operator[](pI)] - centrePoint)
529 ^ (nextPoint - centrePoint)
538 return sumAc/(3.0*sumA);
570 for (pI = 0; pI <
nPoints; ++pI)
572 centrePoint +=
p[operator[](pI)];
578 point nextPoint = centrePoint;
580 for (pI = 0; pI <
nPoints; ++pI)
584 nextPoint =
p[operator[](pI + 1)];
588 nextPoint =
p[operator[](0)];
611 const label len = origFace.
size();
616 newFace[0] = origFace[0];
617 for (label i=1; i < len; ++i)
619 newFace[i] = origFace[len - i];
663 point centreOldPoint = centre(oldPoints);
664 point centreNewPoint = centre(newPoints);
674 oldPoints[
operator[](
pi)],
675 oldPoints[
operator[](
pi + 1)]
681 newPoints[
operator[](
pi)],
682 newPoints[
operator[](
pi + 1)]
690 oldPoints[
operator[](
nPoints-1)],
691 oldPoints[
operator[](0)]
697 newPoints[
operator[](
nPoints-1)],
698 newPoints[
operator[](0)]
721 ).inertia(refPt, density);
724 const point ctr = centre(
p);
733 p[
operator[](fcIndex(i))],
735 ).inertia(refPt, density);
748 for (label pointi = 0; pointi <
points.size() - 1; ++pointi)
764 if (
operator[](i) ==
e.first())
766 if (
operator[](rcIndex(i)) ==
e.second())
771 else if (
operator[](fcIndex(i)) ==
e.second())
780 else if (
operator[](i) ==
e.second())
782 if (
operator[](rcIndex(i)) ==
e.first())
787 else if (
operator[](fcIndex(i)) ==
e.first())
819 return split(SPLITTRIANGLE,
points, triI, quadI, triFaces, quadFaces);
833 return split(COUNTQUAD,
points, triI, quadI, triFaces, quadFaces);
846 return split(SPLITQUAD,
points, triI, quadI, triFaces, quadFaces);
852 const edgeList& eds = this->edges();
854 label longestEdgeI = -1;
855 scalar longestEdgeLength = -SMALL;
859 scalar edgeLength = eds[edI].mag(pts);
861 if (edgeLength > longestEdgeLength)
864 longestEdgeLength = edgeLength;
874 return f.longestEdge(pts);
static const char *const typeName
points setSize(newPointi)
face reverseFace() const
Return face with reverse direction.
pointField points(const UList< point > &points) const
Return the points corresponding to this face.
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:
int edgeDirection(const edge &e) const
The edge direction on the face.
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...
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.
void Swap(DynamicList< T, SizeMin1 > &a, DynamicList< T, SizeMin2 > &b)
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.
Swap arguments as per std::swap, but in Foam namespace.
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.
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 edges in face point ordering,.
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.
#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)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const dimensionedScalar e
Elementary charge.
static bool split(const std::string &line, std::string &key, std::string &val)
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
label collapse()
Collapse face by removing duplicate point labels.
label longestEdge(const face &f, const UList< point > &pts)
A face is a list of labels corresponding to mesh vertices.
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
constexpr face() noexcept=default
Default construct.
vector point
Point is a vector.
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.