From c1964d7807b9995647989aad2101ad926d2e809a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 10 Aug 2018 15:43:06 +0200 Subject: [PATCH] ENH: distinguish between face areaNormal/unitNormal in the code --- .../mesh/conversion/gmshToFoam/gmshToFoam.C | 10 ++-- .../netgenNeutralToFoam/netgenNeutralToFoam.C | 5 +- .../conformalVoronoiMeshCalcDualMesh.C | 6 +-- .../conformalVoronoiMeshZones.C | 5 +- .../conformationSurfaces.C | 12 ++--- .../manipulation/polyDualMesh/meshDualiser.C | 12 ++--- .../surface/surfaceInflate/surfaceInflate.C | 19 ++++---- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 4 +- .../constraint/cyclic/cyclicPolyPatch.C | 33 ++++++------- .../constraint/oldCyclic/oldCyclicPolyPatch.C | 10 ++-- .../PrimitivePatch/PrimitivePatchMeshData.C | 9 ++-- src/conversion/polyDualMesh/polyDualMesh.C | 10 ++-- src/dynamicMesh/meshCut/cellCuts/cellCuts.C | 16 +++---- .../polyMeshGeometry/polyMeshGeometry.C | 8 ++-- .../polyTopoChange/combineFaces.C | 15 +++--- .../polyTopoChange/hexRef8/hexRef8.C | 20 ++++---- .../enrichedPatch/enrichedPatchCutFaces.C | 3 +- src/fileFormats/stl/STLtriangleI.H | 5 +- .../vtk/read/vtkUnstructuredReader.C | 4 +- .../faMesh/faMeshDemandDrivenData.C | 4 +- .../faMesh/faPatches/faPatch/faPatch.C | 7 ++- .../wallBoundedParticleTemplates.C | 2 +- .../MaxwellianThermal/MaxwellianThermal.C | 3 +- .../MixedDiffuseSpecular.C | 3 +- .../SpecularReflection/SpecularReflection.C | 3 +- src/lagrangian/basic/particle/particle.H | 3 +- src/lagrangian/basic/particle/particleI.H | 8 ++-- .../basic/particle/particleTemplates.C | 3 +- .../ParticleCollector/ParticleCollector.C | 7 +-- .../PairCollision/PairCollision.C | 17 +++---- .../MPPIC/PackingModels/Implicit/Implicit.C | 2 +- .../molecule/molecule/molecule.C | 5 +- src/lagrangian/solidParticle/solidParticle.C | 3 +- .../blockDescriptor/blockDescriptor.C | 3 +- src/mesh/blockMesh/blockMesh/blockMeshCheck.C | 6 +-- .../meshRefinementProblemCells.C | 2 +- .../snappyHexMeshDriver/snappySnapDriver.C | 9 ++-- .../snappySnapDriverFeature.C | 4 +- .../AMIMethod/directAMI/directAMI.C | 6 +-- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C | 8 ++-- .../indexedOctree/treeDataPrimitivePatch.C | 2 +- .../primitiveMeshGeometry.C | 14 +++--- .../triSurfaceMesh/triSurfaceMesh.C | 13 ++---- .../rotatedBoxToCell/rotatedBoxToCell.C | 8 +--- .../setAndNormalToFaceZone.C | 2 +- .../tetOverlapVolumeTemplates.C | 4 +- .../intersectedSurface/intersectedSurface.C | 2 +- .../faceTriangulation/faceTriangulation.C | 32 +++++-------- .../triSurfaceTools/triSurfaceCurvature.C | 46 +++++++++---------- .../distributedTriSurfaceMesh.C | 3 +- .../surface/isoSurface/isoSurfaceCell.C | 4 +- .../surfaceFormats/stl/STLsurfaceFormat.C | 12 ++--- 52 files changed, 200 insertions(+), 256 deletions(-) diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index d0dd7c4a4e..51e9221577 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -188,19 +188,17 @@ label findInternalFace(const primitiveMesh& mesh, const labelList& meshF) bool correctOrientation(const pointField& points, const cellShape& shape) { // Get centre of shape. - point cc(shape.centre(points)); + const point cc(shape.centre(points)); // Get outwards pointing faces. faceList faces(shape.faces()); - forAll(faces, i) + for (const face& f : faces) { - const face& f = faces[i]; - - vector n(f.normal(points)); + const vector areaNorm(f.areaNormal(points)); // Check if vector from any point on face to cc points outwards - if (((points[f[0]] - cc) & n) < 0) + if (((points[f[0]] - cc) & areaNorm) < 0) { // Incorrectly oriented return false; diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index 809f996afc..48b55bd14b 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -225,9 +225,10 @@ int main(int argc, char *argv[]) // Determine orientation of tri v.s. cell centre. point cc(cll.centre(points)); point fc(tri.centre(points)); - vector fn(tri.normal(points)); - if (((fc - cc) & fn) < 0) + const vector areaNorm(tri.areaNormal(points)); + + if (((fc - cc) & areaNorm) < 0) { // Boundary face points inwards. Flip. boundaryFaces[facei].flip(); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index fb9899438a..00bad93cd8 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -1832,11 +1832,11 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches } vector correctNormal = calcSharedPatchNormal(vc1, vc2); - correctNormal /= mag(correctNormal); + correctNormal.normalise(); Info<< " cN " << correctNormal << endl; - vector fN = f.normal(pts); + vector fN = f.areaNormal(pts); if (mag(fN) < SMALL) { @@ -1844,7 +1844,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches continue; } - fN /= mag(fN); + fN.normalise(); Info<< " fN " << fN << endl; if ((fN & correctNormal) > 0) diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C index 1f42b3e429..2a37049388 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C @@ -481,10 +481,9 @@ void Foam::conformalVoronoiMesh::calcFaceZones norm ); - vector fN = faces[facei].normal(mesh.points()); - fN /= mag(fN) + SMALL; + const vector areaNorm = faces[facei].areaNormal(mesh.points()); - if ((norm[0] & fN) < 0) + if ((norm[0] & areaNorm) < 0) { flipMap[facei] = true; } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 0afaae03f3..37db9dab40 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -89,11 +89,9 @@ void Foam::conformationSurfaces::hasBoundedVolume Info<< " Index = " << surfaces_[s] << endl; Info<< " Offset = " << regionOffset_[s] << endl; - forAll(triSurf, sI) + for (const labelledTri& f : triSurf) { - const label patchID = - triSurf[sI].region() - + regionOffset_[s]; + const label patchID = f.region() + regionOffset_[s]; // Don't include baffle surfaces in the calculation if @@ -102,15 +100,15 @@ void Foam::conformationSurfaces::hasBoundedVolume != extendedFeatureEdgeMesh::BOTH ) { - sum += triSurf[sI].normal(surfPts); + sum += f.areaNormal(surfPts); } else { - nBaffles++; + ++nBaffles; } } Info<< " has " << nBaffles << " baffles out of " - << triSurf.size() << " triangles" << endl; + << triSurf.size() << " triangles" << nl; totalTriangles += triSurf.size(); } diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index cef8d2695b..ede9932cd3 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -271,8 +271,8 @@ Foam::label Foam::meshDualiser::addInternalFace ); //pointField dualPoints(meshMod.points()); - //vector n(newFace.normal(dualPoints)); - //n /= mag(n); + //const vector n(newFace.unitNormal(dualPoints)); + // //Pout<< "Generated internal dualFace:" << dualFacei // << " verts:" << newFace // << " points:" << UIndirectList(meshMod.points(), newFace) @@ -298,8 +298,8 @@ Foam::label Foam::meshDualiser::addInternalFace ); //pointField dualPoints(meshMod.points()); - //vector n(newFace.normal(dualPoints)); - //n /= mag(n); + //const vector n(newFace.unitNormal(dualPoints)); + // //Pout<< "Generated internal dualFace:" << dualFacei // << " verts:" << newFace // << " points:" << UIndirectList(meshMod.points(), newFace) @@ -355,8 +355,8 @@ Foam::label Foam::meshDualiser::addBoundaryFace ); //pointField dualPoints(meshMod.points()); - //vector n(newFace.normal(dualPoints)); - //n /= mag(n); + //const vector n(newFace.unitNormal(dualPoints)); + // //Pout<< "Generated boundary dualFace:" << dualFacei // << " verts:" << newFace // << " points:" << UIndirectList(meshMod.points(), newFace) diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C index 83c5d147a0..3d5e9fd906 100644 --- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C +++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C @@ -89,11 +89,8 @@ tmp calcVertexNormals(const triSurface& surf) { // Weighted average of normals of faces attached to the vertex // Weight = fA / (mag(e0)^2 * mag(e1)^2); - tmp tpointNormals - ( - new pointField(surf.nPoints(), Zero) - ); - vectorField& pointNormals = tpointNormals.ref(); + auto tpointNormals = tmp::New(surf.nPoints(), Zero); + auto& pointNormals = tpointNormals.ref(); const pointField& points = surf.points(); const labelListList& pointFaces = surf.pointFaces(); @@ -108,20 +105,20 @@ tmp calcVertexNormals(const triSurface& surf) const label faceI = pFaces[fI]; const triFace& f = surf[faceI]; - vector fN = f.normal(points); + vector areaNorm = f.areaNormal(points); scalar weight = calcVertexNormalWeight ( f, meshPoints[pI], - fN, + areaNorm, points ); - pointNormals[pI] += weight*fN; + pointNormals[pI] += weight * areaNorm; } - pointNormals[pI] /= mag(pointNormals[pI]) + VSMALL; + pointNormals[pI].normalise(); } return tpointNormals; @@ -168,9 +165,9 @@ tmp calcPointNormals // Get average edge normal vector n = Zero; - forAll(eFaces, i) + for (const label facei : eFaces) { - n += s.faceNormals()[eFaces[i]]; + n += s.faceNormals()[facei]; } n /= eFaces.size(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index f66b48555f..c25c9fb4a8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1375,7 +1375,7 @@ bool Foam::polyMesh::pointInCell vector proj = p - faceTri.centre(); - if ((faceTri.normal() & proj) > 0) + if ((faceTri.areaNormal() & proj) > 0) { return false; } @@ -1405,7 +1405,7 @@ bool Foam::polyMesh::pointInCell vector proj = p - faceTri.centre(); - if ((faceTri.normal() & proj) > 0) + if ((faceTri.areaNormal() & proj) > 0) { return false; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 4257571d72..845977c910 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -60,9 +60,9 @@ Foam::label Foam::cyclicPolyPatch::findMaxArea forAll(faces, facei) { - scalar areaSqr = magSqr(faces[facei].normal(points)); + scalar areaSqr = magSqr(faces[facei].areaNormal(points)); - if (areaSqr > maxAreaSqr) + if (maxAreaSqr < areaSqr) { maxAreaSqr = areaSqr; maxI = facei; @@ -81,7 +81,7 @@ void Foam::cyclicPolyPatch::calcTransforms() vectorField half0Areas(half0.size()); forAll(half0, facei) { - half0Areas[facei] = half0[facei].normal(half0.points()); + half0Areas[facei] = half0[facei].areaNormal(half0.points()); } // Half1 @@ -89,7 +89,7 @@ void Foam::cyclicPolyPatch::calcTransforms() vectorField half1Areas(half1.size()); forAll(half1, facei) { - half1Areas[facei] = half1[facei].normal(half1.points()); + half1Areas[facei] = half1[facei].areaNormal(half1.points()); } calcTransforms @@ -260,19 +260,17 @@ void Foam::cyclicPolyPatch::calcTransforms // use calculated normals. vector n0 = findFaceMaxRadius(half0Ctrs); vector n1 = -findFaceMaxRadius(half1Ctrs); - n0 /= mag(n0) + VSMALL; - n1 /= mag(n1) + VSMALL; + n0.normalise(); + n1.normalise(); if (debug) { - scalar theta = radToDeg(acos(n0 & n1)); - Pout<< "cyclicPolyPatch::calcTransforms :" << " patch:" << name() << " Specified rotation :" << " n0:" << n0 << " n1:" << n1 - << " swept angle: " << theta << " [deg]" - << endl; + << " swept angle: " << radToDeg(acos(n0 & n1)) + << " [deg]" << endl; } // Extended tensor from two local coordinate systems calculated @@ -420,18 +418,17 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors { vector n0 = findFaceMaxRadius(half0Ctrs); vector n1 = -findFaceMaxRadius(half1Ctrs); - n0 /= mag(n0) + VSMALL; - n1 /= mag(n1) + VSMALL; + n0.normalise(); + n1.normalise(); if (debug) { - scalar theta = radToDeg(acos(n0 & n1)); - Pout<< "cyclicPolyPatch::getCentresAndAnchors :" << " patch:" << name() << " Specified rotation :" << " n0:" << n0 << " n1:" << n1 - << " swept angle: " << theta << " [deg]" + << " swept angle: " + << radToDeg(acos(n0 & n1)) << " [deg]" << endl; } @@ -499,12 +496,10 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors // Determine the face with max area on both halves. These // two faces are used to determine the transformation tensors label max0I = findMaxArea(pp0.points(), pp0); - vector n0 = pp0[max0I].normal(pp0.points()); - n0 /= mag(n0) + VSMALL; + const vector n0 = pp0[max0I].unitNormal(pp0.points()); label max1I = findMaxArea(pp1.points(), pp1); - vector n1 = pp1[max1I].normal(pp1.points()); - n1 /= mag(n1) + VSMALL; + const vector n1 = pp1[max1I].unitNormal(pp1.points()); if (mag(n0 & n1) < 1-matchTolerance()) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C index 80714b0bb4..d04552e934 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C @@ -92,9 +92,9 @@ Foam::label Foam::oldCyclicPolyPatch::findMaxArea forAll(faces, facei) { - scalar areaSqr = magSqr(faces[facei].normal(points)); + scalar areaSqr = magSqr(faces[facei].areaNormal(points)); - if (areaSqr > maxAreaSqr) + if (maxAreaSqr < areaSqr) { maxAreaSqr = areaSqr; maxI = facei; @@ -359,12 +359,10 @@ void Foam::oldCyclicPolyPatch::getCentresAndAnchors // Determine the face with max area on both halves. These // two faces are used to determine the transformation tensors label max0I = findMaxArea(pp.points(), half0Faces); - vector n0 = half0Faces[max0I].normal(pp.points()); - n0 /= mag(n0) + VSMALL; + const vector n0 = half0Faces[max0I].unitNormal(pp.points()); label max1I = findMaxArea(pp.points(), half1Faces); - vector n1 = half1Faces[max1I].normal(pp.points()); - n1 /= mag(n1) + VSMALL; + const vector n1 = half1Faces[max1I].unitNormal(pp.points()); if (mag(n0 & n1) < 1-matchTolerance()) { diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C index 50e4222be0..a513934b28 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C @@ -281,9 +281,9 @@ calcPointNormals() const const labelList& curFaces = pf[pointi]; - forAll(curFaces, facei) + for (const label facei : curFaces) { - curNormal += faceUnitNormals[curFaces[facei]]; + curNormal += faceUnitNormals[facei]; } curNormal /= mag(curNormal) + VSMALL; @@ -425,7 +425,7 @@ calcFaceAreas() const forAll(n, facei) { - n[facei] = this->operator[](facei).normal(points_); + n[facei] = this->operator[](facei).areaNormal(points_); } if (debug) @@ -472,8 +472,7 @@ calcFaceNormals() const forAll(n, facei) { - n[facei] = this->operator[](facei).normal(points_); - n[facei] /= mag(n[facei]) + VSMALL; + n[facei] = this->operator[](facei).unitNormal(points_); } if (debug) diff --git a/src/conversion/polyDualMesh/polyDualMesh.C b/src/conversion/polyDualMesh/polyDualMesh.C index b0c1f2eaea..9b325c9415 100644 --- a/src/conversion/polyDualMesh/polyDualMesh.C +++ b/src/conversion/polyDualMesh/polyDualMesh.C @@ -1006,8 +1006,9 @@ void Foam::polyDualMesh::calcDual { // Check orientation. const face& f = dynDualFaces.last(); - vector n = f.normal(dualPoints); - if (((mesh.points()[owner] - dualPoints[f[0]]) & n) > 0) + const vector areaNorm = f.areaNormal(dualPoints); + + if (((mesh.points()[owner] - dualPoints[f[0]]) & areaNorm) > 0) { WarningInFunction << " on boundary edge:" << edgeI @@ -1121,8 +1122,9 @@ void Foam::polyDualMesh::calcDual { // Check orientation. const face& f = dynDualFaces.last(); - vector n = f.normal(dualPoints); - if (((mesh.points()[owner] - dualPoints[f[0]]) & n) > 0) + const vector areaNorm = f.areaNormal(dualPoints); + + if (((mesh.points()[owner] - dualPoints[f[0]]) & areaNorm) > 0) { WarningInFunction << " on internal edge:" << edgeI diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C index 1dbbc324ef..edb8209d6f 100644 --- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C +++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C @@ -1363,28 +1363,26 @@ bool Foam::cellCuts::loopAnchorConsistent // Create identity face for ease of calculation of normal etc. face f(identity(loopPts.size())); - vector normal = f.normal(loopPts); - point ctr = f.centre(loopPts); + const vector areaNorm = f.areaNormal(loopPts); + const point ctr = f.centre(loopPts); // Get average position of anchor points. vector avg(Zero); - forAll(anchorPoints, ptI) + for (const label pointi : anchorPoints) { - avg += mesh().points()[anchorPoints[ptI]]; + avg += mesh().points()[pointi]; } avg /= anchorPoints.size(); - if (((avg - ctr) & normal) > 0) + if (((avg - ctr) & areaNorm) > 0) { return true; } - else - { - return false; - } + + return false; } diff --git a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C index 39807dc780..c5419bfc10 100644 --- a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C +++ b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C @@ -1646,7 +1646,7 @@ bool Foam::polyMeshGeometry::checkFaceTwist // p[f[fpI]], // p[f.nextLabel(fpI)], // fc -// ).normal() +// ).areaNormal() // ); // // scalar magTri = mag(triArea); @@ -1721,7 +1721,7 @@ bool Foam::polyMeshGeometry::checkFaceTwist p[f[fpI]], p[f.nextLabel(fpI)], fc - ).normal() + ).areaNormal() ); scalar magTri = mag(triArea); @@ -1826,7 +1826,7 @@ bool Foam::polyMeshGeometry::checkTriangleTwist p[f[fp]], p[f.nextLabel(fp)], fc - ).normal(); + ).areaNormal(); scalar magTri = mag(prevN); @@ -1853,7 +1853,7 @@ bool Foam::polyMeshGeometry::checkTriangleTwist p[f[fp]], p[f.nextLabel(fp)], fc - ).normal() + ).areaNormal() ); scalar magTri = mag(triN); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C index 426866008b..44c3ca0afc 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C @@ -55,9 +55,8 @@ bool Foam::combineFaces::convexFace const face& f ) { - // Get outwards pointing normal of f. - vector n = f.normal(points); - n /= mag(n); + // Get outwards pointing normal of f, only the sign matters. + const vector areaNorm = f.areaNormal(points); // Get edge from f[0] to f[size-1]; vector ePrev(points[f.first()] - points[f.last()]); @@ -78,7 +77,7 @@ bool Foam::combineFaces::convexFace { vector edgeNormal = ePrev ^ e10; - if ((edgeNormal & n) < 0) + if ((edgeNormal & areaNorm) < 0) { // Concave. Check angle. if ((ePrev & e10) < minConcaveCos) @@ -150,12 +149,10 @@ void Foam::combineFaces::regioniseFaces // - small angle if (p0 != -1 && p0 == p1 && !patches[p0].coupled()) { - vector f0Normal = mesh_.faceAreas()[f0]; - f0Normal /= mag(f0Normal); - vector f1Normal = mesh_.faceAreas()[f1]; - f1Normal /= mag(f1Normal); + vector f0Normal = normalised(mesh_.faceAreas()[f0]); + vector f1Normal = normalised(mesh_.faceAreas()[f1]); - if ((f0Normal&f1Normal) > minCos) + if ((f0Normal & f1Normal) > minCos) { Map