#!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." cd ${DIR} anisotropy-help() { echo "Usage:" echo " anisotropy [options]" echo "" echo "Commands:" echo " clean Clean project directory via git (.gitignore)." echo " init Activate environment and install dependencies." echo " run Start calculations and etc." echo " kill Kill current process by pid" echo " help Show help for commands." echo "" echo "Options:" echo " -c, --config Use custom configuration file." echo " -s, --safe Safe mode (skip successfuly computed mesh/flow)" echo " -a, --all All mode (overwrites everything)" } case $1 in clean) git clean -fdx ;; init) python -m venv env source env/bin/activate python -m pip install --upgrade pip python -m pip install -r requirements.txt deactivate ;; run) source ${OPENFOAM} source env/bin/activate mkdir "${DIR}/build" echo $$ >"${DIR}/build/anisotropy.pid" python "${DIR}/anisotropy/anisotropy.py" ${@:2} deactivate rm "${DIR}/build/anisotropy.pid" ;; kill) pkill -TERM -P $(cat "${DIR}/build/anisotropy.pid") rm "${DIR}/build/anisotropy.pid" ;; help) anisotropy-help exit 1 ;; *) echo "Unknown command." anisotropy-help exit 1 ;; esac