Building GmshFEM on Windows
Here are detailed instructions on how to build GmshFEM on Windows, using Cygwin and the MinGW compilers. The resulting programs do not depend on the cygwin DLL, i.e. are pure Windows executables.
Cygwin and Windows PATH
Install cygwin from https://www.cygwin.com. Accept all defaults and select View "Full". Install the following packages:
- mingw64-x86_64-gcc-g++
- mingw64-x86_64-gcc-fortran
- cmake
- make
- openssh
- python3
- autoconf
- automake
- git
- wget
- unzip
Also useful for debugging
- gdb
Also useful for editing text files
- emacs-w32
Type "path" in the Windows search box and choose "Edit the system environment variables". Go to "Advanced" and select "Environment variables". If the PATH
variable does not exist (note the ALL CAPS!), create it and set it to
C:\cygwin64\usr\local\bin\;C:\cygwin64\usr\local\lib;C:\cygwin64\usr\local\petsc\complex_mumps_seq\lib;C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin
If PATH
already exists, append the value (don't forget the semicolon!).
Cygwin terminal and Bash environment variables
Open the Cygwin terminal.
Edit the ~/.bash_profile
and add the following at the end:
export PATH="${PATH}:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:/usr/local/bin"
export CXX=x86_64-w64-mingw32-g++
export CC=x86_64-w64-mingw32-gcc
export FC=x86_64-w64-mingw32-gfortran
export PETSC_DIR=/usr/local/petsc
export PETSC_ARCH=complex_mumps_seq
Then
cd
source .bash_profile
PETSc
Method 1: download a pre-built binary package
cd /usr/local
wget https://gmsh.info/beta/petsc-Windows64.zip
unzip petsc-Windows64.zip
Method 2: build from source
Download and configure PETSc:
cd /usr/local
git clone -b release https://gitlab.com/petsc/petsc.git petsc
cd petsc
./configure --CXX=x86_64-w64-mingw32-g++ --CC=x86_64-w64-mingw32-gcc --FC=x86_64-w64-mingw32-gfortran --with-clanguage=cxx --with-debugging=0 --with-mpi=0 --with-fortran-bindings=0 --download-mumps=yes --with-mumps-serial --with-shared-libraries=1 --with-x=0 --with-ssl=0 --with-scalar-type=complex --download-f2cblaslapack=1
Warning: this uses the generic fortran BLAS/LAPACK implementation; for better performance you should install and use optimized BLAS/LAPACK libraries (e.g. OpenBLAS) instead.
Edit complex_mumps_seq/include/petscconf.h
and set
#undef PETSC_HAVE_UNISTD_H
#undef PETSC_HAVE_GETPAGESIZE
#undef PETSC_HAVE_SLEEP
#undef PETSC_HAVE_IEEEFP_H
Build PETSc:
make
Gmsh
Method 1: download a pre-built binary package
cd
wget https://gmsh.info/bin/Windows/gmsh-git-Windows64-sdk.zip
unzip gmsh-git-Windows64-sdk.zip
mkdir /usr/local/include/
cp gmsh-git-Windows64-sdk/include/* /usr/local/include/
cp gmsh-git-Windows64-sdk/lib/* /usr/local/lib/
cp gmsh-git-Windows64-sdk/bin/* /usr/local/bin/
Method 2: build from source
Download, build and install Gmsh (here we build a barebones version - see the Gmsh wiki to compile a full-featured version with OpenCASCADE, the graphical user interface, ...):
cd
git clone https://gitlab.onelab.info/gmsh/gmsh.git
cd gmsh
mkdir build
cd build
cmake -DENABLE_BUILD_DYNAMIC=1 -DENABLE_PETSC=1 -DENABLE_OPENMP=1 ..
make install
GmshFEM
Build and install GmshFEM:
cd
git clone https://gitlab.onelab.info/gmsh/fem.git
cd fem
mkdir build
cd build
cmake ..
make install
Compile an example:
cd
cd fem/tutorials/dirichlet
mkdir build
cd build
cmake ..
make
./tuto.exe
Building on Nic5 (Last updated in March 2023)
On NIC5, GmshFEM can be built from source once Gmsh and PETSc are found. Furthermore, additional dependencies are required depending on what the user wants to do: MUMPS to solve formulations, SLEPc, ...
We assume here that the user wants to install everything in $HOME/.local
Gmsh
See the Gmsh instructions for full details. A basic version can be achieved with
cd
git clone https://gitlab.onelab.info/gmsh/gmsh.git
cd gmsh
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DENABLE_BUILD_DYNAMIC=1 .. ..
make install
PETSc
Download PETSc from Github, then configure it and build it. Here are valid flags to get MUMPS (which requires Scalapack) and MPI support. You should load OpenBLAS beforehand. We recommend putting it your .bashrc
(module load OpenBLAS
). You may also want to add optimization flags.
git clone -b release https://gitlab.com/petsc/petsc.git petsc
cd petsc
./configure --with-mumps=true --download-mumps=yes --download-scalapack --prefix=~/.local/petsc --with-scalar-type=complex --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90 --with-debugging=0
GmshFEM
cd
git clone https://gitlab.onelab.info/gmsh/fem.git
cd fem
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=~/.local/ -DCMAKE_INSTALL_PREFIX=~/.local/ ..
make
make install
To check the installation, you can run a simple tutorial, e.g.:
cd fem/tutorials/dirichlet
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=~/.local ..
make
./tuto