finally drop references to ~/.OpenFOAM-<ver> (use ~/.OpenFOAM/<ver>)

This commit is contained in:
Mark Olesen
2009-05-07 10:37:55 +02:00
parent 1cdbeb29d7
commit d2a78f7e96
4 changed files with 103 additions and 99 deletions

View File

@ -38,8 +38,8 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: ${0##*/} [OPTION] <application> ... usage: ${0##*/} [OPTION] <application> ...
@ -50,16 +50,17 @@ options:
* run a particular OpenFOAM version of <application> * run a particular OpenFOAM version of <application>
USAGE USAGE
exit 1 exit 1
} }
# This script should exist in <foamInstall>/OpenFOAM-<VERSION>/bin/ # This script should exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# extract the <foamInstall> and <version> elements # extract the <foamInstall> and <version> elements
# using a function preserves the command args # using a function preserves the command args
getDefaults() { getDefaults() {
set -- $(echo $0 | sed -e 's@/OpenFOAM-\([^/]*\)/bin/[^/]*$@ \1@') set -- $(echo $0 | sed -e 's@/OpenFOAM-\([^/]*\)/bin/[^/]*$@ \1@')
foamInstall=$1 foamInstall=$1
version=$2 version=$2
} }
getDefaults getDefaults
@ -67,72 +68,60 @@ getDefaults
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-v) -v)
shift shift
version=$1 version=$1
shift shift
;; ;;
--) --)
shift shift
break break
;; ;;
-*) -*)
usage "invalid option '$1'" usage "invalid option '$1'"
;; ;;
*) *)
break break
;; ;;
esac esac
done done
if [ "$#" -lt 1 ]; then if [ "$#" -lt 1 ]
usage "no application specified" then
usage "no application specified"
fi fi
unset foamDotFile unset foamDotFile
# Check user-specific OpenFOAM bashrc file # Check user-specific OpenFOAM bashrc file
for subDir in \ foamDotFile="$HOME/.OpenFOAM/$version/bashrc"
$HOME/.OpenFOAM-$version \ if [ -f $foamDotFile ]
$HOME/.OpenFOAM/$version \
;
do
foamDotFile="$subDir/bashrc"
if [ -f $foamDotFile ]; then
. $foamDotFile
foamDotFile=okay
break
fi
done
# Use the FOAM_INST_DIR variable for locating the installed version
if [ "$foamDotFile" != okay ]
then then
for FOAM_INST_DIR in $foamInstall $WM_PROJECT_INST_DIR . $foamDotFile
do foamDotFile=okay
for subDir in \ else
OpenFOAM-$version/etc \ # Use the FOAM_INST_DIR variable for locating the installed version
OpenFOAM-$version/.OpenFOAM-$version \ for FOAM_INST_DIR in $foamInstall $WM_PROJECT_INST_DIR
; do
do foamDotFile="$FOAM_INST_DIR/OpenFOAM-$version/etc/bashrc"
foamDotFile="$FOAM_INST_DIR/$subDir/bashrc" if [ -f $foamDotFile ]
if [ -f $foamDotFile ]; then then
. $foamDotFile . $foamDotFile
foamDotFile=okay foamDotFile=okay
break 2 break
fi fi
done done
done
fi fi
if [ "$foamDotFile" != okay ];
if [ "$foamDotFile" != okay ]
then then
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2 echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
exit 1 exit 1
fi fi
# Pass on the rest of the arguments # Pass on the rest of the arguments

View File

@ -36,7 +36,7 @@ echo "--------"
echo "Cleaning tutorials ..." echo "Cleaning tutorials ..."
echo "Removing backup files" echo "Removing backup files"
find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \; find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \;
find . \( -name 'core' -o -name 'core.[1-9]*' \) -exec rm {} \; find . \( -name core -o -name 'core.[1-9]*' \) -exec rm {} \;
find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \; find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \;
rm logs testLoopReport > /dev/null 2>&1 rm logs testLoopReport > /dev/null 2>&1

View File

