From 01813d03392838b5532172ef0244fd2967ca7887 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 20 Mar 2014 16:50:42 +0000
Subject: [PATCH] BUG: refinementHistory: access outside range

---
 .../polyTopoChange/refinementHistory.C        | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
index 1c7d63e6845..8e9e844cb5b 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -649,22 +649,20 @@ void Foam::refinementHistory::countProc
         // Increment parent if whole splitCell moves to same processor
         if (splitCellNum[index] == 8)
         {
-            Pout<< "Moving " << splitCellNum[index]
-                << " cells originating from cell " << index
-                << " from processor " << Pstream::myProcNo()
-                << " to processor " << splitCellProc[index]
-                << endl;
+            if (debug)
+            {
+                Pout<< "Moving " << splitCellNum[index]
+                    << " cells originating from cell " << index
+                    << " from processor " << Pstream::myProcNo()
+                    << " to processor " << splitCellProc[index]
+                    << endl;
+            }
 
             label parent = splitCells_[index].parent_;
 
             if (parent >= 0)
             {
-                string oldPrefix = Pout.prefix();
-                Pout.prefix() = "  " + oldPrefix;
-
                 countProc(parent, newProcNo, splitCellProc, splitCellNum);
-
-                Pout.prefix() = oldPrefix;
             }
         }
     }
@@ -924,7 +922,10 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
 
         forAll(newVisibleCells, i)
         {
-            visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
+            if (newVisibleCells[i] >= 0)
+            {
+                visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
+            }
         }
     }
     splitCells_.shrink();
-- 
GitLab