Skip to content

Instantly share code, notes, and snippets.

@ic
Last active July 6, 2017 02:29
Show Gist options
  • Save ic/c9837d268bd2440649404e71ca1515ca to your computer and use it in GitHub Desktop.
Save ic/c9837d268bd2440649404e71ca1515ca to your computer and use it in GitHub Desktop.
Setup and prepare for running the OpenSimRoot demo.
#!/usr/bin/env bash
#
# Setup and prepare for visualizing the OpenSimRoot demo.
#
# Stages:
# * Get OpenSimRoot and its dependencies,
# * Get the demo data,
# * Execute the data crunching,
# * Explain how to run the visualization.
#
# This script tries to automate most of the steps to see the results.
#
# Tested on Linux (Ubuntu 16_04).
#
# Usage:
# * [If necessary] Make executable: `chmod +x run_opensimroot_demo`
# * Run with: `./run_opensimroot_demo`
#
set -e
# Check a directory exit, and make it as necessary.
function check_dir() {
if [ ! -d "$1" ]; then
mkdir -p "$1"
fi
}
# Check file is present and ready for use.
#
# Params:
# $1 Piece name, for reporting only.
# $2 File name to check.
# $3 Command to get the file, if necessary.
# $4 Post-processing command, if necessary.
function check_file() {
if [ ! -f "$2" ]; then
echo -n "Getting $1..."
$($3 > /dev/null)
$($4 > /dev/null)
echo "ok"
fi
}
DEMO_DIR=$(pwd)/osr_demo
TOOLS_DIR=$DEMO_DIR/tools
RUNFILES_DIR=$DEMO_DIR/runfiles
check_dir $DEMO_DIR
check_dir $TOOLS_DIR
check_dir $RUNFILES_DIR
PARAVIEW_FILE_NAME='ParaView-5.4.0-Qt5-OpenGL2-MPI-Linux-64bit.tar.gz'
pushd $TOOLS_DIR
check_file "OpenSimRoot" "OpenSimRoot_Linux_x64" \
"wget http://rootmodels.gitlab.io/OpenSimRoot/executables/OpenSimRoot_Linux_x64" \
"chmod +x OpenSimRoot_Linux_x64"
check_file "OSR Demo Data" "inputfiles_osr.zip" \
"wget http://rootmodels.gitlab.io/OpenSimRoot/inputfiles/inputfiles_osr.zip" \
"unzip inputfiles_osr.zip"
check_file "ParaView" "$PARAVIEW_FILE_NAME" \
"wget -O $PARAVIEW_FILE_NAME https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.4&type=binary&os=linux64&downloadFile=$PARAVIEW_FILE_NAME" \
"tar xvfz $PARAVIEW_FILE_NAME"
popd
pushd $RUNFILES_DIR
$TOOLS_DIR/OpenSimRoot_Linux_x64 -f $TOOLS_DIR/InputFiles/runBean.xml
popd
echo "Vizualize demo results with: $TOOLS_DIR/ParaView-5.4.0-Qt5-OpenGL2-MPI-Linux-64bit/bin/paraview --mesa"
echo " * In the paraview console, open:"
echo " $RUNFILES_DIR/visualisationroots.pvd"
echo " or"
echo " $RUNFILES_DIR/visualisation_phosphorus_DepletionZone.pvd"
echo " data file."
echo " * After opening a file, press the Apply button on the left-hand side panel, then the play button on the top panel."
echo " * Playing the file should show daily root growth. You can try the different colour settings to see interesting representations."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment