diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C index ae4954b8cb4e70e0fa38f1a65a25f4b3b5db81f3..434d94791ca90b0842e9a3e88916e4e33ccf5618 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 b1602c4f20436f75d263be292a081820bde0f97f..f1a8b8a2fd9cd5547ac172c0b4e726384f91850c 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); }