]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
replace scotch by ptscotch
authorMaximilien Siavelis <maximilien.siavelis@necs.fr>
Thu, 28 Sep 2017 09:27:55 +0000 (11:27 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 17 Oct 2017 07:24:09 +0000 (09:24 +0200)
CMakeLists.txt
src/MEDPartitioner/CMakeLists.txt
src/MEDPartitioner/MEDPARTITIONER_Graph.hxx
src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx
src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.hxx
src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx
src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx
src/MEDPartitioner_Swig/MEDPartitionerCommon.i

index 25e1d9fa60d1825f4609371e466b0ed6a8dca3ee..f3c7116efd9457143cf859ee96912a946b51cfa4 100644 (file)
@@ -128,6 +128,9 @@ IF(MEDCOUPLING_BUILD_TESTS)
   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
 ENDIF(MEDCOUPLING_BUILD_TESTS)
 
+FIND_PACKAGE(SalomeMPI REQUIRED)
+ADD_DEFINITIONS("-DHAVE_MPI")
+
 IF(MEDCOUPLING_USE_MPI)
   FIND_PACKAGE(SalomeMPI REQUIRED)
   ADD_DEFINITIONS("-DHAVE_MPI")
index 981fc949a665b79b15db1f88c9cdcf87bc0c366c..8ea88ff170afe69b222a6838b126e81d95614914 100644 (file)
@@ -56,6 +56,9 @@ IF(MEDCOUPLING_PARTITIONER_PARMETIS)
   INCLUDE_DIRECTORIES(${PARMETIS_INCLUDE_DIRS})
 ENDIF(MEDCOUPLING_PARTITIONER_PARMETIS)
 
+ADD_DEFINITIONS(${MPI_DEFINITIONS})
+INCLUDE_DIRECTORIES(${MPI_INCLUDE_DIRS})
+
 IF(MEDCOUPLING_USE_MPI)
   ADD_DEFINITIONS(${MPI_DEFINITIONS})
   INCLUDE_DIRECTORIES(${MPI_INCLUDE_DIRS})
@@ -125,6 +128,10 @@ IF(MEDCOUPLING_PARTITIONER_SCOTCH)
   SET(medpartitionercpp_LDFLAGS ${medpartitionercpp_LDFLAGS} ${SCOTCH_LIBRARIES})
 ENDIF(MEDCOUPLING_PARTITIONER_SCOTCH)
 
+SET(medpartitionercpp_SOURCES ${medpartitionercpp_SOURCES} MEDPARTITIONER_UtilsPara.cxx MEDPARTITIONER_JointFinder.cxx)
+SET(medpartitionercpp_LDFLAGS ${medpartitionercpp_LDFLAGS} ${MPI_LIBRARIES})
+
+
 IF(${MEDCOUPLING_USE_MPI})
   SET(medpartitionercpp_SOURCES ${medpartitionercpp_SOURCES} MEDPARTITIONER_UtilsPara.cxx MEDPARTITIONER_JointFinder.cxx)
   ADD_EXECUTABLE(medpartitioner_para medpartitioner_para.cxx)
index abf92731014373ad4662414186118261991bfee4..63faaa18ff246bacec36c04bf66da909c893876c 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __MEDPARTITIONER_GRAPH_HXX__
 #define __MEDPARTITIONER_GRAPH_HXX__
 
+#include "MEDCouplingMemArray.hxx"
 #include "MEDPARTITIONER.hxx"
 #include "MCAuto.hxx"
 
index 6ea40a0e6a931d31e57ba4008dbe8fae12c3b138..6f14e85ab0cc494f60fdfd2e1330584e7e60b362 100644 (file)
@@ -137,7 +137,7 @@ MEDCoupling::MEDFileData* MEDPARTITIONER::MEDPartitioner::getMEDFileData()
   return _output_collection->retrieveDriver()->getMEDFileData();
 }
 
-MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight)
+MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight, DataArrayInt* vlbloctab)
 {
   MEDPARTITIONER::Graph* cellGraph=0;
   // will be destroyed by XXXGraph class:
@@ -156,7 +156,7 @@ MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCou
       break;
     case Graph::SCOTCH:
 #ifdef MED_ENABLE_SCOTCH
-      cellGraph=new SCOTCHGraph(arr,edgeweight);
+      cellGraph=new SCOTCHGraph(arr,edgeweight,vlbloctab);
 #else
       throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : SCOTCH is not available. Check your products, please.");
 #endif
index dc80f70ebe7eacddecb9d9cac8dd6660ca2b5553..0f2de644da38bb932ca536fcb59ac5dd2ec4af9f 100644 (file)
@@ -42,7 +42,7 @@ namespace MEDPARTITIONER
     MEDPartitioner(const std::string& filename, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false);
     MEDPartitioner(const MEDCoupling::MEDFileData* fileData, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false);
     MEDPartitioner(const MEDCoupling::MEDFileData* fileData, Graph* graph, bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false);
-    static MEDPARTITIONER::Graph* Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0);
+    static MEDPARTITIONER::Graph* Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0, DataArrayInt* vlbloctab=0);
     void write(const std::string& filename);
     MEDCoupling::MEDFileData* getMEDFileData();
     ~MEDPartitioner();
