From cb2a84aa59db0caf257615459b775608d69dad50 Mon Sep 17 00:00:00 2001
From: Van Dung Nguyen <vdg.nguyen@gmail.com>
Date: Fri, 30 Oct 2020 10:58:15 +0100
Subject: [PATCH] add new function

---
 .../modelReduction/DeepMaterialNetworks.cpp      |  4 ++--
 NonLinearSolver/modelReduction/Tree.cpp          | 16 ++++++++++++++++
 NonLinearSolver/modelReduction/Tree.h            |  1 +
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp b/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp
index 27d6a83bf..63577897c 100644
--- a/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp
+++ b/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp
@@ -2609,7 +2609,7 @@ void DeepMaterialNetwork::initializeOnlineEvaluation()
     _T->getBackTrackingPath(_leaves[i],path);
     _backTrackingMap[_leaves[i]] = path;
   };
-  printf("size of void leaves = %d\n",_voidLeaves.size());
+  printf("size of void leaves = %ld\n",_voidLeaves.size());
   
   // leaf map
   printf("creating associated leaves map\n");
@@ -2700,7 +2700,7 @@ void DeepMaterialNetwork::initializeOnlineEvaluation()
     }
   };
   
-  printf("size of void _notUnknownRegularNodes = %d\n",_notUnknownRegularNodes.size());
+  printf("size of void _notUnknownRegularNodes = %ld\n",_notUnknownRegularNodes.size());
 };
 
 void DeepMaterialNetwork::getKeys(const TreeNode* node, std::vector<Dof>& keys) const
diff --git a/NonLinearSolver/modelReduction/Tree.cpp b/NonLinearSolver/modelReduction/Tree.cpp
index 3858f487a..fa1b4f614 100644
--- a/NonLinearSolver/modelReduction/Tree.cpp
+++ b/NonLinearSolver/modelReduction/Tree.cpp
@@ -1485,6 +1485,22 @@ void Tree::printPhaseFraction() const
   allPhase.print("all phase fraction:"); 
 };
 
+void Tree::printLeafFraction() const
+{
+  nodeContainer allLeaves;
+  getAllLeaves(allLeaves);
+  double total = getNonNegativeWeight(_root);
+  printf("print fraction at leaf:\n");
+  int ord=0;
+  for (int i=0; i< allLeaves.size(); i++)
+  {
+    const TreeNode* leaf = allLeaves[i];
+    printf("loc %d: %d %d, fraction = %.5e\n",ord,leaf->depth,leaf->location,getNonNegativeWeight(leaf)/total);
+    ord++;
+  }
+  printf("done printing:\n"); 
+};
+
 void Tree::printTree() const
 {
   printf("Tree print \n");
diff --git a/NonLinearSolver/modelReduction/Tree.h b/NonLinearSolver/modelReduction/Tree.h
index dfaff94d7..3087d7297 100644
--- a/NonLinearSolver/modelReduction/Tree.h
+++ b/NonLinearSolver/modelReduction/Tree.h
@@ -74,6 +74,7 @@ class Tree
     int getNumberOfNodes() const;
     double getPhaseFraction(int i) const;
     void printPhaseFraction() const;
+    void printLeafFraction() const;
     void printNodeFraction() const;
     
     bool removeLeavesWithZeroContribution(double tol=1e-6);
-- 
GitLab