mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
foamUpgradeTurbulenceProperties : do not use dirname with missing arguments
This commit is contained in:
@ -30,51 +30,62 @@
|
|||||||
# Upgrade the turbulenceProperties dictionary to the new format employed
|
# Upgrade the turbulenceProperties dictionary to the new format employed
|
||||||
# in OpenFOAM version 1.5
|
# in OpenFOAM version 1.5
|
||||||
# - RAS turbulence models now defined by the RASProperties dictionary,
|
# - 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,
|
# - LES turbulence models now defined by the LESProperties dictionary,
|
||||||
# and LESModel keyword.
|
# and LESModel keyword.
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
printUsage()
|
usage() {
|
||||||
{
|
cat<<USAGE
|
||||||
echo "Usage: `basename $0` <turbulenceProperties>"
|
|
||||||
echo " Where <turbulenceProperties> is the full path to the"
|
usage: ${0##*/} <turbulenceProperties>
|
||||||
echo " turbulenceProperties dictionary"
|
|
||||||
|
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()
|
convertDict()
|
||||||
{
|
{
|
||||||
echo " Identified $1 turbulence model"
|
echo " Identified $1 turbulence model in $3"
|
||||||
|
outputPath=`dirname $3`
|
||||||
|
|
||||||
sed -e "s/turbulenceProperties/$1Properties/" \
|
sed -e "s/turbulenceProperties/$1Properties/" \
|
||||||
-e "s/$2/$1Model/" \
|
-e "s/$2/$1Model/" \
|
||||||
-e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \
|
-e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \
|
||||||
$3 > "$outputPath/$1Properties"
|
$3 > "$outputPath/$1Properties"
|
||||||
|
|
||||||
echo " written $1Properties to $outputPath/"
|
echo " wrote $outputPath/$1Properties"
|
||||||
}
|
}
|
||||||
|
|
||||||
outputPath=`dirname $1`
|
#
|
||||||
|
# Identify type of turbulence model and convert
|
||||||
if [ $# -ne 1 ]; then
|
#
|
||||||
printUsage
|
if grep turbulenceModel $turbDict >/dev/null 2>&1
|
||||||
exit 1
|
then
|
||||||
elif [ ! -e $1 ]; then
|
convertDict RAS turbulenceModel $turbDict
|
||||||
echo " Error: file $1 does not exist"
|
elif grep LESmodel $turbDict >/dev/null 2>&1
|
||||||
echo ""
|
then
|
||||||
printUsage
|
convertDict LES LESmodel $turbDict
|
||||||
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
|
|
||||||
else
|
else
|
||||||
echo "Unable to determine turbulence model type - nothing changed"
|
echo "Unable to determine turbulence model type - nothing changed"
|
||||||
exit 1
|
exit 1
|
||||||
@ -82,7 +93,4 @@ fi
|
|||||||
|
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user