diff --git a/bin/foamUpgradeTurbulenceProperties b/bin/foamUpgradeTurbulenceProperties index 1f10d8551a..b5ba0a9b0b 100755 --- a/bin/foamUpgradeTurbulenceProperties +++ b/bin/foamUpgradeTurbulenceProperties @@ -30,51 +30,62 @@ # Upgrade the turbulenceProperties dictionary to the new format employed # in OpenFOAM version 1.5 # - RAS turbulence models now defined by the RASProperties dictionary, -# and RASModel keyword, and +# and RASModel keyword. # - LES turbulence models now defined by the LESProperties dictionary, # and LESModel keyword. # #------------------------------------------------------------------------------ -printUsage() -{ - echo "Usage: `basename $0` " - echo " Where is the full path to the" - echo " turbulenceProperties dictionary" +usage() { + cat< + + Where is the full path to the + turbulenceProperties dictionary + +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 +# $3: original dictionary +# convertDict() { - echo " Identified $1 turbulence model" + echo " Identified $1 turbulence model in $3" + outputPath=`dirname $3` sed -e "s/turbulenceProperties/$1Properties/" \ -e "s/$2/$1Model/" \ -e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \ $3 > "$outputPath/$1Properties" - echo " written $1Properties to $outputPath/" + echo " wrote $outputPath/$1Properties" } -outputPath=`dirname $1` - -if [ $# -ne 1 ]; then - printUsage - exit 1 -elif [ ! -e $1 ]; then - echo " Error: file $1 does not exist" - echo "" - printUsage - exit 1 -fi - -# Identify type of turbulence model -RAS=`grep turbulenceModel $1` -LES=`grep LESmodel $1` - -if [ -n "$RAS" ]; then - convertDict "RAS" "turbulenceModel" $1 -elif [ -n "$LES" ]; then - convertDict "LES" "LESmodel" $1 +# +# 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 @@ -82,7 +93,4 @@ fi echo "done." -exit 0 - - #------------------------------------------------------------------------------