From c334f75873d5b687a84fe3cfcee0300c10d78e4a Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 23 May 2011 12:24:13 +0100
Subject: [PATCH] BUG: octree.C : tree building criterion needs to look at any
 change in tree.

---
 src/meshTools/octree/octree.C | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/meshTools/octree/octree.C b/src/meshTools/octree/octree.C
index 86c2ffc62a1..8731f0ef1ff 100644
--- a/src/meshTools/octree/octree.C
+++ b/src/meshTools/octree/octree.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -149,6 +149,7 @@ Foam::octree<Type>::octree
     //  - has some guaranteed maximum size (maxShapeRatio)
 
     label oldNLeaves = -1;  // make test below pass first time.
+    label oldNNodes  = -1;
     deepestLevel_ = 1;
     while
     (
@@ -169,11 +170,11 @@ Foam::octree<Type>::octree
             break;
         }
 
-        if (oldNLeaves == nLeaves())
+        if ((oldNLeaves == nLeaves()) && (oldNNodes == nNodes()))
         {
             if (debug & 1)
             {
-                Pout<< "octree : exiting since nLeaves does not change"
+                Pout<< "octree : exiting since nLeaves and nNodes do not change"
                     << endl;
             }
             break;
@@ -185,6 +186,7 @@ Foam::octree<Type>::octree
         }
 
         oldNLeaves = nLeaves();
+        oldNNodes  = nNodes();
 
         topNode_->redistribute
         (
-- 
GitLab