From 08655f27484ca53662343ae7287fafa7595b6270 Mon Sep 17 00:00:00 2001 From: laurence <laurence> Date: Tue, 26 Mar 2013 13:09:46 +0000 Subject: [PATCH] BUG: Incorrect point indexing in PatchTools::sortedEdgeFaces. triSurface.sortedEdgeFaces() now calls PatchTools::sortedEdgeFaces instead of using a copy of the same code --- .../PatchTools/PatchToolsSortEdges.C | 7 +- .../triSurface/triSurfaceAddressing.C | 75 +------------------ 2 files changed, 6 insertions(+), 76 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C index ae4954b8cb4..434d94791ca 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,10 +68,9 @@ Foam::PatchTools::sortedEdgeFaces // Get opposite vertex for 0th face const Face& f = localFaces[faceNbs[0]]; - label fp0 = findIndex(f, e[0]); label fp1 = f.fcIndex(fp0); - label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1)); + label vertI = (f[fp1] != e[1] ? f[fp1] : f[f.fcIndex(fp1)]); // Get vector normal both to e2 and to edge from opposite vertex // to edge (will be x-axis of our coordinate system) @@ -92,7 +91,7 @@ Foam::PatchTools::sortedEdgeFaces const Face& f = localFaces[faceNbs[nbI]]; label fp0 = findIndex(f, e[0]); label fp1 = f.fcIndex(fp0); - label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1)); + label vertI = (f[fp1] != e[1] ? f[fp1] : f[f.fcIndex(fp1)]); vector vec = e2 ^ (localPoints[vertI] - edgePt); vec /= mag(vec) + VSMALL; diff --git a/src/triSurface/triSurface/triSurfaceAddressing.C b/src/triSurface/triSurface/triSurfaceAddressing.C index b1602c4f204..f1a8b8a2fd9 100644 --- a/src/triSurface/triSurface/triSurfaceAddressing.C +++ b/src/triSurface/triSurface/triSurfaceAddressing.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,7 +31,7 @@ Description #include "HashTable.H" #include "SortableList.H" #include "transform.H" - +#include "PatchTools.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -46,79 +46,10 @@ void Foam::triSurface::calcSortedEdgeFaces() const const labelListList& eFaces = edgeFaces(); - // create the lists for the various results. (resized on completion) sortedEdgeFacesPtr_ = new labelListList(eFaces.size()); labelListList& sortedEdgeFaces = *sortedEdgeFacesPtr_; - forAll(eFaces, edgeI) - { - const labelList& myFaceNbs = eFaces[edgeI]; - - if (myFaceNbs.size() > 2) - { - // Get point on edge and normalized direction of edge (= e2 base - // of our coordinate system) - const edge& e = edges()[edgeI]; - - const point& edgePt = localPoints()[e.start()]; - - vector e2 = e.vec(localPoints()); - e2 /= mag(e2) + VSMALL; - - - // Get opposite vertex for 0th face - const labelledTri& f = localFaces()[myFaceNbs[0]]; - label fp0 = findIndex(f, e[0]); - label fp1 = f.fcIndex(fp0); - label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1)); - - // Get vector normal both to e2 and to edge from opposite vertex - // to edge (will be x-axis of our coordinate system) - vector e0 = e2 ^ (localPoints()[vertI] - edgePt); - e0 /= mag(e0) + VSMALL; - - // Get y-axis of coordinate system - vector e1 = e2 ^ e0; - - - SortableList<scalar> faceAngles(myFaceNbs.size()); - - // e0 is reference so angle is 0 - faceAngles[0] = 0; - - for (label nbI = 1; nbI < myFaceNbs.size(); nbI++) - { - // Get opposite vertex - const labelledTri& f = localFaces()[myFaceNbs[nbI]]; - label fp0 = findIndex(f, e[0]); - label fp1 = f.fcIndex(fp0); - label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1)); - - vector vec = e2 ^ (localPoints()[vertI] - edgePt); - vec /= mag(vec) + VSMALL; - - faceAngles[nbI] = pseudoAngle - ( - e0, - e1, - vec - ); - } - - faceAngles.sort(); - - sortedEdgeFaces[edgeI] = UIndirectList<label> - ( - myFaceNbs, - faceAngles.indices() - ); - } - else - { - // No need to sort. Just copy. - sortedEdgeFaces[edgeI] = myFaceNbs; - } - } + sortedEdgeFaces = PatchTools::sortedEdgeFaces(*this); } -- GitLab