diff --git a/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C b/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C
index 7ec070bef00cf97fb365ccc29fee1df47b6123c9..df7aa17c08f7a9d2ae643ecbeb8e9abcc7eb6d70 100644
--- a/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C
+++ b/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C
@@ -513,17 +513,17 @@ void Foam::fluxSummary::initialiseCellZoneAndDirection
             returnReduce(patch.nEdges(), sumOp<label>())
         );
 
-        label nCells = 0;
-        forAll(allFaceInfo, faceI)
+        if (debug)
         {
-            if (allFaceInfo[faceI].region() == regionI)
+            label nCells = 0;
+            forAll(allFaceInfo, faceI)
             {
-                nCells++;
+                if (allFaceInfo[faceI].region() == regionI)
+                {
+                    nCells++;
+                }
             }
-        }
 
-        if (debug)
-        {
             Info<< "*** region:" << regionI
                 << "  found:" << returnReduce(nCells, sumOp<label>())
                 << " faces" << endl;