From 34a9d9de7354d6b10acc92ad938a9f6fe0bd7136 Mon Sep 17 00:00:00 2001
From: Van Dung Nguyen <vdg.nguyen@gmail.com>
Date: Fri, 30 Oct 2020 13:14:56 +0100
Subject: [PATCH] depth must be move

---
 NonLinearSolver/modelReduction/Tree.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/NonLinearSolver/modelReduction/Tree.cpp b/NonLinearSolver/modelReduction/Tree.cpp
index 953615dbc..1c7cf9c7a 100644
--- a/NonLinearSolver/modelReduction/Tree.cpp
+++ b/NonLinearSolver/modelReduction/Tree.cpp
@@ -1042,6 +1042,18 @@ bool Tree::removeZeroLeaves(double tol, bool iteration)
         otherChild->parent = parent->parent;
         otherChild->childOrder = parent->childOrder;
         grandParent->childs[parent->childOrder] = otherChild;
+        
+        // decrease all associated nodes by 1
+        std::vector<TreeNode*> allAssociatedNodesToChild;
+        getRefToAssociatedNodes(otherChild,allAssociatedNodesToChild);
+        for (int j=0; j< allAssociatedNodesToChild.size(); j++)
+        {
+          std::vector<int> loc;
+          getMaxLocationByDepth(loc);
+          allAssociatedNodesToChild[j]->depth--;
+          allAssociatedNodesToChild[j]->location=loc[allAssociatedNodesToChild[j]->depth]+1;
+        };
+        
         Msg::Info("child weight = %e otherChild weight = %e parent weight = %e",leaf->af->getVal(leaf->weight),otherChild->af->getVal(otherChild->weight),parent->weight);
       }
       else if (parent->childs.size() > 2)
-- 
GitLab