Salome HOME
Adding detection of maj version of Metis to support metis 4 and metis 5.
authorageay <ageay>
Mon, 7 Oct 2013 10:14:03 +0000 (10:14 +0000)
committerageay <ageay>
Mon, 7 Oct 2013 10:14:03 +0000 (10:14 +0000)
adm_local/cmake_files/FindMetis.cmake
src/MEDPartitioner/CMakeLists.txt
src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx
src/MEDPartitioner/MEDPARTITIONER_metis.c

index 0895a0dff3bf50d3cf71bb02fbed781c4692e23e..c0d6c225f04db69e64efa66d552da31764b3a5d1 100644 (file)
@@ -24,7 +24,9 @@ MESSAGE(STATUS "Check for metis ...")
 SET(METIS_ROOT_DIR $ENV{METIS_ROOT_DIR} CACHE PATH "Path to the METIS.")
 IF(METIS_ROOT_DIR)
   LIST(APPEND CMAKE_LIBRARY_PATH "${METIS_ROOT_DIR}")
+  LIST(APPEND CMAKE_LIBRARY_PATH "${METIS_ROOT_DIR}/lib")
   LIST(APPEND CMAKE_INCLUDE_PATH "${METIS_ROOT_DIR}/Lib")
+  LIST(APPEND CMAKE_INCLUDE_PATH "${METIS_ROOT_DIR}/include")
 ENDIF(METIS_ROOT_DIR)
 
 FIND_LIBRARY(METIS_LIBRARIES metis)
@@ -32,3 +34,17 @@ FIND_PATH(METIS_INCLUDE_DIRS metis.h)
 
 INCLUDE(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Metis REQUIRED_VARS METIS_INCLUDE_DIRS METIS_LIBRARIES)
+FILE(READ ${METIS_INCLUDE_DIRS}/metis.h metis_h_content)
+STRING(REPLACE "\n" ";" list_metis_h_content ${metis_h_content})
+FOREACH(ln ${list_metis_h_content})
+  IF("${ln}" MATCHES "^#define METIS_VER_MAJOR")
+    STRING(REPLACE "#define METIS_VER_MAJOR" "" metis_major_version "${ln}")
+    STRING(STRIP "${metis_major_version}" metis_major_version)
+  ENDIF("${ln}" MATCHES "^#define METIS_VER_MAJOR")
+ENDFOREACH(ln ${list_metis_h_content})
+IF(metis_major_version STREQUAL 5)
+  SET(SALOME_MED_METIS_V5 1)
+  MESSAGE("-- Metis maj version 5 detected.")
+ELSE(metis_major_version STREQUAL 5)
+   MESSAGE("-- Metis maj version 4 detected.")
+ENDIF(metis_major_version STREQUAL 5)
index 75312847bb4d562410326cb74e2a52b107d3e31a..19e5a1606d6889156414f197b428e9bdcb16e579 100644 (file)
@@ -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)
 
index dcea42d991038d7d0d40f7c58dabe09f8f12fa38..d3b92d4c57728791dfbb34c384a01876bbe7eff0 100644 (file)
@@ -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
index ca7970150968f091d88f63ebdde1c7b6f1ec5607..0f8ca33b31ed1940f787dd125db8bd4099c6edb2 100644 (file)
 #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
 }