From afd9d5304ce6196c5ba688a17c458866748591d6 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Wed, 22 Apr 2020 15:55:31 +0000 Subject: [PATCH] Merge branch 'cleanup/installscript' into 'master' Cleanup/installscript Closes #848 See merge request dumux-repositories/dumux!1965 (cherry picked from commit 7a6fd6d41d4e81b60f5f56f2842a2bab7088a6db) acaf8100 [install] move and modify installscript b0775e20 [install][handbook] Modify the description of the quick install 14914915 [install][external] Add install course and lecture as options 204468d5 [bin][install] Fix several issues with installdumux.sh script ed7e6247 [install] add check for existing cmake.opts file --- bin/installdumux.sh | 102 +++++++++++++++++++++++++++++ bin/installexternal.sh | 40 +++++++++++ bin/util/test_dumux.sh | 6 ++ doc/handbook/2_quickinstall.tex | 70 ++++++++++++++------ doc/handbook/4_course.tex | 3 +- doc/handbook/4_furtherpractice.tex | 6 +- doc/handbook/installDumux.sh | 44 ------------- 7 files changed, 202 insertions(+), 69 deletions(-) create mode 100755 bin/installdumux.sh create mode 100644 bin/util/test_dumux.sh delete mode 100644 doc/handbook/installDumux.sh diff --git a/bin/installdumux.sh b/bin/installdumux.sh new file mode 100755 index 0000000000..5956e07d3f --- /dev/null +++ b/bin/installdumux.sh @@ -0,0 +1,102 @@ +# One click install script for dumux +echo " " +echo " " +echo "*********************************************************************************************" +echo "(0/3) Checking all prerequistes. (git gcc g++ cmake pkg-config paraview)" +echo "*********************************************************************************************" + +# check some prerequistes +for PRGRM in wget git gcc g++ cmake pkg-config; do + if ! [ -x "$(command -v $PRGRM)" ]; then + echo "ERROR: $PRGRM is not installed." >&2 + exit 1 + fi +done + +if ! [ -x "$(command -v paraview)" ]; then + echo "*********************************************************************************************" + echo "WARNING: paraview seems to be missing. You may not be able to view simulation results!" >&2 + echo "*********************************************************************************************" +fi + +currentver="$(gcc -dumpversion)" +requiredver="7" +if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" != "$requiredver" ]; then + echo "gcc greater than or equal to $requiredver is required for dumux releases >=3.2!" >&2 + exit 1 +fi + +if [ $? -ne 0 ]; then + echo "*********************************************************************************************" + echo "(0/3) An error occured while checking for prerequistes." + echo "*********************************************************************************************" + exit $? +else + echo "*********************************************************************************************" + echo "(1/3) All prerequistes found." + echo "*********************************************************************************************" +fi + + +# make a new folder containing everything +mkdir -p $(pwd)/DUMUX +cd DUMUX + +echo "*********************************************************************************************" +echo "(1/3) Cloning repositories. This may take a while. Make sure to be connected to the internet." +echo "*********************************************************************************************" +DUNE_VERSION=2.7 +DUMUX_VERSION=3.2 +# the core modules +for MOD in common geometry grid localfunctions istl +do + if [ ! -d "dune-$MOD" ]; then + git clone -b releases/$DUNE_VERSION https://gitlab.dune-project.org/core/dune-$MOD.git + else + echo "Skip cloning dune-$MOD because the folder already exists." + fi +done + +# dumux +if [ ! -d "dumux" ]; then + git clone -b releases/$DUMUX_VERSION https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git +else + echo "Skip cloning dumux because the folder already exists." +fi + +if [ $? -ne 0 ]; then + echo "*********************************************************************************************" + echo "(1/3) Failed to clone the repositories. Look for repository specific errors." + echo "*********************************************************************************************" + exit $? +else + echo "*********************************************************************************************" + echo "(2/3) All repositories have been cloned into a containing folder." + echo "*********************************************************************************************" +fi + +echo " " + +echo "**************************************************************************************************" +echo "(2/3) Configure and build dune modules and dumux using dunecontrol. This may take several minutes." +echo "**************************************************************************************************" + +# run dunecontrol +if [ ! -f "cmake.opts" ]; then + wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/raw/releases/3.2/cmake.opts +else + echo "A cmake.opts file already exists. The existing file will be used to configure dumux." +fi + +./dune-common/bin/dunecontrol --opts=cmake.opts all + +if [ $? -ne 0 ]; then + echo "*********************************************************************************************" + echo "(2/3) Failed to build the dune libaries." + echo "*********************************************************************************************" + exit $? +else + echo "*****************************************************************************************************" + echo "(3/3) Succesfully configured and built dune and dumux." + echo "*****************************************************************************************************" +fi diff --git a/bin/installexternal.sh b/bin/installexternal.sh index 9ffdbcb6ff..98d5da318d 100755 --- a/bin/installexternal.sh +++ b/bin/installexternal.sh @@ -10,6 +10,8 @@ DOWNLOAD_ONLY="n" TOPDIR=$(pwd) EXTDIR=$(pwd)/external +DUMUX_VERSION=3.2 + checkLocationForDuneModules() { # test for directory dune-common, dune-common-2.4 etc. @@ -53,6 +55,19 @@ installAluGrid() fi } +installCourse() +{ + cd $TOPDIR + if [ ! -d "dumux-course" ]; then + git clone -b releases/$DUMUX_VERSION https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course.git + else + echo "Skip cloning dumux-course because the folder already exists." + cd dumux-course + git checkout releases/$DUMUX_VERSION + cd .. + fi +} + installFoamGrid() { cd $TOPDIR @@ -135,6 +150,19 @@ installGStat() fi } +installLecture() +{ + cd $TOPDIR + if [ ! -d "dumux-lecture" ]; then + git clone -b releases/$DUMUX_VERSION https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-lecture.git + else + echo "Skip cloning dumux-lecture because the folder already exists." + cd dumux-lecture + git checkout releases/$DUMUX_VERSION + cd .. + fi +} + installMETIS() { cd $EXTDIR @@ -404,9 +432,11 @@ usage() echo "Where PACKAGES is one or more of the following" echo " all Install everything and the kitchen sink." echo " alugrid Download dune-alugrid." + echo " course Download the dumux-course." echo " foamgrid Download dune-foamgrid." echo " glpk Download and install glpk." echo " gstat Download and install gstat." + echo " lecture Download the dumux-lecture." echo " metis Install the METIS graph partitioner." echo " multidomain Download dune-multidomain." echo " multidomaingrid Download and patch dune-multidomaingrid." @@ -471,9 +501,11 @@ for TMP in "$@"; do SOMETHING_DONE="y" createExternalDirectory installAluGrid + installCourse installFoamGrid installGLPK installGStat + installLecture installMETIS installMultidomain installMultidomainGrid @@ -487,6 +519,10 @@ for TMP in "$@"; do SOMETHING_DONE="y" installAluGrid ;; + course) + SOMETHING_DONE="y" + installCourse + ;; foamgrid|dune-foamgrid) SOMETHING_DONE="y" installFoamGrid @@ -501,6 +537,10 @@ for TMP in "$@"; do createExternalDirectory installGStat ;; + lecture) + SOMETHING_DONE="y" + installLecture + ;; metis) SOMETHING_DONE="y" createExternalDirectory diff --git a/bin/util/test_dumux.sh b/bin/util/test_dumux.sh new file mode 100644 index 0000000000..6a55344cb0 --- /dev/null +++ b/bin/util/test_dumux.sh @@ -0,0 +1,6 @@ +# Test to see if the download and configuration worked properly + +cd DUMUX/dumux/build-cmake/test/porousmediumflow/1p/implicit/isothermal +make test_1p_tpfa +./test_1p_tpfa params.input +paraview *pvd diff --git a/doc/handbook/2_quickinstall.tex b/doc/handbook/2_quickinstall.tex index 88656a8686..8f9e256f11 100644 --- a/doc/handbook/2_quickinstall.tex +++ b/doc/handbook/2_quickinstall.tex @@ -3,38 +3,68 @@ For this quick start guide the following software packages are required: \begin{itemize} \item GitLab client \item A standard-compliant C++17 compiler supporting the C++11/C++14/C++17 features of GCC 7 -(\Dumux $> 3.1$\footnote{\Dumux $\leq 3.1$ only requires the C++11/C++14 feature set of GCC 4.9, e.g. GCC 4.9 or newer and Clang 3.8 or newer}), -e.g. GCC 7 or newer and Clang 5 or newer. +(\Dumux $> 3.1$\footnote{\Dumux $\leq 3.1$ only requires the C++11/C++14 feature set of GCC 4.9, +e.g. GCC 4.9 or newer and Clang 3.8 or newer}), e.g. GCC 7 or newer and Clang 5 or newer. \item CMake 2.8.12 or newer \item pkg-config \item ParaView (to visualize the results) \end{itemize} \section{Obtaining code and configuring all modules with a script} -We provide you with a shell-script \texttt{installDumux.sh} that facilitates setting up a {\Dune}/{\Dumux} directory tree -and configures all modules with CMake. -Copy the following lines into a text file named \texttt{installDumux.sh}: -\lstinputlisting[style=DumuxCode, numbersep=5pt, firstline=1, firstnumber=1]{installDumux.sh} +To easily install Dumux, we've provided a shell-script \texttt{installdumux.sh} that facilitates +setting up a {\Dune}/{\Dumux} directory tree and configures all modules with CMake. +First, you will have to download this script. To do this, first navigate to the directory where you +want to install \Dumux and \Dune (a single root folder \texttt{DUMUX} will be produced, so you do +not need to provide one). Then use \texttt{wget} to download the script with the following command: +\begin{lstlisting}[style=Bash] +$ wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/raw/releases/3.2/bin/installdumux.sh +\end{lstlisting} -Place the \texttt{installDumux.sh} script in the directory where you want to install \Dumux and \Dune (a single -root folder \texttt{DUMUX} will be produced, so you do not need to provide one). Make \texttt{installDumux.sh} executable and run the script by typing into the terminal: \texttt{./installDumux.sh} +After the download is complete, execute the script. This can be done with +\begin{lstlisting}[style=Bash] +$ sh installdumux.sh +\end{lstlisting} -Configuring \Dune and \Dumux is done by the command-line script \texttt{dunecontrol} -using optimized configure options, see the line entitled \texttt{\# run build} in the \texttt{installDumux.sh} script. +This script will download each of the \Dune-modules that \Dumux depends on at their 2.7 release, +as well as \Dumux's 3.2 release. After these individual modules are downloaded, \Dune and \Dumux +are automatically configured using the command-line script \texttt{dunecontrol}, located in +\texttt{dune-common/bin/dunecontrol}, optimized using configure options defined in the \texttt{cmake.opts} +file located in \texttt{dumux/cmake.opts}. The commands beneath the \texttt{\# run dunecontrol} in +the \texttt{installdumux.sh} script execute this configuration script, so no further steps are required. More details about the build-system can be found in section \ref{buildIt}. \subsection{A first test run of \Dumux} -When the \texttt{installDumux.sh} script from the subsection above has run successfully, you can execute a second script that -will compile and run a simple one-phase ground water flow example and will visualize the result using ParaView. -The test script can be obtained by copying the following lines into a text file named \texttt{test\_dumux.sh} -that has to be located in the same directory as the installation script. -\begin{lstlisting}[style=DumuxCode] +When the \texttt{installdumux.sh} script from the subsection above has run successfully, +you run a simple test to ensure that the installation ran correctly. To do this, you can +begin by compiling an example problem and running the simulation. You can then visualize +the results using ParaView. We recommend looking at a basic single phase groundwater flow problem. +\begin{enumerate} +\item Navigate to this test in the build directory using: +\begin{lstlisting}[style=Bash] cd DUMUX/dumux/build-cmake/test/porousmediumflow/1p/implicit/isothermal -make -B test_1p_tpfa +\end{lstlisting} +\item Build the executable with the following command: +\begin{lstlisting}[style=Bash] +make test_1p_tpfa +\end{lstlisting} +\item Run the simulation with the parameters listed in \texttt{params.input} like this: +\begin{lstlisting}[style=Bash] ./test_1p_tpfa params.input +\end{lstlisting} +\item Visualize the results in paraview with: +\begin{lstlisting}[style=Bash] paraview *pvd \end{lstlisting} -After making \texttt{test\_dumux.sh} executable, it can be executed by typing into the terminal: \texttt{./test\_dumux.sh}. -If everything works fine, a ParaView window with the result should open automatically, showing the initial -conditions. Advance ParaView to the next frame (green arrow button) and rescale to data range (green double arrow on top right) to admire -the colorful pressure distribution. +\item Advance ParaView to the next frame (green arrow button) and rescale to data range +(green double arrow on top right) to admire the colorful pressure distribution. +\end{enumerate} + +These commands are compiled into \texttt{test\_dumux.sh}, which you can download and run +from the same directory from which you ran \texttt{installDumux.sh}. + +\begin{lstlisting}[style=Bash] +$ wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/raw/releases/3.2/bin/util/test_dumux.sh +$ wget sh test_dumux.sh +\end{lstlisting} + +For further information on how to get started with dumux, see Section \ref{chp:tutorial}. diff --git a/doc/handbook/4_course.tex b/doc/handbook/4_course.tex index 17016c5bbc..bb083fd8a9 100644 --- a/doc/handbook/4_course.tex +++ b/doc/handbook/4_course.tex @@ -25,7 +25,8 @@ $ wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/raw/rele \end{lstlisting} This script will install \texttt{dumux}, it's Dune dependencies, and the \texttt{dumux-course} repository. Within the directory \texttt{dumux-course} there are a series of exercises -and slides describing the previously described examples. \par +and slides describing the previously described examples. The course can also be added to your existing +dumux installation using the \texttt{installExternal.sh} script and the argument \texttt{course}.\par % The \Dumux course will be updated with each \Dumux release. The above script will download the correct version (\textbf{releases/3.2}) of both diff --git a/doc/handbook/4_furtherpractice.tex b/doc/handbook/4_furtherpractice.tex index 76c6c31209..194781c9b6 100644 --- a/doc/handbook/4_furtherpractice.tex +++ b/doc/handbook/4_furtherpractice.tex @@ -9,10 +9,8 @@ cases can be found in the class documentation \url{http://www.dumux.org/document Another possibility to gain more experience with \Dumux is the \texttt{dumux-lecture} module that contains different application examples that are used in the lectures at the Department of Hydromechanics and Modelling of Hydrosystems in Stuttgart. -The \texttt{dumux-lecture} module can be obtained as follows: -\begin{lstlisting}[style=Bash] -$ git clone https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-lecture.git -\end{lstlisting} +The \texttt{dumux-lecture} module can be obtained with the \texttt{installExternal.sh} +script and the argument \texttt{lecture}. The module is structured based on the different lectures: \begin{itemize} diff --git a/doc/handbook/installDumux.sh b/doc/handbook/installDumux.sh deleted file mode 100644 index fe06600aa2..0000000000 --- a/doc/handbook/installDumux.sh +++ /dev/null @@ -1,44 +0,0 @@ -# One click install script for dumux - -# make a new folder containing everything -mkdir $(pwd)/DUMUX -cd DUMUX - -echo "*************************************************" -echo "(1/2) Cloning repositories. This may take a while. -Make sure to be connected to the internet." -echo "*************************************************" -# the core modules -for MOD in common geometry grid localfunctions istl; do - git clone -b releases/2.6 https://gitlab.dune-project.org/core/dune-$MOD.git -done - -# dumux -git clone -b releases/3.1 https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git - -if [ $? -ne 0 ]; then - echo "*************************************************" - echo "Failed to clone the repositories." - echo "*************************************************" - exit $? -fi - -echo "*************************************************" -echo "(2/2) Configure dune modules and dumux. Build the -dune libaries. This may take several minutes." -echo "*************************************************" -# run build -./dune-common/bin/dunecontrol --opts=dumux/cmake.opts all -# -if [ $? -ne 0 ]; then - echo "*************************************************" - echo "Failed to build the dune libaries." - echo "*************************************************" - exit $? -fi - -# echo result -echo "*************************************************" -echo "Successfully configured and built dune and dumux." -echo "Please run the test_dumux.sh script to confirm everything works." -echo "*************************************************" -- GitLab