elmerfem icon indicating copy to clipboard operation
elmerfem copied to clipboard

Modularizing METIS

Open Foadsf opened this issue 4 years ago • 5 comments

Following this discussion, I'm looking into the possibilities of modularizing METIS instead of just dropping the code into this repository. So the possibilities:

  • Cross-platform:

    • Sadly Conan does not have a METIS library yet. I have created a package request here. If you can help please do.
    • The METIS developers do not provide a direct URL link to the source code but a bunch of zip files. I'm not sure if we can something like a .gitmodule to put a "virtual" version of that library here. Or if you have any communication with them please ask them to expose their direct source code, maybe upload the entire library on GitHub/BitBucket/GitLab...
    • The vcpkg package manager, an alternative to Conan, has a METIS package. I'm going to test it but I have no experience with this tool before.
  • Windows only:

    • MSYS2 also has a METIS package mingw-w64-x86_64-metis-5.1.0-3 which one can install with pacman -S
    • Also, CygWin has a METIS package, though I prefer MSYS2.
  • For macOS, there is actually a HomeBrew package for METIS here.

  • For other operating systems (e.g., GNU/Linux, *BSD) there are plenty of prebuild packages as you may see here on Repology.

  • For the CMake instructions, we may use the FindMETIS script provided by the Eigen library.

I am interested to know your thoughts on what is the best way to approach this.

Foadsf avatar Mar 20 '20 22:03 Foadsf

ElmerGrid:

MSYS2 - MinGW-w64

I was able to compile ElmerGrid on MSYS2 using the MinGW-w64 compiler(s):

  • isolate the elmergrid folder
  • delete the src\metis-5.1.0 folder
  • delete these lines of the src/CMakeList.txt:
SET(METIS_INSTALL FALSE CACHE BOOL "")
ADD_SUBDIRECTORY(metis-5.1.0)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/metis)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/elmergrid/src/metis)
  • add the build/ to the .gitignore
  • in the file src/femelmer.c follow the instructions here to replace the C macros:
// #ifdef MINGW32
//   fail = mkdir(subdirectoryname);
// #else
//   fail = mkdir(subdirectoryname,0750);
// #endif

#ifdef __linux__
    mkdir(directoryname, 0750); 
#else
    _mkdir(directoryname);
#endif
  • add the #include <direct.h> header to the femelmer.c file
  • in femelmer.c make sure you have #include "metis.h"
  • cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
  • make -I /mingw64/include/

Foadsf avatar Mar 21 '20 00:03 Foadsf

Dear @raback ,

I created a new repository for ElmerGrid here. Your review and feedback would be highly appreciated.

Foadsf avatar Mar 22 '20 13:03 Foadsf

The develop branch here now compiles in both MSVC-Vcpkg and MSYS2-MinGW64. @raback test and review would be highly appreciated.

Foadsf avatar Mar 22 '20 23:03 Foadsf

Are the METIS routines called from Fortran? If so, I wrote a module with the C bindings to be able and interface safely from Fortran: https://github.com/ivan-pi/fmetis

ivan-pi avatar Apr 21 '20 22:04 ivan-pi

As an update, it appears that someone has eventually added METIs to Conan here.

Foadsf avatar Feb 23 '22 11:02 Foadsf