bin/script changes

foamUpdateCaseFileHeader:
      - handle multiple files
      - use fixed version width
      - replace grep/tr/cut -> sed

    foamUpgradeTurbulenceProperties:
      - handle multiple files
This commit is contained in:
Mark Olesen
2008-07-17 23:26:54 +02:00
parent a34c8d635b
commit 1884b91c8c
2 changed files with 97 additions and 77 deletions

View File

@ -41,24 +41,15 @@ usage() {
usage: ${0##*/} <turbulenceProperties>
Where <turbulenceProperties> is the full path to the
turbulenceProperties dictionary
Where <turbulenceProperties> is the full path to the
turbulenceProperties dictionary
Note: can upgrade several files at once
USAGE
exit 1
}
[ $# = 1 ] || usage
turbDict=$1
if [ ! -f $turbDict ]
then
echo " Error: file $turbDict does not exist"
echo ""
usage
fi
#
# $1: turbulence model
# $2: new properties type
@ -66,7 +57,7 @@ fi
#
convertDict()
{
echo " Identified $1 turbulence model in $3"
echo "Identified $1 turbulence model in '$3'"
outputPath=`dirname $3`
sed -e "s/turbulenceProperties/$1Properties/" \
@ -77,20 +68,26 @@ convertDict()
echo " wrote $outputPath/$1Properties"
}
#
# Identify type of turbulence model and convert
#
if grep turbulenceModel $turbDict >/dev/null 2>&1
then
convertDict RAS turbulenceModel $turbDict
elif grep LESmodel $turbDict >/dev/null 2>&1
then
convertDict LES LESmodel $turbDict
else
echo "Unable to determine turbulence model type - nothing changed"
exit 1
fi
[ $# -ge 1 ] || usage
echo "done."
for turbDict
do
# Identify type of turbulence model and convert
if [ -f $turbDict ]
then
if grep turbulenceModel $turbDict >/dev/null 2>&1
then
convertDict RAS turbulenceModel $turbDict
elif grep LESmodel $turbDict >/dev/null 2>&1
then
convertDict LES LESmodel $turbDict
else
echo "Unable to determine turbulence model type in '$turbDict'"
echo " - nothing changed"
fi
else
echo "Error: file '$turbDict' does not exist"
fi
done
#------------------------------------------------------------------------------