mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: drop face::area() and triFace::area() - less useful than expected
This commit is contained in:
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAll(surf, faceI)
|
||||
{
|
||||
const scalar fArea(Foam::mag(surf[faceI].area(surf.points())));
|
||||
const scalar fArea(surf[faceI].mag(surf.points()));
|
||||
areaTotal += fArea;
|
||||
|
||||
if (writeAreas)
|
||||
|
||||
@ -555,95 +555,6 @@ Foam::point Foam::face::centre(const pointField& points) const
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::face::area
|
||||
(
|
||||
const pointField& points,
|
||||
point& centrePt
|
||||
) const
|
||||
{
|
||||
const label nPoints = this->size();
|
||||
const labelList& f = *this;
|
||||
|
||||
// If the face is a triangle, do a direct calculation for efficiency
|
||||
// and to avoid round-off error-related problems
|
||||
if (nPoints == 3)
|
||||
{
|
||||
// return centre point information?
|
||||
if (¢rePt)
|
||||
{
|
||||
centrePt =
|
||||
(
|
||||
(1.0/3.0)
|
||||
* (points[f[0]] + points[f[1]] + points[f[2]])
|
||||
);
|
||||
}
|
||||
|
||||
return
|
||||
(
|
||||
0.5
|
||||
*
|
||||
(
|
||||
(points[f[1]] - points[f[0]])
|
||||
^ (points[f[2]] - points[f[0]])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
point fCentre = points[f[0]];
|
||||
for (label pI = 1; pI < nPoints; ++pI)
|
||||
{
|
||||
fCentre += points[f[pI]];
|
||||
}
|
||||
|
||||
fCentre /= nPoints;
|
||||
|
||||
vector sumN2 = vector::zero;
|
||||
scalar sumA = 0.0;
|
||||
vector sumAc = vector::zero; // for area-weighted centre
|
||||
|
||||
for (label pI = 0; pI < nPoints; ++pI)
|
||||
{
|
||||
const point& nextPoint = points[f[(pI + 1) % nPoints]];
|
||||
|
||||
// Calculate 3*triangle centre
|
||||
const vector ttc
|
||||
(
|
||||
points[f[pI]]
|
||||
+ nextPoint
|
||||
+ fCentre
|
||||
);
|
||||
|
||||
// Calculate 2*triangle normal
|
||||
const vector n2
|
||||
(
|
||||
(nextPoint - points[f[pI]]) ^ (fCentre - points[f[pI]])
|
||||
);
|
||||
|
||||
// 2*triangle area
|
||||
const scalar ta(Foam::mag(n2));
|
||||
|
||||
sumN2 += n2;
|
||||
sumA += ta;
|
||||
sumAc += ta*ttc;
|
||||
}
|
||||
|
||||
// return centre point information?
|
||||
if (¢rePt)
|
||||
{
|
||||
if (sumA > VSMALL)
|
||||
{
|
||||
centrePt = sumAc/(3.0*sumA);
|
||||
}
|
||||
else
|
||||
{
|
||||
centrePt = fCentre;
|
||||
}
|
||||
}
|
||||
|
||||
return 0.5*sumN2;
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::face::normal(const pointField& p) const
|
||||
{
|
||||
const label nPoints = size();
|
||||
|
||||
@ -183,18 +183,11 @@ public:
|
||||
//- Centre point of face
|
||||
point centre(const pointField&) const;
|
||||
|
||||
//- Area of face, optionally return centre point as well
|
||||
vector area
|
||||
(
|
||||
const pointField&,
|
||||
point& centrePt = *reinterpret_cast<point*>(0)
|
||||
) const;
|
||||
|
||||
//- Calculate average value at centroid of face
|
||||
template<class Type>
|
||||
Type average(const pointField&, const Field<Type>&) const;
|
||||
|
||||
//- Scalar magnitude
|
||||
//- Magnitude of face area
|
||||
inline scalar mag(const pointField&) const;
|
||||
|
||||
//- Vector normal; magnitude is equal to area of face
|
||||
|
||||
@ -114,21 +114,14 @@ public:
|
||||
//- Return centre (centroid)
|
||||
inline point centre(const pointField&) const;
|
||||
|
||||
//- Area, optionally return centre point as well
|
||||
inline vector area
|
||||
(
|
||||
const pointField&,
|
||||
point& centrePt = *reinterpret_cast<point*>(0)
|
||||
) const;
|
||||
|
||||
//- Calculate average value at centroid of face
|
||||
template<class Type>
|
||||
Type average(const pointField&, const Field<Type>&) const;
|
||||
|
||||
//- Return scalar magnitude
|
||||
//- Magnitude of face area
|
||||
inline scalar mag(const pointField&) const;
|
||||
|
||||
//- Return vector normal
|
||||
//- Vector normal; magnitude is equal to area of face
|
||||
inline vector normal(const pointField&) const;
|
||||
|
||||
//- Number of triangles after splitting
|
||||
|
||||
@ -171,27 +171,12 @@ inline Foam::point Foam::triFace::centre(const pointField& points) const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::vector Foam::triFace::area
|
||||
(
|
||||
const pointField& points,
|
||||
point& centrePt
|
||||
) const
|
||||
{
|
||||
// return centre point information?
|
||||
if (¢rePt)
|
||||
{
|
||||
centrePt = this->centre(points);
|
||||
}
|
||||
|
||||
return this->normal(points);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::triFace::mag(const pointField& points) const
|
||||
{
|
||||
return ::Foam::mag(normal(points));
|
||||
}
|
||||
|
||||
|
||||
// could also delegate to triPointRef(...).normal()
|
||||
inline Foam::vector Foam::triFace::normal(const pointField& points) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user