Installing, Compiling & Running Elmer in Ubuntu 14.04

Discussion about building and installing Elmer
annier
Posts: 1112
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Installing, Compiling & Running Elmer in Ubuntu 14.04

Post by annier » 30 Sep 2014, 11:37

Since Elmer can now be compiled wonderfully both with cmake or launchpad in ubuntu, it is recommended that the installation procedures be followed using any one of the following methods

...................................................................................................................................................................................................................................................................................
1. Using launchpad to install Elmer in Ubuntu (This can install GUI of Elmer along with other modules)
There is this way to install ElmerNonGui in Ubuntu 14.04 (also tested in Ubuntu 16.04) as mentioned in this reference
a. First add ppa repository of elmer

Code: Select all

$ sudo apt-add-repository ppa:elmer-csc-ubuntu/elmer-csc-ppa
b. Get update

Code: Select all

$ sudo apt-get update
c. Install elmer
(i) For Ubuntu 14.04, Ubuntu 16.04

Code: Select all

$ sudo apt-get install elmerfem-csc
(ii) For Ubuntu 18.04
Complete features using ElmerGUI

Code: Select all

$ sudo apt-get install elmerfem-csc-eg
or,
Non-GUI features

Code: Select all

$ sudo apt-get install elmerfem-csc
References:
[1]. https://github.com/ElmerCSC/elmerfem/wiki/Packages
[2]. viewtopic.php?f=2&t=5607


This will finish the installation of elmer in Ubuntu.
The xml files for solvers of installed ElmerGUI has to be copied from edf-extra to edf directory.
For this, we need to find the location of ElmerGUI,
d. Type and find out the location of ElmerGUI

Code: Select all

$  whereis ElmerGUI
This will produce a promt message in the same terminal as:

Code: Select all

ElmerGUI: /usr/bin/ElmerGUI  /usr/lib/ElmerGUI  /usr/share/ElmerGUI  
The edf-extra and edf directories are located in /usr/share location.

e. Copy the xml files from edf-extra directory to edf directory as root user:

Code: Select all

$ sudo -s

Code: Select all

