Commit 2905d8e2 authored by Mark Olesen's avatar Mark Olesen

ENH: distinguish between face areaNormal/unitNormal in the code

- makes benefit of changes in OpenFOAM-v1812 to avoid future
  uncertainty about which 'normal' is meant.
parent 33033ed9
......@@ -164,21 +164,19 @@ Foam::point Foam::Module::boundaryLayers::createNewVertex
if (treatPatches[patchLabel])
{
normal += f.normal(points);
normal += f.areaNormal(points);
}
else
{
v += f.normal(points);
v += f.areaNormal(points);
}
}
const scalar magV = mag(v) + VSMALL;
v /= magV;
v.normalise();
normal -= (normal & v)*v;
const scalar magN = mag(normal) + VSMALL;
normal /= magN;
normal.normalise();
forAllRow(pointPoints, bpI, ppI)
{
......@@ -922,11 +920,11 @@ void Foam::Module::boundaryLayers::createNewEdgeVerticesParallel
if (treatPatches[patchLabel])
{
normal[epI] += f.normal(points);
normal[epI] += f.areaNormal(points);
}
else
{
v[epI] += f.normal(points);
v[epI] += f.areaNormal(points);
}
}
}
......
......@@ -850,7 +850,7 @@ void Foam::Module::extrudeLayer::movePoints()
{
const face& f = faces[faceI];
lps.coordinates() -= f.normal(points);
lps.coordinates() -= f.areaNormal(points);
if (thickness_ < 0.0)
{
......@@ -943,7 +943,7 @@ void Foam::Module::extrudeLayer::movePoints()
{
const face& f = faces[faceI];
normal -= f.normal(points);
normal -= f.areaNormal(points);
if (thickness_ < 0.0)
{
......@@ -969,11 +969,7 @@ void Foam::Module::extrudeLayer::movePoints()
thickness *= 0.4;
}
const scalar d = mag(normal);
if (d > VSMALL)
{
normal /= d;
}
normal.normalise();
displacements[pI] = normal*thickness;
}
......
......@@ -81,8 +81,7 @@ bool Foam::Module::triangulateNonPlanarBaseFaces::findNonPlanarBoundaryFaces()
);
const point triCentre = tri.centre();
vector n = tri.normal();
n /= (mag(n) + VSMALL);
vector n = tri.unitNormal();
forAll(bf, pI)
{
......
......@@ -34,8 +34,7 @@ License
Foam::label Foam::Module::faceDecomposition::concaveVertex() const
{
vector n = f_.normal(points_);
n /= mag(n);
const vector n = f_.unitNormal(points_);
const edgeList edges = f_.edges();
......@@ -43,12 +42,11 @@ Foam::label Foam::Module::faceDecomposition::concaveVertex() const
forAll(edges, eI)
{
vector ev = edges[eI].vec(points_);
ev /= mag(ev);
const short next = (eI + 1) % f_.size();
vector evn = edges[next].vec(points_);
evn /= mag(evn);
const vector ev = edges[eI].unitVec(points_);
const vector evn = edges[next].unitVec(points_);
const vector prod = (ev ^ evn);
......@@ -106,8 +104,7 @@ bool Foam::Module::faceDecomposition::isFaceConvex() const
bool Foam::Module::faceDecomposition::isFacePlanar(const scalar tol) const
{
vector nref = f_.normal(points_);
nref /= mag(nref);
const vector nref = f_.unitNormal(points_);
forAll(f_, pI)
{
......
......@@ -272,13 +272,12 @@ inline Foam::faceList Foam::Module::help::mergePatchFaces
for (label nI = 0; nI<(patchFaces.size()-1); nI++)
{
vector n0 = patchFaces[nI].normal(polyPoints);
n0 /= mag(n0);
const vector n0 = patchFaces[nI].unitNormal(polyPoints);
for (label nJ = nI + 1; nJ < patchFaces.size(); nJ++)
{
vector n1 = patchFaces[nI].normal(polyPoints);
n1 /= mag(n1);
const vector n1 = patchFaces[nI].unitNormal(polyPoints);
if
(
help::shareAnEdge(patchFaces[nI], patchFaces[nJ])
......@@ -686,8 +685,7 @@ inline bool Foam::Module::help::findMinimizerPoint
forAll(origins, i)
{
//- use the normalized vector
vector n = normals[i];
n /= (mag(n) + VSMALL);
vector n = normalised(normals[i]);
const tensor t = n*n;
......@@ -1051,7 +1049,7 @@ inline bool Foam::Module::help::doTrianglesOverlap
return false;
}
vector n0 = tri0.normal();
vector n0 = tri0.areaNormal();
const scalar dn0 = mag(n0);
n0 /= (dn0 + VSMALL);
......@@ -1060,7 +1058,7 @@ inline bool Foam::Module::help::doTrianglesOverlap
return false;
}
vector n1 = tri1.normal();
vector n1 = tri1.areaNormal();
const scalar dn1 = mag(n1);
n1 /= (dn1 + VSMALL);
......@@ -1328,13 +1326,8 @@ inline bool Foam::Module::help::doTrianglesIntersect
return false;
}
vector n0 = tri0.normal();
const scalar dn0 = mag(n0);
n0 /= (dn0 + VSMALL);
vector n1 = tri1.normal();
const scalar dn1 = mag(n1);
n1 /= (dn1 + VSMALL);
const vector n0 = tri0.unitNormal();
const vector n1 = tri1.unitNormal();
//- distance of the points of the first triangle from the plane
//- of the second triangle
......@@ -1677,7 +1670,7 @@ inline bool Foam::Module::help::isFaceConvexAndOk
{
bool valid(true);
vector normal = f.normal(fp);
vector normal = f.areaNormal(fp);
const scalar magN = mag(normal);
//- face has zero area. All points are inverted
......
......@@ -702,7 +702,7 @@ bool Foam::Module::polyMeshGenChecks::checkMinTwist
fCentres[faceI]
);
const vector triArea = triangle.normal();
const vector triArea = triangle.areaNormal();
const scalar magTri = (mag(triArea) + VSMALL);
......@@ -762,7 +762,7 @@ bool Foam::Module::polyMeshGenChecks::checkMinTwist
fCentres[faceI]
);
const vector triArea = triangle.normal();
const vector triArea = triangle.areaNormal();
const scalar magTri = mag(triArea);
......@@ -857,7 +857,7 @@ bool Foam::Module::polyMeshGenChecks::checkMinTwist
fCentres[faceI]
);
const vector triArea = triangle.normal();
const vector triArea = triangle.areaNormal();
const scalar magTri = (mag(triArea) + VSMALL);
......@@ -1356,11 +1356,7 @@ bool Foam::Module::polyMeshGenChecks::checkTriangleTwist
fCentres[faceI]
);
vector prevN = tri.normal();
const scalar magTri = mag(prevN) + VSMALL;
prevN /= magTri;
vector prevN = tri.unitNormal();
// compare with other possible triangles
for (label pJ = pI + 1; pJ < f.size(); ++pJ)
......@@ -1372,11 +1368,7 @@ bool Foam::Module::polyMeshGenChecks::checkTriangleTwist
fCentres[faceI]
);
vector triN = tri.normal();
scalar magTriN = mag(triN) + VSMALL;
triN /= magTriN;
vector triN = tri.unitNormal();
if ((prevN & triN) < minTwist)
{
......@@ -2264,7 +2256,7 @@ void Foam::Module::polyMeshGenChecks::checkFaceSkewness
{
const vector d = fCentres[faceI] - centres[own[faceI]];
vector n = faces[faceI].normal(points);
vector n = faces[faceI].areaNormal(points);
const scalar magn = mag(n);
if (magn > VSMALL)
{
......
......@@ -101,7 +101,7 @@ inline Foam::vector Foam::Module::partTet::Sa(const PointField& points) const
points[data_[3]]
);
return tria.normal();
return tria.areaNormal();
//return triangle<point, point>(b_, c_, d_).normal();
}
......@@ -116,7 +116,7 @@ inline Foam::vector Foam::Module::partTet::Sb(const PointField& points) const
points[data_[2]]
);
return tria.normal();
return tria.areaNormal();
//return triangle<point, point>(a_, d_, c_).normal();
}
......@@ -131,7 +131,7 @@ inline Foam::vector Foam::Module::partTet::Sc(const PointField& points) const
points[data_[3]]
);
return tria.normal();
return tria.areaNormal();
//return triangle<point, point>(a_, b_, d_).normal();
}
......@@ -146,7 +146,7 @@ inline Foam::vector Foam::Module::partTet::Sd(const PointField& points) const
points[data_[1]]
);
return tria.normal();
return tria.areaNormal();
//return triangle<point, point>(a_, c_, b_).normal();
}
......
......@@ -311,8 +311,7 @@ void Foam::Module::triSurfAddressing::calculateFacetNormals() const
# endif
forAll(facets_, fI)
{
vector v = facets_[fI].normal(points_);
v /= (mag(v) + VSMALL);
vector v = facets_[fI].unitNormal(points_);
(*facetNormalsPtr_)[fI] = v;
}
}
......
......@@ -379,7 +379,7 @@ void Foam::Module::boundaryLayerOptimisation::calculateHairVectorsAtTheBoundary
forAllRow(edgeFaces, beI, befI)
{
const face& bf = bFaces[edgeFaces(beI, befI)];
const vector fNormal = bf.normal(points);
const vector fNormal = bf.areaNormal(points);
const label pos = bf.which(he.start());
......
......@@ -57,7 +57,7 @@ void Foam::Module::symmetryPlaneOptimisation::detectSymmetryPlanes()
for (label faceI = start; faceI < end; ++faceI)
{
cs.first += faces[faceI].centre(points);
ns.first += faces[faceI].normal(points);
ns.first += faces[faceI].areaNormal(points);
}
cs.second = ns.second = boundaries[patchI].patchSize();
......
......@@ -99,7 +99,7 @@ Foam::Module::knuppMetric::knuppMetric(partTetMeshSimplex& simplex)
points_[pt.c()]
);
const vector n = tri.normal();
const vector n = tri.areaNormal();
const scalar d = mag(n);
if (d > VSMALL)
......
......@@ -80,7 +80,7 @@ Foam::Module::quadricMetric::quadricMetric(partTetMeshSimplex& simplex)
points_[pt.c()]
);
const vector n = tri.normal();
const vector n = tri.areaNormal();
const scalar d = mag(n);
if (d > VSMALL)
......
......@@ -377,7 +377,7 @@ Foam::scalar Foam::Module::volumeOptimizer::optimiseSteepestDescent
points_[tet.c()]
);
vector n = tri.normal();
vector n = tri.areaNormal();
const scalar d = mag(n);
if (d > VSMALL)
......
......@@ -479,8 +479,7 @@ void Foam::Module::tetMeshOptimisation::optimiseBoundaryVolumeOptimizer
points[nodeI]
);
vector n = tri.normal();
n /= (mag(n) + VSMALL);
vector n = tri.unitNormal();
nt += symm(n*n);
}
......
......@@ -1041,10 +1041,8 @@ bool Foam::Module::edgeExtractor::distributeBoundaryFacesNormalAlignment()
maxDSq = Foam::max(dSq, maxDSq);
// calculate normal vectors
vector tn = surf[nearestTriangle].normal(sPoints);
tn /= (mag(tn) + VSMALL);
vector fn = bf.normal(points);
fn /= (mag(fn) + SMALL);
vector tn = surf[nearestTriangle].unitNormal(sPoints);
vector fn = bf.unitNormal(points);
// calculate alignment
normalAlignment[i] = mag(tn & fn);
......
......@@ -202,7 +202,7 @@ void Foam::Module::meshSurfaceCheckInvertedVertices::checkVertices()
fCentres[bfI]
);
vector nNext = triNext.normal();
vector nNext = triNext.areaNormal();
scalar mNext = mag(nNext);
// face has zero area
......@@ -259,7 +259,7 @@ void Foam::Module::meshSurfaceCheckInvertedVertices::checkVertices()
points[bf.prevLabel(pI)]
);
vector nPrev = triPrev.normal();
vector nPrev = triPrev.areaNormal();
scalar mPrev = mag(nPrev);
// face has zero area
......
......@@ -838,7 +838,7 @@ void Foam::Module::meshSurfaceEngine::calculateFaceNormals() const
{
const face& bf = bFaces[bfI];
faceNormalsPtr_->operator[](bfI) = bf.normal(points);
faceNormalsPtr_->operator[](bfI) = bf.areaNormal(points);
}
}
......
......@@ -96,7 +96,7 @@ void Foam::Module::meshSurfaceEngineModifier::moveBoundaryVertex
{
const label bfI = pFaces(bpI, pfI);
faceNormals[bfI] = bFaces[bfI].normal(points);
faceNormals[bfI] = bFaces[bfI].areaNormal(points);
}
}
......@@ -271,7 +271,7 @@ void Foam::Module::meshSurfaceEngineModifier::updateGeometry
forAll(updateFaces, bfI)
{
if (updateFaces[bfI])
faceNormals[bfI] = bFaces[bfI].normal(points);
faceNormals[bfI] = bFaces[bfI].areaNormal(points);
}
}
......
......@@ -141,7 +141,7 @@ Foam::scalar Foam::Module::meshSurfaceMapper::faceMetricInPatch
const pointFieldPMG& points = surfaceEngine_.points();
const point centre = bf.centre(points);
const vector area = bf.normal(points);
const vector area = bf.areaNormal(points);
point projCentre;
scalar dSq;
......@@ -178,7 +178,7 @@ Foam::scalar Foam::Module::meshSurfaceMapper::faceMetricInPatch
projPoints[pI],
projPoints[bf.fcIndex(pI)],
projCentre
).normal();
).areaNormal();
}
return magSqr(centre - projCentre) + mag(mag(projArea) - mag(area));
......
......@@ -179,7 +179,7 @@ void Foam::Module::triSurfaceClassifyEdges::checkOrientation()
{
const labelledTri& tri = surf[triI];
const point c = tri.centre(points);
vector n = tri.normal(points);
vector n = tri.areaNormal(points);
const scalar magN = mag(n);
if (magN < VSMALL)
......
......@@ -353,7 +353,7 @@ void Foam::Module::triSurfaceCurvatureEstimator::calculateSurfaceCurvatures()
continue;
otherLabels[regionI].insert(pI);
normals[regionI] += surface_[triI].normal(points);
normals[regionI] += surface_[triI].areaNormal(points);
}
}
......@@ -389,7 +389,7 @@ void Foam::Module::triSurfaceCurvatureEstimator::calculateSurfaceCurvatures()
forAllIters(normals, nit)
{
nit() /= (Foam::mag(nit()) + VSMALL);
nit().normalise();
}
forAllConstIters(otherLabels, it)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment