From f758f27fdd2aaea3890494a1e898a45f8d4499e9 Mon Sep 17 00:00:00 2001
From: sergio <s.ferraris@opencfd.co.uk>
Date: Tue, 22 Jun 2021 11:07:26 -0700
Subject: [PATCH] BUG: Managing topoBitSet as source in haloToCell. See issue
 #2137

---
 .../sets/cellSources/haloToCell/haloToCell.C      | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/meshTools/sets/cellSources/haloToCell/haloToCell.C b/src/meshTools/sets/cellSources/haloToCell/haloToCell.C
index c5bc2ff9eb1..d5b98bf4477 100644
--- a/src/meshTools/sets/cellSources/haloToCell/haloToCell.C
+++ b/src/meshTools/sets/cellSources/haloToCell/haloToCell.C
@@ -28,6 +28,7 @@ License
 #include "haloToCell.H"
 #include "polyMesh.H"
 #include "cellSet.H"
+#include "topoBitSet.H"
 #include "syncTools.H"
 #include "addToRunTimeSelectionTable.H"
 
@@ -78,15 +79,21 @@ void Foam::haloToCell::combine(topoSet& set, const bool add) const
     const labelList& faceOwn = mesh_.faceOwner();
     const labelList& faceNei = mesh_.faceNeighbour();
 
-
     // The starting set of cells
     bitSet current(cells.size());
 
-    for (const label celli : set)
+    if (isA<topoBitSet>(set))
     {
-        current.set(celli);
+        current |= refCast<const topoBitSet>(set).addressing();
     }
-
+    else 
+    {
+        for (const label celli : set)
+        {
+            current.set(celli);
+        }
+    }
+    
     // The perimeter faces of the cell set
     bitSet outsideFaces(mesh_.nFaces());
 
-- 
GitLab