Elmer — source code and compilation

Created: 2009-06-20

Updated: 2010-04-24

Description:

This is a free translation of my notes and it may differ from original.

Elmer – open source package for finite element modeling.

The Elmer website includes several excellent PDF manuals on various aspects of the Elmer suite, as well as example input files distributed with the ElmerGrid and Tutorial manuals. Some documentation is available in a special package in the Debian and Ubuntu repositories, which became possible after the change in the license of documentation at CC-BY-ND.

Elmer_on_Debian_Sid.png
Elmer in Debian GNU/Linux (Sid), desktop environment — KDE-4.2.4

The screenshot shows: finite element grid in preprocessor, a text editor with instructions for the solver, the new post-processor, which is actively improving now. It is presented the solution of the simplest problem of natural convection from a heated plate.

Installation files for MS Windows are daily generated by developers from the trunk branch of SVN. deb packages with binaries exist in Debian >= 6.0 (Squeeze) and Ubuntu >= 9.10 (Karmic Koala), and I do not know about packages for other distributions.

There is all the necessary information on compiling and using the program in the official website. So the following will be give only simple and brief instructions for building the program (as well as the creation of packages with it if necessary) in the unstable branch of Debian (must be relevant to users Ubuntu). I hope it will be useful for someone.

The source code and compilation

If you have not installed a version control system Subversion yet, it's easy to install:
sudo apt-get install subversion
And then you can get the source code:
svn export https://elmerfem.svn.sourceforge.net/svnroot/elmerfem/trunk elmerfem/trunk
Or you can copy single archive with sources:
wget 'http://elmerfem.svn.sourceforge.net/viewvc/elmerfem/trunk.tar.gz?view=tar'
tar xzf 'trunk.tar.gz?view=tar'
rm trunk.tar.gz*
To compile the program you need to install the following packages:
sudo apt-get install automake gcc g++ \
 gfortran libblas-dev liblapack-dev mpi-default-dev mpi-default-bin \
 libhypre-dev libsuitesparse-dev libarpack2-dev libreadline-dev \
 libncurses5-dev libx11-dev tk8.4-dev tcl8.4-dev libfreetype6-dev \
 libftgl-dev libgl1-mesa-dev libglu1-mesa-dev \
 libopencascade-modeling-dev libqt4-dev qt4-qmake libqt4-opengl-dev \
 libqwt5-qt4-dev libvtk5-qt4-dev python-qt4-dev libscotchmetis-dev \
 r-base-core
Now you need to edit the file trunk/ElmerGUI/ElmerGUI.pri in any text editor. For example, it looks like this in my case:: ElmerGUI.pri. I recommend to check the lines:
...
DEFINES += EG_PYTHONQT # Use PythonQt for scripting in post processor?
...
BITS = 32
...
   VTK_INCLUDEPATH = /usr/include/vtk-5.2
   VTK_LIBPATH += /usr/lib/vtk-5.2 /usr/lib
...
   OCC_INCLUDEPATH = /usr/include/opencascade
   OCC_LIBPATH += /usr/lib /usr/lib/opencas
...
Such script can simplify the compilation:
#!/bin/sh -f
# Compile Elmer modules and install it

export ELMER_HOME=/mnt/other/elmer

# replace these with your compilers:
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran


export ELMERGUI_HOME=$ELMER_HOME/bin
modules="matc umfpack mathlibs elmergrid meshgen2d eio hutiter fem post elmerparam front"

for m in $modules; do
  cd $m
  chmod uog=rwx ./configure
  ./configure --prefix="$ELMER_HOME"
  make
  make install
  cd ..
done

