From a129d6a146cd57980225d80740c86914909b0f9e Mon Sep 17 00:00:00 2001
From: Andrew Heather <a.heather@opencfd.co.uk>
Date: Fri, 8 Sep 2017 17:22:49 +0100
Subject: [PATCH] ENH: isoCutCell - improved robustness.  Patch provided by
 Johan Roenby - see #582

---
 .../isoAdvection/isoCutCell/isoCutCell.C        | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C
index 33563d728d8..30aaa5f72b7 100644
--- a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C
+++ b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C
@@ -361,6 +361,23 @@ Foam::label Foam::isoCutCell::calcSubCell
         // Cell cut at least at one face
         cellStatus_ = 0;
         calcIsoFaceCentreAndArea();
+
+        // In the rare but occuring cases where a cell is only touched at a
+        // point or a line the isoFaceArea_ will have zero length and here the
+        // cell should be treated as either completely empty or full.
+        if (mag(isoFaceArea_) < 10*SMALL)
+        {
+            if (fullySubFaces_.empty())
+            {
+                // Cell fully above isosurface
+                cellStatus_ = 1;
+            }
+            else
+            {
+                // Cell fully below isosurface
+                cellStatus_ = -1;
+            }
+        }
     }
     else if (fullySubFaces_.empty())
     {
-- 
GitLab