index a0d4686bd6c969f18cf1bb26edf3b1d033ab7243..0ab62a6398be58a6000f4ceec7b520f6656e7a13 100644 (file)
 #include "MEDCouplingSkyLineArray.hxx"
 
 #include <cstdio>
+#include <mpi.h>
 
 #ifdef MED_ENABLE_SCOTCH
 extern "C"
 {
 #define restrict
-#include "scotch.h"
+#include "ptscotch.h"
 }
 #endif
 
@@ -39,7 +40,7 @@ SCOTCHGraph::SCOTCHGraph():Graph()
 {
 }
 
-SCOTCHGraph::SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray* graph, int* edgeweight):Graph(graph,edgeweight)
+SCOTCHGraph::SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray* graph, int* edgeweight, DataArrayInt* vlbloctab):Graph(graph,edgeweight), _vlbloctab(vlbloctab)
 {
 }
 
@@ -66,18 +67,24 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para
   //output parameters
   int* partition = new int[n+1];
   
-  SCOTCH_Graph scotch_graph;
-  SCOTCH_graphInit(&scotch_graph);
-  SCOTCH_graphBuild(&scotch_graph,
-                    0, //base first indice 0
-                    n, //nb of graph nodes
-                    xadj,
-                    0,
-                    _cell_weight, //graph vertices loads
-                    0,
-                    xadj[n], //number of edges
-                    adjncy,
-                    _edge_weight);
+  int* vlbloctab = _vlbloctab?const_cast<int*>(_vlbloctab->begin()):0;
+  
+  SCOTCH_Dgraph scotch_graph;
+  SCOTCH_dgraphInit(&scotch_graph, MPI_COMM_WORLD);
+  SCOTCH_dgraphBuild(&scotch_graph,
+                     0,             // baseval               , base first indice 0
+                     n,             // vertlocnbr            , nb of local graph nodes
+                     n,             // vertlocmax            , should be set to vertlocnbr for graphs without holes
+                     xadj,          // vertloctab[vertnbr+1] , index vertex table
+                     0,             // vendloctab            , index end vertex table if disjoint, set to zero
+                     _cell_weight,  // veloloctab            , graph vertices loads, set to zero
+                     vlbloctab,     // vlblocltab            , vertex label array : global vertex index
+                     xadj[n],       // edgelocnbr            , number of edges
+                     xadj[n],       // edgelocsiz            , same as edgelocnbr if edgeloctab is compact
+                     adjncy,        // edgeloctab[edgelocnbr], global indexes of edges
+                     0,             // edgegsttab            , optionnal, should be computed internally, set to zero
+                     _edge_weight); // edloloctab            , graph edges loads, set to zero
+  
   SCOTCH_Strat scotch_strategy;
   SCOTCH_stratInit(&scotch_strategy);
   
@@ -88,7 +95,7 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para
   if (nparts>1)
     {
       if (MyGlobals::_Verbose>10) std::cout << "SCOTCHGraph::graphPart SCOTCH_graphPart" << std::endl;
-      SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition);
+      SCOTCH_dgraphPart(&scotch_graph,nparts,&scotch_strategy,partition);
     }
   else  //partition for 1 subdomain
     {
@@ -97,7 +104,7 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para
     }
   
   SCOTCH_stratExit(&scotch_strategy);
-  SCOTCH_graphExit(&scotch_graph);
+  SCOTCH_dgraphExit(&scotch_graph);
 
   std::vector<int> index(n+1);
   std::vector<int> value(n);
index cbab99edcc343dca871e7bd2a0e8605763ecbd1d..bfcc62727d2f5e6728a0927675907c3eb31452a5 100644 (file)
@@ -31,9 +31,11 @@ namespace MEDPARTITIONER
   {
   public:
     SCOTCHGraph();
-    SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray*, int* edgeweight=0);
+    SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray*, int* edgeweight=0, DataArrayInt* vlbloctab=0);
     virtual ~SCOTCHGraph();
     void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0);
+  protected:
+    DataArrayInt* _vlbloctab;
   };
 }
 
index 350ac7555c4898f2ff5e6693b41c46cdbfefba4e..31e09e26a8b7d7f2482eabee4136efc1188b237b 100644 (file)
@@ -78,7 +78,7 @@ namespace MEDPARTITIONER
     MEDPartitioner(const std::string& filename, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception);
     MEDPartitioner(const MEDCoupling::MEDFileData* fileData, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception);
     MEDPartitioner(const MEDCoupling::MEDFileData* fileData, Graph* graph, bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception);
-    static MEDPARTITIONER::Graph* Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0) throw(INTERP_KERNEL::Exception);
+    static MEDPARTITIONER::Graph* Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0, MEDCoupling::DataArrayInt* vlbloctab=0) throw(INTERP_KERNEL::Exception);
     MEDCoupling::MEDFileData* getMEDFileData() throw(INTERP_KERNEL::Exception);
     void write(const std::string& filename) throw(INTERP_KERNEL::Exception);
   };