Salome HOME
Merge branch 'omu/py2yacsgui'
[modules/yacs.git] / src / engine / Bloc.cxx
index e7fa7f74cb26696ff6ec0f535eb9ca069f5cfe27..6fc3240abfa88716d1fb14d9d23e3654f04aaa64 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,9 @@
 #include "OutputDataStreamPort.hxx"
 #include "ElementaryNode.hxx"
 #include "Visitor.hxx"
+#include "ForkBlocPoint.hxx"
 #include "SetOfPoints.hxx"
+#include "PlayGround.hxx"
 
 #include <queue>
 #include <iostream>
@@ -452,33 +454,55 @@ void Bloc::accept(Visitor* visitor)
  * for all concurrent branches in \a this.
  */
 int Bloc::getMaxLevelOfParallelism() const
+{
+  std::list< AbstractPoint * > pts(analyzeParallelism());
+  ForkBlocPoint fbp(pts,NULL);
+  return fbp.getMaxLevelOfParallelism();
+}
+
+std::list< AbstractPoint * > Bloc::analyzeParallelism() const
 {
   std::vector< std::list<Node *> > r(splitIntoIndependantGraph());
-  int ret(0);
+  std::list< AbstractPoint * > pts;
   for(std::vector< std::list<Node *> >::const_iterator it=r.begin();it!=r.end();it++)
     {
       SetOfPoints sop(*it);
       sop.simplify();
-      ret+=sop.getMaxLevelOfParallelism();
+      pts.push_back(sop.getUniqueAndReleaseIt());
     }
-  return ret;
+  return pts;
 }
 
-/*!
- * Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method).
- * _fwLinks is a map with a Node* as key and a set<Node*> as value. The set gives
- * all nodes that are forwardly connected to the key node 
- * _bwLinks is a map for backward dependencies
- * The method is : for all CF link (n1->n2) 
- * add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1]
- * add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2]
- * For useless links
- * If a node is already in a forward dependency when adding and the direct link
- * already exists so it's a useless link (see the code !)
- */
-void Bloc::performCFComputations(LinkInfo& info) const
+double Bloc::getWeightRegardingDPL() const
+{
+  std::list< AbstractPoint * > pts(analyzeParallelism());
+  ForkBlocPoint fbp(pts,NULL);
+  return fbp.getWeightRegardingDPL();
+}
+
+void Bloc::removeRecursivelyRedundantCL()
+{
+  StaticDefinedComposedNode::removeRecursivelyRedundantCL();
+  LinkInfo info(I_CF_USELESS);
+  initComputation();
+  performCFComputationsOnlyOneLevel(info);
+  std::set< std::pair<Node *, Node *> > linksToKill(info.getInfoUselessLinks());
+  for(std::set< std::pair<Node *, Node *> >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++)
+    edRemoveCFLink((*it).first,(*it).second);
+  destructCFComputations(info);
+}
+
+void Bloc::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  if(!pd)
+    throw Exception("Bloc::partitionRegardingDPL : NULL pointer !");
+  std::list< AbstractPoint * > pts(analyzeParallelism());
+  ForkBlocPoint fbp(pts,NULL);
+  fbp.partitionRegardingDPL(pd,zeMap);
+}
+
+void Bloc::performCFComputationsOnlyOneLevel(LinkInfo& info) const
 {
-  StaticDefinedComposedNode::performCFComputations(info);
   delete _fwLinks;//Normally useless
   delete _bwLinks;//Normally useless
   _fwLinks=new map<Node *,set<Node *> >;
@@ -549,6 +573,24 @@ void Bloc::performCFComputations(LinkInfo& info) const
     }
 }
 
+/*!
+ * Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method).
+ * _fwLinks is a map with a Node* as key and a set<Node*> as value. The set gives
+ * all nodes that are forwardly connected to the key node 
+ * _bwLinks is a map for backward dependencies
+ * The method is : for all CF link (n1->n2) 
+ * add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1]
+ * add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2]
+ * For useless links
+ * If a node is already in a forward dependency when adding and the direct link
+ * already exists so it's a useless link (see the code !)
+ */
+void Bloc::performCFComputations(LinkInfo& info) const
+{
+  StaticDefinedComposedNode::performCFComputations(info);
+  performCFComputationsOnlyOneLevel(info);
+}
+
 void Bloc::destructCFComputations(LinkInfo& info) const
 {
   StaticDefinedComposedNode::destructCFComputations(info);