Skip to content
Snippets Groups Projects
foamRunTutorials 2.61 KiB
Newer Older
#!/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"
thisScript=$0
if [ "/${thisScript#/}" != "$thisScript" ]
then
    thisScript="$PWD/$thisScript"
fi

while [ "$#" -gt 0 ]
do
    case "$1" in
    -t | -test)

    # Avoid infinite recursion when invoked from an Allrun or Alltest script
if ! $skipFirst && $runTests && test -f Alltest
    # Run specialized Alltest script
elif ! $skipFirst && test -f Allrun
then
    # Run specialized Allrun script
elif ! $skipFirst && test -f Allrun-optional
then
    # Found Allrun-optional script - skip this tutorial.
    echo "Skipped optional case $PWD"
then
    # Run normal case with blockMesh and the application
    runApplication blockMesh
    runApplication $(getApplication)
else
    # Loop over sub-directories and compile any applications
        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

#------------------------------------------------------------------------------