Skip to content
Snippets Groups Projects
Commit a34c8d63 authored by Mark Olesen's avatar Mark Olesen
Browse files

foamUpgradeTurbulenceProperties : do not use dirname with missing arguments

parent 931c30e6
Branches
Tags
No related merge requests found
......@@ -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` <turbulenceProperties>"
echo " Where <turbulenceProperties> is the full path to the"
echo " turbulenceProperties dictionary"
usage() {
cat<<USAGE
usage: ${0##*/} <turbulenceProperties>
Where <turbulenceProperties> 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
#------------------------------------------------------------------------------
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment