From eed875e1fa33624cdc521b4e1ff39f065aa5ae62 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Fri, 21 Oct 2016 12:08:18 +0100
Subject: [PATCH] primitiveMeshEdges: Added support for edges with duplicate
 vertices

Patch contributed by Mattijs Janssens
Resolves bug-report http://bugs.openfoam.org/view.php?id=2301
---
 src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
index 72a27c7bc38..01c7ec471c6 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
@@ -56,7 +56,14 @@ Foam::label Foam::primitiveMesh::getEdge
     // Make new edge.
     label edgeI = es.size();
     pe[pointi].append(edgeI);
-    pe[nextPointi].append(edgeI);
+
+    if (nextPointi != pointi)
+    {
+        // Very occasionally (e.g. blockMesh) a face can have duplicate
+        // vertices. Make sure we register pointEdges only once.
+        pe[nextPointi].append(edgeI);
+    }
+
     if (pointi < nextPointi)
     {
         es.append(edge(pointi, nextPointi));
-- 
GitLab