### STYLE: separate areaNormal/unitNormal method for primitives (issue #885)

parent a410f52e
 ... ... @@ -81,7 +81,7 @@ Foam::label Foam::face::mostConcaveAngle scalar& maxAngle ) const { vector n(normal(points)); vector n(areaNormal(points)); label index = 0; maxAngle = -GREAT; ... ... @@ -542,17 +542,16 @@ Foam::point Foam::face::centre(const UList& points) const } Foam::vector Foam::face::normal(const UList& p) const Foam::vector Foam::face::areaNormal(const UList& p) const { const label nPoints = size(); // Calculate the normal by summing the face triangle normals. // Calculate the area normal by summing the face triangle area normals. // Changed to deal with small concavity by using a central decomposition // // If the face is a triangle, do a direct calculation to avoid round-off // error-related problems // if (nPoints == 3) { return triPointRef ... ... @@ -560,7 +559,7 @@ Foam::vector Foam::face::normal(const UList& p) const p[operator[](0)], p[operator[](1)], p[operator[](2)] ).normal(); ).areaNormal(); } label pI; ... ... @@ -594,7 +593,7 @@ Foam::vector Foam::face::normal(const UList& p) const p[operator[](pI)], nextPoint, centrePoint ).normal(); ).areaNormal(); } return n; ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -39,7 +39,6 @@ SourceFiles faceTemplates.C \*---------------------------------------------------------------------------*/ #ifndef face_H #define face_H ... ... @@ -194,12 +193,22 @@ public: const Field& fld ) const; //- The area normal - with magnitude equal to area of face vector areaNormal(const UList& p) const; //- The unit normal inline vector unitNormal(const UList& p) const; //- Legacy name for areaNormal. // \deprecated Deprecated for new use (JUN-2018) inline vector normal(const UList& p) const { return areaNormal(p); // Legacy definition } //- Magnitude of face area inline scalar mag(const UList& p) const; //- Vector normal; magnitude is equal to area of face vector normal(const UList& p) const; //- Return face with reverse direction // The starting points of the original and reverse face are identical. face reverseFace() const; ... ...
 ... ... @@ -37,10 +37,8 @@ Foam::scalar Foam::face::contactSphereDiameter const UList& meshPoints ) const { scalar magN = Foam::mag(n); vector n1 = n/(magN + SMALL); vector n2 = normal(meshPoints); vector n1 = n/(Foam::mag(n) + SMALL); vector n2 = areaNormal(meshPoints); n2 /= Foam::mag(n2) + SMALL; ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -105,9 +105,17 @@ inline Foam::pointField Foam::face::points } inline Foam::vector Foam::face::unitNormal(const UList& p) const { const vector n(areaNormal(p)); const scalar s(Foam::mag(n)); return s < ROOTVSMALL ? Zero : n/s; } inline Foam::scalar Foam::face::mag(const UList& p) const { return ::Foam::mag(normal(p)); return ::Foam::mag(areaNormal(p)); } ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -124,12 +124,22 @@ public: template Type average(const UList& unused, const Field& fld) const; //- The area normal - with magnitude equal to area of face inline vector areaNormal(const UList& points) const; //- The unit normal inline vector unitNormal(const UList& points) const; //- Legacy name for areaNormal. // \deprecated Deprecated for new use (JUN-2018) inline vector normal(const UList& points) const { return areaNormal(points); // Legacy definition } //- Magnitude of face area inline scalar mag(const UList& points) const; //- Vector normal; magnitude is equal to area of face inline vector normal(const UList& points) const; //- Number of triangles after splitting inline label nTriangles() const; ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -171,15 +171,9 @@ inline Foam::point Foam::triFace::centre(const UList& points) const } inline Foam::scalar Foam::triFace::mag(const UList& points) const { return ::Foam::mag(normal(points)); } // could also delegate to triPointRef(...).normal() inline Foam::vector Foam::triFace::normal(const UList& points) const inline Foam::vector Foam::triFace::areaNormal(const UList& points) const { // As per triPointRef(...).areaNormal() return 0.5* ( (points[operator[](1)] - points[operator[](0)]) ... ... @@ -188,6 +182,20 @@ inline Foam::vector Foam::triFace::normal(const UList& points) const } inline Foam::vector Foam::triFace::unitNormal(const UList& points) const { const vector n(areaNormal(points)); const scalar s(Foam::mag(n)); return s < ROOTVSMALL ? Zero : n/s; } inline Foam::scalar Foam::triFace::mag(const UList& points) const { return ::Foam::mag(areaNormal(points)); } inline Foam::label Foam::triFace::nTriangles() const { return 1; ... ...
 ... ... @@ -172,7 +172,7 @@ public: //- Operate on a triangle result operator()(const FixedList& p) const { return result(triPointRef(p[0], p[1], p[2]).normal()); return result(triPointRef(p[0], p[1], p[2]).areaNormal()); } }; ... ...
 ... ... @@ -106,8 +106,9 @@ typename Foam::cut::opAddResult::type Foam::triCut { // Set the level set to the signed distance from the plane FixedList level; for (label i = 0; i < 3; ++ i) for (label i = 0; i < 3; ++i) { // uses unit-normal level[i] = (tri[i] - p.refPoint()) & p.normal(); } ... ... @@ -251,8 +252,9 @@ typename Foam::cut::opAddResult::type Foam::tetCut { // Set the level set to the signed distance from the plane FixedList level; for (label i = 0; i < 4; ++ i) for (label i = 0; i < 4; ++i) { // uses unit-normal level[i] = (tet[i] - p.refPoint()) & p.normal(); } ... ...
 ... ... @@ -195,7 +195,7 @@ public: // Member Functions //- Return plane normal //- Return the plane unit normal const vector& normal() const; //- Return plane base point ... ...
 ... ... @@ -89,7 +89,7 @@ inline Foam::scalar Foam::pyramid::mag const UList& points ) const { return (1.0/3.0)*(base_.normal(points)&(height(points))); return (1.0/3.0)*(base_.areaNormal(points) & (height(points))); } ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -54,13 +54,12 @@ SourceFiles namespace Foam { // Forward declarations class Istream; class Ostream; class tetPoints; class plane; // Forward declaration of friend functions and operators template class tetrahedron; template ... ... @@ -210,13 +209,16 @@ public: // Properties //- Return face normal //- Face area normal for side a inline vector Sa() const; //- Face area normal for side b inline vector Sb() const; //- Face area normal for side c inline vector Sc() const; //- Face area normal for side d inline vector Sd() const; //- Return centre (centroid) ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -133,28 +133,28 @@ inline Foam::triPointRef Foam::tetrahedron::tri template inline Foam::vector Foam::tetrahedron::Sa() const { return triangle(b_, c_, d_).normal(); return triangle(b_, c_, d_).areaNormal(); } template inline Foam::vector Foam::tetrahedron::Sb() const { return triangle(a_, d_, c_).normal(); return triangle(a_, d_, c_).areaNormal(); } template inline Foam::vector Foam::tetrahedron::Sc() const { return triangle(a_, b_, d_).normal(); return triangle(a_, b_, d_).areaNormal(); } template inline Foam::vector Foam::tetrahedron::Sd() const { return triangle(a_, c_, b_).normal(); return triangle(a_, c_, b_).areaNormal(); } ... ... @@ -415,7 +415,7 @@ bool Foam::tetrahedron::inside(const point& pt) const // "definitively" shown otherwise by obtaining a positive dot // product greater than a tolerance of SMALL. // The tet is defined: tet(Cc, tetBasePt, pA, pB) where the normal // The tet is defined: tet(Cc, tetBasePt, pA, pB) where the area normal // vectors and base points for the half-space planes are: // area[0] = Sa(); // area[1] = Sb(); ... ... @@ -575,10 +575,11 @@ inline void Foam::tetrahedron::tetSliceWithPlane label nPos = 0; forAll(tet, i) { // with plane unit-normal d[i] = ((tet[i] - pl.refPoint()) & pl.normal()); if (d[i] > 0) { nPos++; ++nPos; } } ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -206,12 +206,22 @@ public: //- Return centre (centroid) inline Point centre() const; //- The area normal - with magnitude equal to area of triangle inline vector areaNormal() const; //- Return unit normal inline vector unitNormal() const; //- Legacy name for areaNormal. // \deprecated Deprecated for new use (JUN-2018) inline vector normal() const { return areaNormal(); } //- Return scalar magnitude inline scalar mag() const; //- Return vector normal inline vector normal() const; //- Return circum-centre inline Point circumCentre() const; ... ...
 ... ... @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. ... ... @@ -106,16 +106,25 @@ inline Point Foam::triangle::centre() const template inline Foam::scalar Foam::triangle::mag() const inline Foam::vector Foam::triangle::areaNormal() const { return Foam::mag(normal()); return 0.5*((b_ - a_)^(c_ - a_)); } template inline Foam::vector Foam::triangle::normal() const inline Foam::vector Foam::triangle::unitNormal() const { return 0.5*((b_ - a_)^(c_ - a_)); const vector n(areaNormal()); const scalar s(Foam::mag(n)); return s < ROOTVSMALL ? Zero : n/s; } template inline Foam::scalar Foam::triangle::mag() const { return ::Foam::mag(areaNormal()); } ... ... @@ -392,7 +401,7 @@ inline Foam::pointHit Foam::triangle::ray || (alg == intersection::HALF_RAY && dist > -planarPointTol) || ( alg == intersection::VISIBLE && ((q1 & normal()) < -VSMALL) && ((q1 & areaNormal()) < -VSMALL) ); if (hit && eligible) ... ...
 ... ... @@ -526,11 +526,6 @@ public: // current tet. inline vector normal() const; //- Return the normal of the tri on tetFacei_ for the // current tet at the start of the timestep, i.e. based // on oldPoints inline vector oldNormal() const; //- Is the particle on a face? inline bool onFace() const; ... ...
 ... ... @@ -280,12 +280,6 @@ inline Foam::vector Foam::particle::normal() const } inline Foam::vector Foam::particle::oldNormal() const { return currentTetIndices().oldFaceTri(mesh_).normal(); } inline bool Foam::particle::onFace() const { return facei_ >= 0; ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!