cd ElmerGUI
qmake
make
make install
cp Application/edf-extra/* $ELMER_HOME/bin/edf/
cd ..

cd ElmerGUIlogger
qmake -project
qmake
make
make install
cp ./ElmerGUIlogger $ELMERGUI_HOME
cd ..
This script must be placed in the trunk directory and you need to edit it before executing. ELMER_HOME variable specifies the directory all the necessary files will be placed to after assembly. If you do not care about trash in the system, you can set ELMER_HOME=/. If your user does not have permission to write to the directory ELMER_HOME, you need to change in the script: make install to sudo make install and cp to sudo cp.

In the process of compiling it is sometimes necessary to suspend the process. For example, if the cooler on the laptop can not cope with cooling the processor. You can do this with the aid of command:
pkill -STOP make
To continue the process:
pkill -CONT make

After running the script all the components of the program will be installed in the appropriate directories. Now, for example, to run the graphical preprocessor ElmerGUI you can use a simple script like this:
#!/bin/sh

export ELMER_HOME=/mnt/other/elmer

case "$1" in
    "-h"|"-help"|"--help")
        echo "This is a simple script for setting environment variables and launching ElmerGUIlogger."
        echo "ELMER_HOME now is set to: $ELMER_HOME"
        ;;
    *)
        export ELMERGUI_HOME=$ELMER_HOME/bin
        export ELMER_POST_HOME=$ELMERGUI_HOME
        export ELMER_LIB="$ELMER_HOME/lib:$ELMER_HOME/share/elmersolver/lib:$ELMER_HOME/share/elmerpost/lib:$ELMER_HOME/share/elmerfront/lib"
        export PATH=$ELMER_HOME/bin:$ELMER_HOME/lib:$ELMER_HOME/share/elmersolver/lib:$PATH
        export LD_LIBRARY_PATH="${ELMER_LIB}:${LD_LIBRARY_PATH}"
        unset  ELMER_LIB

        # nohup $ELMERGUI_HOME/ElmerGUIlogger
        $ELMERGUI_HOME/ElmerGUIlogger &
        ;;
esac

exit 0


Building deb packages

There are several ways to create a deb-package from scratch. For example: a simple and correct methods. There are others... But here I write about a simple way to upgrade an existing package in the repository, using the obtained from the SVN source code, and with the additional assumption that the package version is not much different from the version of the source in SVN and all the additional patches will be successfully applied.

Immediately install necessary to build packages utilities:
sudo apt-get install dh-make debhelper autotools-dev fakeroot
Information about them can be found in the documentation, but here I will not write anything.

The first step (getting the source) described above, we will assume that you already have them. Rename the directory trunk and wrap it in the archive, like this:
export ELMER_VERSION=5.5.0.svn.4453.mybuild
mv trunk "elmerfem-$ELMER_VERSION"
tar -czf "elmerfem_$ELMER_VERSION.orig.tar.gz" "elmerfem-$ELMER_VERSION"
Next, you need to download from Debian repository patches from maintainers of the package. For example:
export ELMER_OLD_VERSION=5.5.0.svn.4388.dfsg
export POSTFIX=-1
wget "http://ftp.de.debian.org/debian/pool/main/e/elmerfem/elmerfem_$ELMER_OLD_VERSION$POSTFIX.debian.tar.gz"
Look here and here, perhaps there is a newer version of patches.

Now extract and move the debian directory with a description of the package:
tar xzf elmerfem_$ELMER_OLD_VERSION$POSTFIX.debian.tar.gz
mv debian "elmerfem-$ELMER_VERSION/"
Next we need to change the version of collected packets in the file debian/changelog. This can be done in any text editor or by special utility dch:
cd "elmerfem-$ELMER_VERSION"
export DEBEMAIL="Vasya Pupkin <vasya@example.com>"
dch -v "$ELMER_VERSION-1" "Non-maintainer upload."
dch -a "Updating elmerfem packages."
Now we have to deal with dependencies. I.e. with the packages required to build and install packages with this program. All the necessary information about this is contained in a text file debian/control. Section Build-Depends contains a list of packages (and versions) needed to build packages specified in sections Package, and sections Depends contain a list of packages required for installation. For example, if Build-Depends looks like this:
Build-Depends: debhelper (>= 5), po-debconf, autoconf, automake,
 gfortran, libblas-dev | libblas-3gf.so, liblapack-dev | liblapack-3gf.so,
 mpi-default-dev, mpi-default-bin,
 libhypre-dev, libsuitesparse-dev, libarpack2-dev, libreadline-dev,
 libncurses5-dev, libx11-dev, tk8.4-dev, tcl8.4-dev, libfreetype6-dev,
 libftgl-dev, libgl1-mesa-dev | libgl-dev, libglu1-mesa-dev | libglu-dev,
 libopencascade-modeling-dev, libqt4-dev, qt4-qmake, libqt4-opengl-dev,
 libqwt5-qt4-dev, libvtk5-qt4-dev, python-qt4-dev, libscotchmetis-dev,
 r-base-core
You need to install:
sudo apt-get install debhelper po-debconf autoconf automake \
 gfortran libblas-dev liblapack-dev mpi-default-dev mpi-default-bin \
 libhypre-dev libsuitesparse-dev libarpack2-dev libreadline-dev \
 libncurses5-dev libx11-dev tk8.4-dev tcl8.4-dev libfreetype6-dev \
 libftgl-dev libgl1-mesa-dev libglu1-mesa-dev \
 libopencascade-modeling-dev libqt4-dev qt4-qmake libqt4-opengl-dev \
 libqwt5-qt4-dev libvtk5-qt4-dev python-qt4-dev libscotchmetis-dev \
 r-base-core
Now you can perform any changes in the sources, if necessary.

Finally it's time to execute the command for building Elmer packages:
dpkg-buildpackage -rfakeroot
At the end of the assembly warnings may appear:
dpkg-buildpackage: warning: Failed to sign .dsc and .changes file
This is normal if you have not configured GnuPG. It doesn't affect packages.

If the build packages were successful then 4 deb-file and other associated assembly files should appear. In this example, the list of files (and one directory):
$ cd ..
$ ls -p
elmer_5.5.0.svn.4453.mybuild-1_i386.deb
elmer-common_5.5.0.svn.4453.mybuild-1_all.deb
elmerfem_5.5.0.svn.4388.dfsg-1.diff
elmerfem-5.5.0.svn.4453.mybuild/
elmerfem_5.5.0.svn.4453.mybuild-1.diff.gz
elmerfem_5.5.0.svn.4453.mybuild-1.dsc
elmerfem_5.5.0.svn.4453.mybuild-1_i386.changes
elmerfem_5.5.0.svn.4453.mybuild.orig.tar.gz
libelmer-dev_5.5.0.svn.4453.mybuild-1_i386.deb
libelmersolver-5.5.0_5.5.0.svn.4453.mybuild-1_i386.deb
To install new packages and their dependencies:
sudo dpkg -i *elmer*.deb
sudo apt-get -f install
Shortcut to start the program: /usr/share/applications/ElmerGUIlogger.desktop
To run from the console:
sh -c 'ELMER_HOME=/usr ELMERGUI_HOME=/usr/share/ElmerGUI ELMER_POST_HOME=/usr/share/elmerpost ElmerGUIlogger' &

I wish you a pleasant and successful work.

PS: I recommend to MS Windows users after installing the program to move all *.xml files from directory %ELMER_HOME%\bin\edf-extra\ to %ELMER_HOME%\bin\edf\. If you compiled deb packages for the instructions above, you do not need any additional actions.

PPS: project is open and actively growing. Even I had already managed to make a modest contribution: r4220, r5861. The entire list of changes to the trunk branch SVN is available here.

My old script for updating: automatic_update_elmer.sh. New script for unofficial PPA with daily builds: automatic_update_elmerfem. Links from this web site:
Elmer — packages for Debian GNU/Linux and Ubuntu

Links to documentation:
ElmerDocumentation.tar.gz
Elmer documentation
Elmer presentations
Elmer interfaces
Elmer examples
Elmer forum
Elmer wiki
Elmer FEM

Elmer in Debian and Ubuntu:
Package details in Debian Sid
Debian PTS, Launchpad page
Bugs in Debian, Bugs in Ubuntu
Package Git repository
Package changelog

Tehnick © 2009-2016