]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorcvw <cvw>
Wed, 28 Mar 2012 08:01:12 +0000 (08:01 +0000)
committercvw <cvw>
Wed, 28 Mar 2012 08:01:12 +0000 (08:01 +0000)
src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx
src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.cxx
src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx

index 11e8841fc407cc7d62ca11dafeda5a0108dcad61..dda41050b5aa7ff96e613c6eadaa1bc5a3b5f48d 100644 (file)
@@ -55,7 +55,7 @@ void METISGraph::partGraph(int ndomain,
   if (MyGlobals::_Verbose>10)
     std::cout << "proc " << MyGlobals::_Rank << " : METISGraph::partGraph" << std::endl;
   
-  // number of graph vertices
+  //number of graph vertices
   int n=_graph->getNumberOf();
   //graph
   int * xadj=const_cast<int*>(_graph->getIndex());
@@ -78,17 +78,17 @@ void METISGraph::partGraph(int ndomain,
     seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33
   */
   int options[4]={0,0,0,0};
-  // output parameters
-  int edgecut;
-  int* partition=new int[n];
-
 #if !defined(MED_ENABLE_METIS)
   throw INTERP_KERNEL::Exception("METISGraph::partGraph : METIS is not available. Check your products, please.");
 #else
+  //output parameters
+  int edgecut;
+  int* partition=new int[n];
+
   if(nparts >1)
     {
       if (MyGlobals::_Verbose>10) 
-        std::cout << "METISGraph::partGraph METIS_PartGraph METIS_PartGraph(RecursiveOrKway) newww" << std::endl;
+        std::cout << "METISGraph::partGraph METIS_PartGraph METIS_PartGraph(RecursiveOrKway)" << std::endl;
       if (options_string != "k")
         METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag,
                                   &base, &nparts, options, &edgecut, partition);
index 719690af4842f3d43efdc789f06524e48759445c..5046ac4edc2efb5eec56e6b70ab0a4fcc0eacd7a 100644 (file)
@@ -80,12 +80,11 @@ void METISGraph::partGraph(int ndomain,
   int options[4]={0,0,0,0};
   // output parameters
   int edgecut;
-  int* partition=new int[n];
-
 #if !defined(MED_ENABLE_PARMETIS)
   throw INTERP_KERNEL::Exception("METISGraph::partGraph : PARMETIS is not available. Check your products, please.");
 #else
-
+  int* partition=new int[n];
+  
   if (MyGlobals::_Verbose>10) 
     std::cout << "proc " << MyGlobals::_Rank << " : METISGraph::partGraph ParMETIS_PartKway new" << std::endl;
   int * vtxdist=parallelizer->getProcVtxdist();
index 7daa646526a47e31ac9da8f4ceb58e6fbeed8b1d..99b542707de05efaccd0d975657ddcb1a7ef0c29 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "MEDPARTITIONER_Graph.hxx"
 #include "MEDPARTITIONER_ScotchGraph.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
 
 #include <cstdio>
 
@@ -46,51 +47,53 @@ SCOTCHGraph::~SCOTCHGraph()
 
 void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* sel)
 {
-#ifdef MED_ENABLE_SCOTCH
-  // number of graph vertices
+  if (MyGlobals::_Verbose>10)
+    std::cout << "proc " << MyGlobals::_Rank << " : SCOTCHGraph::partGraph" << std::endl;
+  
+  //number of graph vertices
   int n = _graph->getNumberOf();
-
   //graph
   int * xadj=const_cast<int*>(_graph->getIndex());
-  int * adjncy = const_cast<int*>(_graph->getValue());
-
+  int * adjncy=const_cast<int*>(_graph->getValue());
   //ndomain
-  int nparts = ndomain;
+  int nparts=ndomain;
 
-  // output parameters
+#if !defined(MED_ENABLE_SCOTCH)
+  throw INTERP_KERNEL::Exception("SCOTCHGraph::partGraph : SCOTCH is not available. Check your products, please.");
+#else
+  //output parameters
   int* partition = new int[n+1];
-
+  
   SCOTCH_Graph scotch_graph;
-
   SCOTCH_graphInit(&scotch_graph);
-
-
   SCOTCH_graphBuild(&scotch_graph,
-                    1, //first indice 1
-                    n, // nb of graph nodes
+                    0, //base first indice 0
+                    n, //nb of graph nodes
                     xadj,
                     0,
                     _cell_weight, //graph vertices loads
                     0,
-                    xadj[n], // number of edges
+                    xadj[n], //number of edges
                     adjncy,
                     _edge_weight);
-
-  SCOTCH_Strat scotch_strategy;           
+  SCOTCH_Strat scotch_strategy;
   SCOTCH_stratInit(&scotch_strategy);
-
+  
   //!user-defined options for the strategy
   if (options_string!="")
     SCOTCH_stratGraphMap(&scotch_strategy,options_string.c_str());
 
-
-  if (nparts>1)           
-    SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition);
-  else
-    // partition for 1 subdomain
+  if (nparts>1)
+    {
+      if (MyGlobals::_Verbose>10) std::cout << "SCOTCHGraph::graphPart SCOTCH_graphPart" << std::endl;
+      SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition);
+    }
+  else  //partition for 1 subdomain
+    {
     for (int i=0; i<n+1; i++)
       partition[i]=0;
-
+    }
+  
   SCOTCH_stratExit(&scotch_strategy);
   SCOTCH_graphExit(&scotch_graph);
 
@@ -102,13 +105,11 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para
       index[i+1]=index[i]+1;
       value[i]=partition[i];
     }
-
+  delete [] partition;
+  
   //creating a skylinearray with no copy of the index and partition array
-  // the fifth argument true specifies that only the pointers are passed 
+  //the fifth argument true specifies that only the pointers are passed 
   //to the object
-  
   _partition = new MEDPARTITIONER::SkyLineArray(index,value);
-#else
-  throw INTERP_KERNEL::Exception("SCOTCH is not available. Check your products, please.");
 #endif
 }