$ cp -r /usr/share/ElmerGUI/edf-extra/* /usr/share/ElmerGUI/edf/


..........................................................................................................................................................................................................................................................................................
2. Using Cmake (This can install GUI of Elmer along with other modules)
The detail steps for installing Elmer using Cmake are provided in this link
viewtopic.php?f=2&t=3742&sid=6fb6416993 ... 8318f7a65d

............................................................................................................................................................................................................................................................................................
3. Compiling manually (The methods provided here describe only the compilation of ElmerNonGUI)
The following links have been referred for installation and compilation of elmer in Ubuntu 14.04 (64 bits)
http://www.elmerfem.org/elmerwiki/index ... r_on_Linux
http://www.elmerfem.org/elmerwiki/index ... u_12.04%29
http://ascend4.org/Building_Elmer_on_Ubuntu_12.04
https://subversion.apache.org/packages.html#debian
viewtopic.php?f=3&t=3585&p=12259&sid=73 ... 65d#p12259
viewtopic.php?f=2&t=2446(about path of libhuti.a)
viewtopic.php?f=2&t=3488&sid=6fb6416993 ... 8318f7a65d (the corresponding procedure in Ubuntu 12.04).
viewtopic.php?f=2&t=3581&sid=6fb6416993 ... 8318f7a65d (list of dependencies for installation of Elmer)

I would like to thank Matthias and Rasmus for their effort in providing the idea of selecting the "compile.sh" script for Elmer in Ubuntu 14.04. Also, i am learning new things through the ongoing discussions with Teobo.

Note:
  • i. For the context of here , the scripts with "$" in their front mean that they are to be typed in the terminal and if they are without it "they are to be pasted in a file" and then will be implemented.
  • ii. Find the number of processors of CPU by typing

    Code: Select all

    $nproc
    in the terminal. For this context, it was 4.

    this number has to be used later in step 4 below within the compile script as

    Code: Select all

     make -j 4
    [/b]
  • iii. Before installation, make sure that the dependencies for Elmer Installation (except that come along with Elmer package), as mentioned here, have been already installed in the Ubuntu machine. Some of them can be installed as following and some might already be existing in the computer.

    Code: Select all

    $sudo apt-get install  libblas-dev liblapack-dev libatlas-dev libarpack2-dev \
    libparpack2-dev libmpich2-dev libhypre-dev mpi-default-dev mpi-default-bin
Steps for Installation and Compilation:

1. Check out for the subversion

Code: Select all

$ sudo apt-get install subversion
$ sudo apt-get install libapache2-svn
Also, one can get the rabbitvcs subversion in the Ubuntu software centre.

2. Get the elmerfem source via the subversion

Code: Select all

$ svn checkout http://svn.code.sf.net/p/elmerfem/code/trunk elmerfem
or

Code: Select all

$ svn checkout https://svn.code.sf.net/p/elmerfem/code/trunk elmerfem
3. Jump into the elmerfem directory

Code: Select all

$ cd elmerfem
4. Create the compile script with the filename compile.sh inside the elmerfem directory.The following script should be added to the compile.sh file.

Code: Select all

#!/bin/sh -f
        # Compile Elmer modules and install it
        #
        # The elmer path is in home directory
        export ELMER_HOME=$HOME/elmerinst/
        export TCLTK_INCPATH="/usr/include/tcl8.4"

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

        modules="matc umfpack mathlibs elmergrid meshgen2d eio hutiter fem"

        for m in $modules; do
          cd $m
          ./configure --prefix="$ELMER_HOME" --with-tcltk="-ltcl8.4 -ltk8.4" --with-mpi-inc-dir="/usr/include/mpi"
          make clean
          make -j 4
          make install
          cd ..
        done
(If Tcl8.5 is present in the /usr/include/ directory of the computer, please replace 8.4 with 8.5 above. If neither of Tcl8.4 and Tcl8.5 is present in /usr/include/ directory; install Tcl8.5 using sudo apt-get install Tcl8.5 and create its symlink in the /usr/include/ directory.)


5. Run the script as follows. This will make an installation directory "elmerinst" within the Home directory and it is the path to elmer.

Code: Select all

$ chmod u+x compile.sh
$ ./compile.sh
6. Set the environment variables in the bashrc file for defining the path of Elmer
- In the terminal, type the following;

Code: Select all

$ gedit ~/.bashrc
-Add the following scripts at the end of the bashrc file

Code: Select all

export ELMER_HOME=$HOME/elmerinst
#export ELMER_POST_HOME=$ELMER_HOME/share/elmerpost
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ELMER_HOME/lib
export PATH=$PATH:$ELMER_HOME/bin
The manual installation and compilation of elmer in nonGui form is completed.

Steps for Running of the ElmerNonGui Tutorial/ Elmer Tests
It is assumed that the elmerfem and elmerinst folders are in the home directory.
1. Make an elmer project directory

Code: Select all

$mkdir elmer_project
2. Copy a test from elmerfem directory (e.g.CavityLid) to the elmer_project directory.

Code: Select all

$cp -r $HOME/elmerfem/fem/tests/CavityLid/ $HOME/elmer_project/CavityLid
3. Jump into the CavityLid tutorial.

Code: Select all

$cd ~/elmer_project/CavityLid/
4.Convert mesh file in .grd format [1] to .mesh.*(ElmerSolver) format [2] [Please refer chapter 1 of Elmer Grid Manual (http://www.nic.funet.fi/pub/sci/physics ... Manual.pdf) to find the corresponding number of Different File Formats]

Code: Select all

$ElmerGrid 1 2 square.grd
5. For users of Paraview, open the case.sif file via

Code: Select all

$gedit case.sif
and replace post file = case.ep (in simulation section) with

Code: Select all

Post File = case.vtu

Save the edited file.

6. Run the ElmerSolver command

Code: Select all

$ElmerSolver > anyname.log 2>&1
7.Open paraview by typing in terminal

Code: Select all

$paraview
Note: paraview can be installed in ubuntu by typing

Code: Select all

$sudo apt-get install paraview
The file>open>... can lead us to opening the case.vtu file located within the $HOME/emer_project/CavityLid/square/ directory.


The following reply to this post describes the steps for running ElmerNonGUI in Ubuntu 14.04.

Yours
Anil Kunwar
Last edited by annier on 02 Dec 2018, 13:16, edited 66 times in total.
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

annier
Posts: 1112
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by annier » 30 Sep 2014, 11:40

Steps for Running ElmerNonGUI in Ubuntu 14.04
1. We need to write all the input information (Header, Body, Solver, Simulation, Equation, Material ,Boundary Conditions) in a text file and make it a SIF (ending with .sif). Let it be named as abcd.sif. ( A sample Solver Input File for learning about the structure of .sif file can be found at different test examples in the downloaded elmer directory => $HOME/elmerfem/fem/tests or in general /path/ to elmer directory/fem/tests .)
Additionally, we need to create an empty text file with the file name ELMERSOLVER_STARTINFO and inside it we write the following thing:

Code: Select all

abcd.sif
1
The ELMERSOLVER_STARTINFO file should be in the same directory with the abcd.sif file.

2. We draw the geometry and mesh in some other preprocessors and convert it into Elmer format with ElmerGrid command in the terminal by jumping into the directory where the geometry/mesh files are located.
If the file exported by the preprocessor in .unv format has the name abcdwxyz.unv, then the following command converts the .unv file [8] into ElmerSolver format[2]:

Code: Select all

$ ElmerGrid 8 2 abcdwxyz.unv -autoclean
3. Then we put the folder with mesh files (in elmer grid format) in the directory where the SIF file is located. If the folder having mesh files (in Elmer Format) is named mymesh, then Header in abcd.sif should be like:

Code: Select all

Header
Mesh DB "." "mymesh"
End
4. In the terminal, we jump into the directory containing abcd.sif and type:

Code: Select all

$ ElmerSolver
or, in case we need to see the solver logfile

Code: Select all

$ ElmerSolver > anyname.log  2>&1
This will run the Elmer Solver.

5. In order to see the result, we can open postprocessor (example : Paraview) and browse the .vtu files located within the mymesh directory.
The method A and method B are mutually exclusive.
Method A
For this, there should have been written the following command in the simulation section of abcd.sif:

Code: Select all

Simulation
...
Post File = "case.vtu"
...
End
or
Method B (Provides the feature of real time view during data Reloading to Paraview with the command of vtu time collection = logical true)

Code: Select all

Solver n !(Use the last number here)
      Exec Solver = String "after saving"   
      exec interval = 1
      Equation = String "ResultOutput"
      Procedure = File "ResultOutputSolve" "ResultOutputSolver"
      Output File Name = String "case."
      Output Format = String "vtu"
      Vtu Format = Logical True
      vtu time collection = logical true
      Binary Output = Logical True  ! binary format is the default
     Single Precision = Logical True ! double precision is the default
   ! In the Vtu format all fields are saved if the user does not list them explicitely.
End

Note: The notes on Data Reloading in Paraview can be carried out using the python script as given in the following Paraview mailing lists. (i) http://markmail.org/message/exxynsgishbvtngg
(ii)http://markmail.org/message/rxlwxs7uqrfgibyv
Data reloading can be achieved regardless of the method A and B above but with method B (vtu time collection option in result output solver), the data reloading in paraview is accompanied by the real time visualization feature.



Yours
Anil Kunwar
Last edited by annier on 11 Oct 2014, 23:07, edited 8 times in total.
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

mzenker
Posts: 1917
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by mzenker » 30 Sep 2014, 12:01

annier wrote: 5. In order to see the result, we can open postprocessor (example : Paraview) and browse the .vtu files located within the mymesh directory.
I would like to add that the data can be reloaded during simulation using Python scripts posted on the ParaView mailing list
for vtu time series and
for vtu time series with pvd time collection (using ResultOutputSolver with "vtu time collection = logical true").

Matthias

annier
Posts: 1112
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by annier » 30 Sep 2014, 12:12

Hi Matthias,
Thank you very much for this concept of using the Paraview in an effective way. I have already updated the above post.
Yours
Anil Kunwar
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

mzenker
Posts: 1917
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by mzenker » 30 Sep 2014, 12:52

Hi,

data reloading in ParaView works in both cases (methods A and B), but using different Python scripts as indicated in my post.
The difference is that using a vtu time collection file, you see the real time in ParaView.

Matthias

annier
Posts: 1112
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by annier » 01 Oct 2014, 13:55

Hi Matthias,
Thank you again for clarifying us more about data reloading and real time visualization during data reloading.

Yours
Anil Kunwar
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

Termo
Posts: 33
Joined: 19 Jul 2011, 11:10
Antispam: Yes

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by Termo » 02 Oct 2014, 21:27

Also a note that the

Code: Select all

 make -j 8
is for compiling on a system with 8 or more cores, so the number after -j should preferably be equil to or less than the numbers of cores on the system that you compile on.

/Rasmus

annier
Posts: 1112
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by annier » 03 Oct 2014, 19:33

Hi Rasmus,
Thank you for making us learn about the number of processors used in compilations
I have updated my post as above.
Yours
Anil Kunwar
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

teobo
Posts: 97
Joined: 07 Sep 2014, 10:41
Antispam: Yes

fatal error: mpi.h

Post by teobo » 09 Oct 2014, 21:39

Hi
could not compile Elmer. Tried to follow all your tips in the initial post.
See output below and in attachment.
Thanks for help in advance.

Code: Select all

kubuntu@kubuntu:~/elmerfem$ sh compile1.sh >anyname.log  2>&1
kubuntu@kubuntu:~/elmerfem$ tail anyname.log 
                 from SolveHypre.c:47:
/usr/include/HYPRE_utilities.h:26:17: fatal error: mpi.h: No such file or directory
 #include "mpi.h"
                 ^
compilation terminated.
make[2]: *** [SolveHypre.o] Error 1
make[2]: Leaving directory `/home/kubuntu/elmerfem/fem/src'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/kubuntu/elmerfem/fem/src'
make: *** [install-recursive] Error 1

kubuntu@kubuntu:~/elmerfem$ cat compile1.sh 
#!/bin/sh -f 
# Compile Elmer modules and install it
#

export ELMER_HOME=/opt/Elmer

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

modules="matc umfpack mathlibs elmergrid meshgen2d eio hutiter fem"

for m in $modules; do
  cd $m
  ./configure --prefix="$ELMER_HOME"
  make clean
  make -j 2
  make install
  cd ..
done
kubuntu@kubuntu:~/elmerfem$ nproc
2
kubuntu@kubuntu:~/elmerfem$
kubuntu@kubuntu:~/elmerfem$ head -n23 /etc/apt/sources.list|grep trusty|wc
     10      55     827


 
Attachments
anyname.log
(383.19 KiB) Downloaded 246 times

annier
Posts: 1112
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Installing, Compiling & Running ElmerNonGUI in Ubuntu 14.04

Post by annier » 10 Oct 2014, 06:37

Hi Teobo,
Looking at your log file, the compilation is not proceeding for the fem module of Elmer (related with mpi).
Would you again try reinstalling with all the steps same except step 4 (wherein you will be using the following compile script with fem module compiled in a separate way than other modules)?

Code: Select all

    #!/bin/sh -f
    #the compiler (here the gcc 4.X suite)
    export CC=gcc
    export CXX=g++
    export FC=gfortran
    export F77=gfortran
    #the compiler flags
    export CFLAGS=""
    export FCFLAGS=""
    export F77FLAGS=""
    export FFLAGS=""
    #linking
    export LDFLAGS=""
    #paths
    #export ELMER_HOME="/path/to/Elmerdir"
    export ELMER_HOME="$HOME/elmerinst"
    # modules
    modules="matc umfpack mathlibs elmergrid meshgen2d eio hutiter  post"
    # configure and build
    for m in $modules; do
      cd $m ; ./configure --prefix=$ELMER_HOME && make clean && make && make install && cd ..
    #done >>>>>>>this word has produced error in the compilation test
    # configure and build the module fem using mpi related aspect
    cd fem; ./configure --prefix=$ELMER_HOME --with-mpi-inc-dir=/usr/include/mpich2 
    make clean
    make
    make install 
    cd ..
    done
Yours
Anil Kunwar
Last edited by annier on 10 Oct 2014, 16:50, edited 3 times in total.
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

Post Reply