From ec41a4cc7e789523e0a4ec06d2075575480bc123 Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Fri, 13 Mar 2015 09:51:33 +0000
Subject: [PATCH] rhoCentralFoam: Correct handling of single-cell meshes
 Resolves bug-report http://openfoam.org/mantisbt/view.php?id=1548

---
 .../rhoCentralFoam/directionInterpolate.H        | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H b/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H
index 443bab5f1f0..d818f2f0e5f 100644
--- a/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H
+++ b/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H
@@ -27,15 +27,17 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > interpolate
     sf.rename(vf.name() + '_' + dir.name());
 
     // Correct BCs of the positive (outgoing) fluxes
-    if (dir[0] > 0)
+    forAll(sf.boundaryField(), patchi)
     {
-        forAll(sf.boundaryField(), patchi)
+        if
+        (
+           !sf.boundaryField()[patchi].coupled()
+         && sf.boundaryField()[patchi].size()
+         && dir.boundaryField()[patchi][0] > 0
+        )
         {
-            if (!sf.boundaryField()[patchi].coupled())
-            {
-                sf.boundaryField()[patchi] =
-                    vf.boundaryField()[patchi].patchInternalField();
-            }
+            sf.boundaryField()[patchi] =
+                vf.boundaryField()[patchi].patchInternalField();
         }
     }
 
-- 
GitLab