From 9838510728b37938ddae325e130146e970b0cbf3 Mon Sep 17 00:00:00 2001
From: Carl-Martin Pfeiler <carl-martin.pfeiler@asc.tuwien.ac.at>
Date: Mon, 19 Aug 2019 18:12:30 +0200
Subject: [PATCH] installer script added; install help updated

---
 installationHelp.txt | 143 +++++++++++++++----------------------------
 local_installer.sh   |  74 ++++++++++++++++++++++
 2 files changed, 124 insertions(+), 93 deletions(-)
 create mode 100644 local_installer.sh

diff --git a/installationHelp.txt b/installationHelp.txt
index 1ba83c6..ea017db 100644
--- a/installationHelp.txt
+++ b/installationHelp.txt
@@ -1,93 +1,50 @@
-# Installation instructions for ngsolve, bem++ and ngbem, created on 2018/06/12
-# we consider a local installation to the ${HOME} directory
-
-#------------------------------------------------------------------------------#
-
-# 0) Dependencies:
-# This list is probably neither complete nor strict.
-# However, if you encounter problems during installation of ngsolve or bem++,
-# try installing/updating these packages
-
-# Install with package manager: (sudo apt-get install ...)
-python3 python3-tk libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev liblapacke-dev cython cython3  mpich libboost-all-dev libtbb-dev python3-pip
-
-# install with pip (pip3 install ...)
-numpy scipy mpi4py pyamg
-
-#------------------------------------------------------------------------------#
-
-# A) NgSolve
-# - We rely on a local installation, see https://ngsolve.org/docu/latest/install/installlinux.html
-
-# add the following line to the ~/.bashrc
-export NETGENDIR=${HOME}/ngs/ngsolve-install/bin
-export PYTHONPATH=${HOME}/ngs/ngsolve-install/lib/python3/dist-packages/:$PYTHONPATH
-export PATH=$NETGENDIR:$PATH
-
-#------------------------------------------------------------------------------#
-
-# B) BEM++
-# again: local installation, for further information see http://www.bempp.org/installation.html
-# summarizing our experience, you need the following: python3, cmake, git, cython, scipy, numpy - versions as new as possible
-
-#------------------------------------------------------------------------------#
-
-# B.1) Eigen
-# first we need to download the "eigen" headers from http://eigen.tuxfamily.org/index.php?title=Main_Page
-
-cd ~
-mkdir eigen
-cd eigen
-# get newest release, i.e., numbers in the following 3 lines may vary
-wget "http://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2"
-tar -xjf 3.3.4.tar.bz2
-mv eigen-eigen-5a0156e40feb/ eigen-headers
-# that's it, nothing needs to be built here, only the Eigen headers are needed
-
-#------------------------------------------------------------------------------#
-
-# B.2) BEM++
-# now we start the local bempp installation, further info athttp://www.bempp.org/installation.html
-
-cd ~
-mkdir bempp
-cd bempp
-git clone https://bitbucket.org/bemppsolutions/bempp.git bempp-src
-mkdir bempp-install
-mkdir bempp-build
-cd bempp-build
-export CXX=$(which g++-6)
-cmake ../bempp-src -DEIGEN3_INCLUDE_DIR=${HOME}/eigen/eigen-headers -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_INSTALL_PREFIX=${HOME}/bempp/bempp-install
-make -j8
-make install
-
-# add the following line to the ~/.bashrc
-export PYTHONPATH=$PYTHONPATH:${HOME}/bempp/bempp-install/lib/python3.4/site-packages
-
-#------------------------------------------------------------------------------#
-
-# C) NGBEM
-# good thing: it's on github now - https://github.com/arieder/ngbem
-# since we use the purely Python based interface, cloning is sufficient.
-
-cd ~
-git clone https://github.com/arieder/ngbem.git ngbem
-
-# add the following line to the ~/.bashrc
-export PYTHONPATH=$PYTHONPATH:${HOME}/ngbem
-
-#------------------------------------------------------------------------------#
-
-# D) COMMICS
-# clone this repository, e.g.,
-cd ~
-mkdir commics
-cd commics
-git clone git@gitlab.asc.tuwien.ac.at:cpfeiler/commics.git
-
-# since commics is python3 based, nothing needs to be built
-
-# add the following line to the ~/.bashrc
-export PYTHONPATH=$PYTHONPATH:${HOME}/commics
-
-#------------------------------------------------------------------------------#
+# Commics is a Python3 module.
+# It requires the installation of Netgen/NGSolve, BEM++, NGBEM, and some Python3 packages, namely scipy numpy mpi4py and pyamg.
+# 
+# The required software packages have dependencies themselves.
+# To increase accessibility, this repository contains a shell script (local_installer.sh) taking care of the installation of Commics together with all its dependencies (and the dependencies thereof).
+# The script has been verified to work on a desktop PC with freshly installed Ubuntu 18.04 LTS.
+# To execute the shell script, do the following:
+
+chmod u+x local_installer.sh
+./local_installer.sh
+
+# At the beginning, you will be prompted to enter your password and confirm space requirements with Y(es) once or twice. These are the prompts of the "sudo apt" commands.
+
+# The script will do the following:
+#   - Use the package manager (sudo apt install) to install required packages
+#   - Use Python3-pip (sudo pip3 install) to install required Python packages
+#   - Create a folder (default ~/Software) where Commics and its dependencies will be located
+#   - Use gcc-8 to build Netgen/NGSolve and BEM++
+#   - Clone NGBEM from GitHub
+#   - Clone Commics from the GitLab of TU Wien
+#   - Write path variables to the file WRITE_PATHS_TO (default ~/.bashrc)
+ 
+# You can see the following variables and default-options in the first few lines of local_installer.sh:
+#   - SOFTWARE_DIR=~/Software               # ... Path to installation folder
+#   - NR_MAKE_THREADS=2                     # ... nr of jobs passed to "make -j", 
+#                                           #     may be increased if your hardware allows for it
+#   - PYTHON_INSTALLATION=/usr/bin/python3  # ... Your python3 installation
+#   - WRITE_PATHS_TO=~/.bashrc              # ... The file to which the exports of required path-variables are appended
+#                                           #     default=~/.bashrc (This file is sourced whenever you open a bash shell)
+
+# The following are the GIT hashes used for installation.
+# We recommend to use these versions, since this setup has been tested to work with Commics.
+# You are free to use different versions of Netgen/NGSolve, BEM++, NGBEM,
+# but as they are always under development, I cannot guarantee compatibility.
+#   - NGSOLVE_GIT_VERSION_HASH="0419c0285dae6589c32a5ddfaf0dea2e89a5e3b7"
+#   - BEMPP_GIT_VERSION_HASH="ce2ffc1ce52f07bf5890b19fb7c4389a7bb1031a"
+#   - NGBEM_GIT_VERSION_HASH="499138ca5dd17e812d3bdfdc0556afbff4ca340c"
+#   - COMMICS_GIT_VERSION_HASH=""
+
+
+# If you did not alter WRITE_PATHS_TO, then the correct paths will be set whenever you open a new bash shell.
+# That's it. Use "from commics import *" from within Pyhton3 to use Commics.
+# Have a look at the Python scripts inside commics/tests for some example scripts.
+
+# If you want to use Commics on a machine, where you do not have root privileges, consider these points for installation:
+#   - Root privileges are only required for the "sudo apt install" part of local_installer.sh
+#   - The sudo pip3 install [...] can be replaced by pip3 install [...] --user
+#   - See https://ngsolve.org/ for details on Netgen/NGSolve installation
+#   - See https://bempp.com/ for details on BEM++ installation
+#   - Apart from the official website, the instructions on http://roybijster.nl/2018/08/installing-bem-from-source are quite helpful.
diff --git a/local_installer.sh b/local_installer.sh
new file mode 100644
index 0000000..ad076ec
--- /dev/null
+++ b/local_installer.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+################################################################################
+SOFTWARE_DIR=~/Software
+NR_MAKE_THREADS=2
+PYTHON_INSTALLATION=/usr/bin/python3
+WRITE_PATHS_TO=~/.bashrc
+################################################################################
+NGSOLVE_GIT_VERSION_HASH="0419c0285dae6589c32a5ddfaf0dea2e89a5e3b7"
+BEMPP_GIT_VERSION_HASH="ce2ffc1ce52f07bf5890b19fb7c4389a7bb1031a"
+NGBEM_GIT_VERSION_HASH="499138ca5dd17e812d3bdfdc0556afbff4ca340c"
+COMMICS_GIT_VERSION_HASH=""
+################################################################################
+
+# install requirements
+sudo apt update
+sudo apt upgrade
+sudo apt install python3-tk libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++-8 gcc-8 libglu1-mesa-dev liblapacke-dev mpich libboost-all-dev libtbb-dev python3-pip cython3 patchelf
+export CXX=$(which g++-8)
+export CC=$(which gcc-8)
+sudo pip3 install numpy scipy mpi4py pyamg cython
+
+#ngsolve installation
+mkdir -p ${SOFTWARE_DIR}/ngsolve
+cd ${SOFTWARE_DIR}/ngsolve
+git clone https://github.com/NGSolve/ngsolve.git ngsolve-src
+mkdir ngsolve-install
+mkdir ngsolve-build
+cd ngsolve-src
+git checkout ${NGSOLVE_GIT_VERSION_HASH}
+git submodule update --init --recursive
+cd ../ngsolve-build
+cmake -DCMAKE_INSTALL_PREFIX=../ngsolve-install ../ngsolve-src
+make -j${NR_MAKE_THREADS}
+make install
+echo "export NETGENDIR=${SOFTWARE_DIR}/ngsolve/ngsolve-install/bin" >> ${WRITE_PATHS_TO} 
+echo "export PYTHONPATH=\${PYTHONPATH}:${SOFTWARE_DIR}/ngsolve/ngsolve-install/lib/python3/dist-packages" >> ${WRITE_PATHS_TO} 
+echo "export PATH=\${PATH}:\${NETGENDIR}" >> ${WRITE_PATHS_TO} 
+
+#bem++ installation
+mkdir -p ${SOFTWARE_DIR}/eigen
+cd ${SOFTWARE_DIR}/eigen
+wget "http://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2"
+tar -xjf 3.3.7.tar.bz2 
+mv eigen-eigen-* eigen-headers
+mkdir -p ${SOFTWARE_DIR}/bempp
+cd ${SOFTWARE_DIR}/bempp
+git clone https://bitbucket.org/bemppsolutions/bempp.git bempp-src
+cd bempp-src
+git checkout ${BEMPP_GIT_VERSION_HASH}
+cd ..
+mkdir bempp-install
+mkdir bempp-build
+cd bempp-build
+cmake ../bempp-src -DEIGEN3_INCLUDE_DIR=${SOFTWARE_DIR}/eigen/eigen-headers -DPYTHON_EXECUTABLE=${PYTHON_INSTALLATION} -DCMAKE_INSTALL_PREFIX=${SOFTWARE_DIR}/bempp/bempp-install
+make -j${NR_MAKE_THREADS}
+make install
+cd ${SOFTWARE_DIR}
+PYTHON3_SUB_BEMPP_FOLDER=$(ls ${SOFTWARE_DIR}/bempp/bempp-install/lib | grep python)
+echo "export PYTHONPATH=\${PYTHONPATH}:${SOFTWARE_DIR}/bempp/bempp-install/lib/${PYTHON3_SUB_BEMPP_FOLDER}/site-packages" >> ${WRITE_PATHS_TO}
+
+#ngbem clone
+cd ${SOFTWARE_DIR}
+git clone https://github.com/arieder/ngbem.git ngbem
+cd ngbem
+git checkout ${NGBEM_GIT_VERSION_HASH}
+echo "export PYTHONPATH=\${PYTHONPATH}:${SOFTWARE_DIR}/ngbem" >> ${WRITE_PATHS_TO} 
+
+#commics clone
+mkdir -p ${SOFTWARE_DIR}/commics
+cd ${SOFTWARE_DIR}/commics
+git clone https://geras.asc.tuwien.ac.at/cpfeiler/commics.git
+cd commics
+git checkout ${COMMICS_GIT_VERSION_HASH}
+echo "export PYTHONPATH=\${PYTHONPATH}:${SOFTWARE_DIR}/commics" >> ${WRITE_PATHS_TO} 
-- 
GitLab