简单来说,就是遍历运行目录下的所有算例。其中用到了一个工具foamRunTutorials,其接受两个参数-skipFirst和-test,查看帮助给出的说明分别是:do not execute the first Allrun script和run test loop。这样也看不出具体是干什么的!直接看foamRunTutorials脚本分析。
# Source tutorial run functions . "$WM_PROJECT_DIR/bin/tools/RunFunctions"
usage() { cat<<USAGE Usage: ${0##*/} [OPTIONS] options: -help | -h print the usage -skipFirst | -s do not execute the first Allrun script -test | -t run test loop Helper script used by the Allrun scripts in the OpenFOAM tutorials USAGE }
# If an argument is supplied do not execute ./Allrun to avoid recursion if ! $skipFirst && [ -f "./Allrun" ] # 既没有指定skipFirst参数且./Allrun也不存在 then # Run specialised Allrun script. 运行专门的Allrun脚本 ./Allrun $passArgs elif [ -d system ] then # Run normal case. 以普通算例的方式运行 application=$(getApplication) runApplication blockMesh runApplication "$application" 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 # MakefileDirs是foamRunTutorials专用的Makefile文件 $make -k -f "$WM_PROJECT_DIR/bin/tools/MakefileDirs" \ FOAM_TARGETS="$FOAM_TARGETS" \ FOAM_APP="$Script" FOAM_ARGS="$passArgs" fi
usage() { while [ "$#" -ge 1 ]; doecho"$1"; shift; done cat<<USAGE usage: ${0##*/} [OPTION] options: -root <dir> specify root directory to run tests from -default sets up a default scheme on all schemes -help print the usage * quickly tests the tutorials and writes out the scheme/solver information USAGE exit 1 }
setDefaultFvSchemes() { cat<<EOF gradSchemes { default Gauss linear; } divSchemes { default Gauss linear; div(phi,fu_ft_ha) Gauss multivariateSelection { fu upwind; ft upwind; h upwind; }; div(phi,ft_b_ha_hau) Gauss multivariateSelection { fu upwind; ft upwind; b upwind; h upwind; hu upwind; }; } laplacianSchemes { default Gauss linear corrected; } interpolationSchemes { default linear; } snGradSchemes { default corrected; } EOF }
# # VARIABLE # unset MAIN_CONTROL_DICT
for i in \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT \ $WM_PROJECT_DIR/etc \ ; do if [ -f "$i/controlDict" ] then MAIN_CONTROL_DICT="$i/controlDict" break fi done
[ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
if [ -d "$TEST_RUN_DIR" ] then rm -rf $TEST_RUN_DIR fi
echo"Modifying ${MAIN_CONTROL_DICT}" if [ -e ${MAIN_CONTROL_DICT}.orig ] then echo"File ${MAIN_CONTROL_DICT}.orig already exists" echo"Did Alltest fail in some way and then run again?" exit 1 fi
# Clean up on termination and on Ctrl-C trap'mv ${MAIN_CONTROL_DICT}.orig ${MAIN_CONTROL_DICT} 2>/dev/null; exit $retVal' \ EXIT TERM INT cp ${MAIN_CONTROL_DICT}${MAIN_CONTROL_DICT}.orig
echo"Copying the tutorials" cp -a ${TUTORIALS_DIR}${TEST_RUN_DIR}
echo"Modifying the controlDicts to run only one time step" cd${TEST_RUN_DIR} || exit 1
for CD in `find . -name "controlDict*"` do mv ${CD}${CD}.orig sed \ -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \ -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \ -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \ -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \ ${CD}.orig > ${CD} done
if [ "$DEFAULT_SCHEMES" = true ] then echo"Modifying the fvSchemes to contain only default schemes" for FV_SC in `find . -name fvSchemes` do for S in$FV_SCHEMES do mv ${FV_SC}${FV_SC}.orig sed -e /"${S}"/,/$p/d ${FV_SC}.orig > ${FV_SC} done setDefaultFvSchemes >> ${FV_SC} done fi