openfoam/bin/foamRunTutorials
Mark Olesen c5f4dbd866 ENH: foamRunTutorials now skips tutorials with Allrun-optional
- for tutorials that are known to run poorly, can provide a
  placeholder Allrun-optional instead of the usual Allrun script.
  If this is detected, the case will be skipped.
2018-01-09 16:44:32 +01:00

94 lines
2.6 KiB
Bash
Executable File

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# foamRunTutorials
#
# Description
# Run either Allrun or blockMesh/application in current directory
# and all its subdirectories.
#
# For tutorials that are known to run poorly, an Allrun-optional
# placeholder can be used instead of the usual Allrun script.
# When this is detected, the case will be skipped.
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
# Normally use standard "make"
make="make"
thisScript=$0
if [ "/${thisScript#/}" != "$thisScript" ]
then
thisScript="$PWD/$thisScript"
fi
unset passArgs runTests
skipFirst=false
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-t | -test)
passArgs="-test"
runTests=true
;;
# Avoid infinite recursion when invoked from an Allrun or Alltest script
-s | -skipFirst)
skipFirst=true
;;
*)
break
;;
esac
shift
done
if ! $skipFirst && $runTests && test -f Alltest
then
# Run specialized Alltest script
./Alltest $passArgs $*
elif ! $skipFirst && test -f Allrun
then
# Run specialized Allrun script
./Allrun $passArgs $*
elif ! $skipFirst && test -f Allrun-optional
then
# Found Allrun-optional script - skip this tutorial.
echo "Skipped optional case $PWD"
elif [ -d system ]
then
# Run normal case with blockMesh and the application
runApplication blockMesh
runApplication $(getApplication)
else
# Loop over sub-directories and compile any applications
for caseName in *
do
if [ -d $caseName -a -d "$caseName/Make" ]
then
( compileApplication $caseName )
fi
done
FOAM_TARGETS=$(for d in *; do [ -d "$d" ] && echo "$d"; done | xargs)
# Run all cases which have not already been run
$make -k -f $WM_PROJECT_DIR/bin/tools/MakefileDirs \
FOAM_TARGETS="$FOAM_TARGETS" \
FOAM_APP="$thisScript" FOAM_ARGS="$passArgs $*"
fi
#------------------------------------------------------------------------------