mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve handling of etc/controlDict for Alltest
- only backup/modify controlDict if it contains a DebugSwitches entry - add -no-debug option to suppress modification entirely
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
# \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||||
@ -20,7 +20,7 @@
|
|||||||
# The entire OpenFOAM environment (WM_PROJECT_DIR, etc)
|
# The entire OpenFOAM environment (WM_PROJECT_DIR, etc)
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
cd ${0%/*} || exit 1 # Run from this directory
|
cd "${0%/*}" || exit 1 # Run from this directory
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
@ -33,6 +33,7 @@ usage: ${0##*/} [OPTION]
|
|||||||
options:
|
options:
|
||||||
-git Use git to retrieve the tutorials
|
-git Use git to retrieve the tutorials
|
||||||
-no-git Do not use git to retrieve the tutorials
|
-no-git Do not use git to retrieve the tutorials
|
||||||
|
-no-debug Do not adjust DebugSwitches (fvSchemes, solution)
|
||||||
-root dir Specify root directory to run tests from
|
-root dir Specify root directory to run tests from
|
||||||
-default Sets up a default scheme on all schemes
|
-default Sets up a default scheme on all schemes
|
||||||
-help Print the usage
|
-help Print the usage
|
||||||
@ -61,8 +62,9 @@ die()
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
ROOT="./"
|
ROOT="./"
|
||||||
unset DEFAULT_SCHEMES
|
useDefaultSchemes=false
|
||||||
useGit=auto
|
useGit=auto
|
||||||
|
adjustDebugSwitches=true
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
@ -82,8 +84,11 @@ do
|
|||||||
-no-git)
|
-no-git)
|
||||||
unset useGit
|
unset useGit
|
||||||
;;
|
;;
|
||||||
|
-no-debug)
|
||||||
|
unset adjustDebugSwitches
|
||||||
|
;;
|
||||||
-d | -default)
|
-d | -default)
|
||||||
DEFAULT_SCHEMES=true
|
useDefaultSchemes=true
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
die "Unknown option/argument: '$1'"
|
die "Unknown option/argument: '$1'"
|
||||||
@ -93,7 +98,7 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Set FOAM_TUTORIALS directory location, as required.
|
# Set FOAM_TUTORIALS directory location, as required.
|
||||||
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
. "${WM_PROJECT_DIR:?}/bin/tools/RunFunctions"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -131,17 +136,27 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Location of the user or project controlDict
|
# Locate the user or project controlDict to adjust
|
||||||
#
|
#
|
||||||
if MAIN_CONTROL_DICT="$($WM_PROJECT_DIR/bin/foamEtcFile -mode=uo controlDict)"
|
unset ETC_CONTROL_DICT
|
||||||
|
if [ "$adjustDebugSwitches" = true ]
|
||||||
then
|
then
|
||||||
if [ -e "${MAIN_CONTROL_DICT}.orig" ]
|
if ETC_CONTROL_DICT="$($WM_PROJECT_DIR/bin/foamEtcFile -mode=uo controlDict)"
|
||||||
then
|
then
|
||||||
die "File ${MAIN_CONTROL_DICT}.orig already exists" \
|
if [ -e "${ETC_CONTROL_DICT}.orig" ]
|
||||||
"Did Alltest fail in some way and then run again?"
|
then
|
||||||
|
die "File ${ETC_CONTROL_DICT}.orig already exists" \
|
||||||
|
"Did Alltest fail in some way and then run again?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
grep DebugSwitches "${ETC_CONTROL_DICT}" 1> /dev/null 2>&1 || {
|
||||||
|
echo "No DebugSwitches to adjust in ${ETC_CONTROL_DICT}" 1>&2
|
||||||
|
unset ETC_CONTROL_DICT
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "No main (user or project) controlDict to adjust" 1>&2
|
||||||
|
unset ETC_CONTROL_DICT
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
die "No main (user or project) controlDict found"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -176,7 +191,7 @@ buildDir="$WM_PROJECT_DIR/build/$WM_OPTIONS/${TEST_RUN_DIR##*/}"
|
|||||||
if [ -d "$buildDir" ]
|
if [ -d "$buildDir" ]
|
||||||
then
|
then
|
||||||
echo "Removing old build directory: $buildDir" 1>&2
|
echo "Removing old build directory: $buildDir" 1>&2
|
||||||
rm -rf $buildDir
|
rm -rf "$buildDir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset gitbase
|
unset gitbase
|
||||||
@ -208,7 +223,7 @@ fi
|
|||||||
if [ -n "$gitbase" ]
|
if [ -n "$gitbase" ]
|
||||||
then
|
then
|
||||||
echo "Copying the tutorials from current git branch" 1>&2
|
echo "Copying the tutorials from current git branch" 1>&2
|
||||||
mkdir -p ${TEST_RUN_DIR}
|
mkdir -p "${TEST_RUN_DIR}"
|
||||||
( cd "$gitbase/tutorials" && git archive --format=tar HEAD . ) | \
|
( cd "$gitbase/tutorials" && git archive --format=tar HEAD . ) | \
|
||||||
( cd "$TEST_RUN_DIR" && tar -xf - )
|
( cd "$TEST_RUN_DIR" && tar -xf - )
|
||||||
else
|
else
|
||||||
@ -216,37 +231,41 @@ else
|
|||||||
cp -a "$TUTORIALS_DIR" "$TEST_RUN_DIR"
|
cp -a "$TUTORIALS_DIR" "$TEST_RUN_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd "${TEST_RUN_DIR}" || exit 1
|
||||||
|
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
|
|
||||||
# Clean up on termination and on Ctrl-C
|
# Adjust etc controlDict, and clean up on termination and on Ctrl-C
|
||||||
trap 'mv ${MAIN_CONTROL_DICT}.orig ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
|
if [ -f "${ETC_CONTROL_DICT}" ]
|
||||||
EXIT TERM INT
|
then
|
||||||
cp -f "${MAIN_CONTROL_DICT}" "${MAIN_CONTROL_DICT}.orig"
|
trap 'mv ${ETC_CONTROL_DICT}.orig ${ETC_CONTROL_DICT} 2>/dev/null; exit 0' \
|
||||||
|
EXIT TERM INT
|
||||||
|
|
||||||
echo "Modifying ${MAIN_CONTROL_DICT}" 1>&2
|
echo "Modifying DebugSwitches: ${ETC_CONTROL_DICT}" 1>&2
|
||||||
|
|
||||||
sed \
|
cp -f "${ETC_CONTROL_DICT}" "${ETC_CONTROL_DICT}.orig"
|
||||||
-e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
|
sed \
|
||||||
-e s/"\(solution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
|
-e 's/\(fvSchemes[ \t]*\)\([0-9]\);/\1 1;/g' \
|
||||||
"${MAIN_CONTROL_DICT}.orig" > "${MAIN_CONTROL_DICT}"
|
-e 's/"\(solution[ \t]*\)\([0-9]\);/\1 1;/g' \
|
||||||
|
"${ETC_CONTROL_DICT}.orig" > "${ETC_CONTROL_DICT}"
|
||||||
|
fi
|
||||||
|
|
||||||
cd "${TEST_RUN_DIR}" || exit 1
|
echo "Modifying the case controlDicts to run only one time step" 1>&2
|
||||||
|
echo 1>&2
|
||||||
echo "Modifying the controlDicts to run only one time step" 1>&2
|
|
||||||
|
|
||||||
for CD in $(find . -name "controlDict*" -type f)
|
for CD in $(find . -name "controlDict*" -type f)
|
||||||
do
|
do
|
||||||
cp -f "${CD}" "${CD}.orig"
|
cp -f "${CD}" "${CD}.orig"
|
||||||
sed \
|
sed \
|
||||||
-e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
|
-e 's/\(startFrom[ \t]*\)\([a-zA-Z]*\);/\1 latestTime;/g' \
|
||||||
-e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
|
-e 's/\(stopAt[ \t]*\)\([a-zA-Z]*\);/\1 nextWrite;/g' \
|
||||||
-e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
|
-e 's/\(writeControl[ \t]*\)\([a-zA-Z]*\);/\1 timeStep;/g' \
|
||||||
-e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
|
-e 's/\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);/\1 1;/g' \
|
||||||
"${CD}.orig" > "${CD}"
|
"${CD}.orig" > "${CD}"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$DEFAULT_SCHEMES" = true ]
|
if [ "$useDefaultSchemes" = true ]
|
||||||
then
|
then
|
||||||
echo "Modifying the fvSchemes to contain only default schemes" 1>&2
|
echo "Modifying the fvSchemes to contain only default schemes" 1>&2
|
||||||
for FV_SC in $(find . -name fvSchemes -type f)
|
for FV_SC in $(find . -name fvSchemes -type f)
|
||||||
@ -260,10 +279,11 @@ then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -f Allrun ] || cp -f "${FOAM_TUTORIALS:?}/Allrun" .
|
||||||
cp -f $FOAM_TUTORIALS/Allrun .
|
|
||||||
./Allrun -test
|
./Allrun -test
|
||||||
|
|
||||||
|
|
||||||
|
# The rest here doesn't seem to be used
|
||||||
sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
|
sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
|
||||||
APPLICATIONS=\
|
APPLICATIONS=\
|
||||||
$(grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g')
|
$(grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g')
|
||||||
|
|||||||
Reference in New Issue
Block a user