diff --git a/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C b/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C index d3b3145c1d..0e08e333fd 100644 --- a/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C +++ b/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C @@ -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) diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index f0b50dcdda..4060404af7 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -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(); diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 9fa82bf5fc..723d9bbfb7 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -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(0) - ) const; - //- Calculate average value at centroid of face template Type average(const pointField&, const Field&) const; - //- Scalar magnitude + //- Magnitude of face area inline scalar mag(const pointField&) const; //- Vector normal; magnitude is equal to area of face diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index 21ac6065b6..933cb52239 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -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(0) - ) const; - //- Calculate average value at centroid of face template Type average(const pointField&, const Field&) 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 diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H index 501a6fe1cd..af62aa1aa3 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H @@ -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 {