@ -48,15 +48,19 @@ logReport () {
UzSS=`grep -E "Uz[:| ]*solution singularity" $1` UzSS=`grep -E "Uz[:| ]*solution singularity" $1`
completed=`grep -E "^[\t ]*[eE]nd" $1` completed=`grep -E "^[\t ]*[eE]nd" $1`
if [ "$fatalError" ] ; then if [ "$fatalError" ]
then
echo "$appAndCase: ** FOAM FATAL ERROR **" echo "$appAndCase: ** FOAM FATAL ERROR **"
return return
elif [ "$UxSS" -a "$UySS" -a "$UzSS" ] ; then elif [ "$UxSS" -a "$UySS" -a "$UzSS" ]
then
echo "$appAndCase: ** Solution singularity **" echo "$appAndCase: ** Solution singularity **"
return return
elif [ "$completed" ] ; then elif [ "$completed" ]
then
completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'` completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'`
if [ "$completionTime" ] ; then if [ "$completionTime" ]
then
completionTime="in $completionTime" completionTime="in $completionTime"
fi fi
echo "$appAndCase: completed $completionTime" echo "$appAndCase: completed $completionTime"
@ -90,5 +94,4 @@ done
find . -name "log.*" -exec cat {} \; >> logs find . -name "log.*" -exec cat {} \; >> logs
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View File

@ -27,25 +27,30 @@
# Alltest # Alltest
# #
# Description # Description
# quickly tests the tutorials and writes out the scheme/solver information
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
cd ${0%/*} || exit 1 # run from this directory cd ${0%/*} || exit 1 # run from this directory
# FUNCTIONS usage() {
# while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printUsage () { cat<<USAGE
cat <<EOF
Usage: $0
Quickly tests the tutorials and writes out the scheme/solver information
Options are: usage: $0 [OPTION]
-d sets up a default scheme on all schemes
-h help options:
EOF -d sets up a default scheme on all schemes
-h this usage
* quickly tests the tutorials and writes out the scheme/solver information
USAGE
exit 1
} }
setDefaultFvSchemes () {
setDefaultFvSchemes() {
cat<<EOF cat<<EOF
gradSchemes { default Gauss linear; } gradSchemes { default Gauss linear; }
divSchemes divSchemes
@ -72,23 +77,27 @@ snGradSchemes { default corrected; }
fluxRequired { default yes; } fluxRequired { default yes; }
EOF EOF
} }
# #
# VARIABLE # VARIABLE
# #
MAIN_CONTROL_DICT= unset MAIN_CONTROL_DICT
for i in \ for i in \
$HOME/.$WM_PROJECT-$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
$HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT \
$HOME/.$WM_PROJECT \ $WM_PROJECT_DIR/etc \
$WM_PROJECT_DIR/etc \ ;
;
do do
if [ -f "$i/controlDict" ]; then if [ -f "$i/controlDict" ]
MAIN_CONTROL_DICT="$i/controlDict" then
break MAIN_CONTROL_DICT="$i/controlDict"
fi break
fi
done done
[ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
TUTORIALS_DIR=. TUTORIALS_DIR=.
TEST_RUN_DIR=../tutorialsTest TEST_RUN_DIR=../tutorialsTest
FV_SCHEMES=\ FV_SCHEMES=\
@ -110,16 +119,16 @@ DEFAULT_SCHEMES=0
# OPTIONS # OPTIONS
# #
OPTS=`getopt hd $*` OPTS=`getopt hd $*`
if [ $? -ne 0 ] ; then if [ $? -ne 0 ]
echo "Aborting due to invalid option" then
printUsage usage "Aborting due to invalid option"
exit 1
fi fi
eval set -- "$OPTS" eval set -- "$OPTS"
while [ $1 != -- ]; do while [ $1 != -- ]
do
case $1 in case $1 in
-d) DEFAULT_SCHEMES=1;; -d) DEFAULT_SCHEMES=1;;
-h) printUsage; exit 1;; -h) usage;;
esac esac
shift shift
done done
@ -129,14 +138,15 @@ shift
# MAIN # MAIN
# #
if [ -d "$TEST_RUN_DIR" ] ; then if [ -d "$TEST_RUN_DIR" ]
then
rm -rf $TEST_RUN_DIR rm -rf $TEST_RUN_DIR
fi fi
echo "Modifying ${MAIN_CONTROL_DICT}" echo "Modifying ${MAIN_CONTROL_DICT}"
if [ -e ${MAIN_CONTROL_DICT}.org ] if [ -e ${MAIN_CONTROL_DICT}.org ]
then then
echo "File " ${MAIN_CONTROL_DICT}.org " already exists" echo "File ${MAIN_CONTROL_DICT}.org already exists"
echo "Did Alltest fail in some way and then run again?" echo "Did Alltest fail in some way and then run again?"
exit 1 exit 1
fi fi
@ -155,20 +165,21 @@ echo "Copying the tutorials"
cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR} cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
echo "Modifying the controlDicts to run only one time step" echo "Modifying the controlDicts to run only one time step"
cd ${TEST_RUN_DIR} cd ${TEST_RUN_DIR} || exit 1
for CD in `find . -name "controlDict*"` for CD in `find . -name "controlDict*"`
do do
mv ${CD} ${CD}.org mv ${CD} ${CD}.org
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}.org > ${CD} ${CD}.org > ${CD}
done done
if [ $DEFAULT_SCHEMES = 1 ] ; then if [ $DEFAULT_SCHEMES = 1 ]
then
echo "Modifying the fvSchemes to contain only default schemes" echo "Modifying the fvSchemes to contain only default schemes"
for FV_SC in `find . -name fvSchemes` for FV_SC in `find . -name fvSchemes`
do do
@ -205,7 +216,8 @@ do
done done
echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
done done
if [ -f $SCHEMES_TEMP ] ; then if [ -f $SCHEMES_TEMP ]
then
cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
fi fi
done done