diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index 5a9680ea48..e7b8c5e3e9 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -28,7 +28,7 @@ License #include "triPointRef.H" #include "mathematicalConstants.H" #include "Swap.H" -#include "const_circulator.H" +#include "ConstCirculator.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -69,7 +69,7 @@ Foam::scalar Foam::face::edgeCos label leftEdgeI = left(index); label rightEdgeI = right(index); - // note negate on left edge to get correct left-pointing edge. + // Note negate on left edge to get correct left-pointing edge. return -(edges[leftEdgeI] & edges[rightEdgeI]); } @@ -237,7 +237,7 @@ Foam::label Foam::face::split minIndex = index; } - // go to next candidate + // Go to next candidate index = fcIndex(index); } @@ -254,7 +254,7 @@ Foam::label Foam::face::split } else { - // folded around + // Folded around diff = minIndex + size() - startIndex; } @@ -300,10 +300,6 @@ Foam::face::face(const triFace& f) // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -// return -// 0: no match -// +1: identical -// -1: same face, but different orientation int Foam::face::compare(const face& a, const face& b) { // Basic rule: we assume that the sequence of labels in each list @@ -330,8 +326,8 @@ int Foam::face::compare(const face& a, const face& b) } } - const_circulator aCirc(a); - const_circulator bCirc(b); + ConstCirculator aCirc(a); + ConstCirculator bCirc(b); // Rotate face b until its element matches the starting element of face a. do @@ -406,6 +402,49 @@ int Foam::face::compare(const face& a, const face& b) } +bool Foam::face::sameVertices(const face& a, const face& b) +{ + label sizeA = a.size(); + label sizeB = b.size(); + + // Trivial reject: faces are different size + if (sizeA != sizeB) + { + return false; + } + // Check faces with a single vertex + else if (sizeA == 1) + { + if (a[0] == b[0]) + { + return true; + } + else + { + return false; + } + } + + forAll(a, i) + { + bool found = false; + + forAll(b, j) + { + if (a[i] == b[j]) + { + found = true; + break; + } + } + + if (!found) return false; + } + + return true; +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::face::collapse() @@ -572,7 +611,7 @@ Foam::vector Foam::face::normal(const pointField& p) const Foam::face Foam::face::reverseFace() const { - // reverse the label list and return + // Reverse the label list and return // The starting points of the original and reverse face are identical. const labelList& f = *this; @@ -731,7 +770,7 @@ Foam::edgeList Foam::face::edges() const e[pointI] = edge(points[pointI], points[pointI + 1]); } - // add last edge + // Add last edge e.last() = edge(points.last(), points[0]); return e; @@ -746,37 +785,37 @@ int Foam::face::edgeDirection(const edge& e) const { if (operator[](rcIndex(i)) == e.end()) { - // reverse direction + // Reverse direction return -1; } else if (operator[](fcIndex(i)) == e.end()) { - // forward direction + // Forward direction return 1; } - // no match + // No match return 0; } else if (operator[](i) == e.end()) { if (operator[](rcIndex(i)) == e.start()) { - // forward direction + // Forward direction return 1; } else if (operator[](fcIndex(i)) == e.start()) { - // reverse direction + // Reverse direction return -1; } - // no match + // No match return 0; } } - // not found + // Not found return 0; } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 6648e4ad2a..afb9b45496 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -371,6 +371,9 @@ public: // -1: same face, but different orientation static int compare(const face&, const face&); + //- Return true if the faces have the same vertices + static bool sameVertices(const face&, const face&); + // Friend Operators diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index ae86b476c6..11d60fec9f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -233,6 +233,7 @@ private: cellList& cells ); + // Geometry checks //- Check non-orthogonality diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index b54c0fc429..9a3e69faf5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -21,9 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - Create polyMesh from cell and patch shapes - \*---------------------------------------------------------------------------*/ #include "polyMesh.H" @@ -102,7 +99,7 @@ Foam::labelList Foam::polyMesh::facePatchFaceCells forAll(cellFaces, cellFace) { - if (cellFaces[cellFace] == curFace) + if (face::sameVertices(cellFaces[cellFace], curFace)) { // Found the cell corresponding to this face FaceCells[fI] = facePointCells[cellI]; @@ -175,7 +172,7 @@ void Foam::polyMesh::setTopology // Initialise number of faces to 0 nFaces = 0; - // set reference to point-cell addressing + // Set reference to point-cell addressing labelListList PointCells = cellShapePointCells(cellsAsShapes); bool found = false; @@ -340,7 +337,7 @@ void Foam::polyMesh::setTopology forAll(facesOfCellInside, cellFaceI) { - if (facesOfCellInside[cellFaceI] == curFace) + if (face::sameVertices(facesOfCellInside[cellFaceI], curFace)) { if (cells[cellInside][cellFaceI] >= 0) { @@ -385,7 +382,7 @@ void Foam::polyMesh::setTopology << abort(FatalError); } - // increment the counter of faces + // Increment the counter of faces nFaces++; } @@ -501,7 +498,7 @@ Foam::polyMesh::polyMesh IOobject::AUTO_WRITE ), *this, - boundaryFaces.size() + 1 // add room for a default patch + boundaryFaces.size() + 1 // Add room for a default patch ), bounds_(points_, syncPar), comm_(UPstream::worldComm), @@ -587,7 +584,7 @@ Foam::polyMesh::polyMesh // completed, as they hold a subList of the face list forAll(boundaryFaces, patchI) { - // add the patch to the list + // Add the patch to the list boundary_.set ( patchI, @@ -785,7 +782,7 @@ Foam::polyMesh::polyMesh IOobject::AUTO_WRITE ), *this, - boundaryFaces.size() + 1 // add room for a default patch + boundaryFaces.size() + 1 // Add room for a default patch ), bounds_(points_, syncPar), comm_(UPstream::worldComm), @@ -876,7 +873,7 @@ Foam::polyMesh::polyMesh patchDict.set("nFaces", patchSizes[patchI]); patchDict.set("startFace", patchStarts[patchI]); - // add the patch to the list + // Add the patch to the list boundary_.set ( patchI,