From 1490028019e382a69ec06d2846c2e47562efd144 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 7 Oct 2013 10:14:03 +0000 Subject: [PATCH] Adding detection of maj version of Metis to support metis 4 and metis 5. --- src/MEDPartitioner/CMakeLists.txt | 3 ++ .../MEDPARTITIONER_MetisGraph.cxx | 2 +- src/MEDPartitioner/MEDPARTITIONER_metis.c | 33 ++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/MEDPartitioner/CMakeLists.txt b/src/MEDPartitioner/CMakeLists.txt index 75312847b..19e5a1606 100644 --- a/src/MEDPartitioner/CMakeLists.txt +++ b/src/MEDPartitioner/CMakeLists.txt @@ -36,6 +36,9 @@ INCLUDE_DIRECTORIES( IF(SALOME_MED_PARTITIONER_METIS) ADD_DEFINITIONS(${METIS_DEFINITIONS}) ADD_DEFINITIONS("-DMED_ENABLE_METIS") + IF(SALOME_MED_METIS_V5) + ADD_DEFINITIONS("-DMED_ENABLE_METIS_V5") + ENDIF(SALOME_MED_METIS_V5) INCLUDE_DIRECTORIES(${METIS_INCLUDE_DIRS}) ENDIF(SALOME_MED_PARTITIONER_METIS) diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx index dcea42d99..d3b92d4c5 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx @@ -75,7 +75,7 @@ void METISGraph::partGraph(int ndomain, #define PMV3_OPTION_PSR 3 seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33 */ - int options[4]={0,0,0,0}; + int options[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; #if !defined(MED_ENABLE_METIS) throw INTERP_KERNEL::Exception("METISGraph::partGraph : METIS is not available. Check your products, please."); #else diff --git a/src/MEDPartitioner/MEDPARTITIONER_metis.c b/src/MEDPartitioner/MEDPARTITIONER_metis.c index ca7970150..0f8ca33b3 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_metis.c +++ b/src/MEDPartitioner/MEDPARTITIONER_metis.c @@ -27,20 +27,35 @@ #include "MEDPARTITIONER_metis.h" #if defined(MED_ENABLE_METIS) & !defined(MED_ENABLE_PARMETIS) - #include "defs.h" + #ifndef MED_ENABLE_METIS_V5 + #include "defs.h" + #endif // MED_ENABLE_METIS_V5 #include "metis.h" + #ifdef MED_ENABLE_METIS_V5 + #define idxtype idx_t + #endif // MED_ENABLE_METIS_V5 #else typedef int idxtype; -#endif +#endif // defined(MED_ENABLE_METIS) & !defined(MED_ENABLE_PARMETIS) void MEDPARTITIONER_METIS_PartGraphRecursive(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, int *edgecut, idxtype *part) { #if defined(MED_ENABLE_METIS) + #ifndef MED_ENABLE_METIS_V5 METIS_PartGraphRecursive(nvtxs, xadj, adjncy, vwgt, - adjwgt, wgtflag, numflag, nparts, + adjwgt, wgtflag, numflag, nparts, + options, edgecut, part); + #else + int ncon=1; + options[METIS_OPTION_NCUTS]=1; + options[METIS_OPTION_NITER]=1; + options[METIS_OPTION_UFACTOR]=1; + METIS_PartGraphRecursive(nvtxs, &ncon, xadj, adjncy, vwgt, 0 /* vsize*/, + adjwgt, nparts,/* tpwgts*/ 0,/* ubvec */ 0, options, edgecut, part); + #endif #endif } @@ -49,8 +64,18 @@ void MEDPARTITIONER_METIS_PartGraphKway(int *nvtxs, idxtype *xadj, idxtype *adjn int *options, int *edgecut, idxtype *part) { #if defined(MED_ENABLE_METIS) + #ifndef MED_ENABLE_METIS_V5 METIS_PartGraphKway(nvtxs, xadj, adjncy, vwgt, - adjwgt, wgtflag, numflag, nparts, + adjwgt, wgtflag, numflag, nparts, + options, edgecut, part); + #else + int ncon=1; + options[METIS_OPTION_NCUTS]=1; + options[METIS_OPTION_NITER]=1; + options[METIS_OPTION_UFACTOR]=1; + METIS_PartGraphKway(nvtxs, &ncon, xadj, adjncy, vwgt, 0 /* vsize*/, + adjwgt, nparts, 0 , 0 /* ubvec */, options, edgecut, part); + #endif #endif } -- 2.39.2