From abe5d284f2c6b2c2ee3b9ae181b8c3217c246013 Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Thu, 4 Sep 2014 19:10:31 +0200
Subject: [PATCH] skip internal elements also in face search

---
 MeshGeoToolsLib/BoundaryElementsAlongSurface.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/MeshGeoToolsLib/BoundaryElementsAlongSurface.cpp b/MeshGeoToolsLib/BoundaryElementsAlongSurface.cpp
index 2c8e4511aab..db786415391 100644
--- a/MeshGeoToolsLib/BoundaryElementsAlongSurface.cpp
+++ b/MeshGeoToolsLib/BoundaryElementsAlongSurface.cpp
@@ -29,6 +29,17 @@ BoundaryElementsAlongSurface::BoundaryElementsAlongSurface(MeshLib::Mesh const&
 	// get a list of edges made of the nodes
 	for (auto ele_id : ele_ids_near_sfc) {
 		auto* e = _mesh.getElement(ele_id);
+		// skip internal elements
+		bool isOuterElement = false;
+		for (unsigned i=0; i<e->getNNeighbors(); i++) {
+			if (!e->getNeighbor(i)) {
+				isOuterElement = true;
+				break;
+			}
+		}
+		if (!isOuterElement)
+			continue;
+		// find faces on surface
 		for (unsigned i=0; i<e->getNEdges(); i++) {
 			auto* edge = e->getEdge(i);
 			// check
-- 
GitLab