foamUpdate scripts - avoid destroying soft-links or trashing existing {RAS,LES}Properties

This commit is contained in:
Mark Olesen 2008-08-08 23:15:28 +02:00
parent 2e6f99627b
commit 3bc28f6cb0
3 changed files with 20 additions and 14 deletions

View File

@ -121,17 +121,18 @@ do
if grep FoamFile $caseFile >/dev/null 2>&1 if grep FoamFile $caseFile >/dev/null 2>&1
then then
echo "Updating case file: $caseFile" echo "Updating case file: $caseFile"
sed -n '/FoamFile/,/}/p' $caseFile > FoamFile sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp
CLASS=`FoamFileAttribute class FoamFile` CLASS=`FoamFileAttribute class FoamFile.tmp`
OBJECT=`FoamFileAttribute object FoamFile` OBJECT=`FoamFileAttribute object FoamFile.tmp`
FORMAT=`FoamFileAttribute format FoamFile` FORMAT=`FoamFileAttribute format FoamFile.tmp`
printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp
mv FoamFile.tmp $caseFile # use cat to avoid removing/replace soft-links
rm FoamFile [ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile
rm FoamFile.tmp
else else
echo " Invalid case file: $caseFile" echo " Invalid case file: $caseFile"
fi fi

View File

@ -60,12 +60,17 @@ convertDict()
echo "Identified $1 turbulence model in '$3'" echo "Identified $1 turbulence model in '$3'"
outputPath=`dirname $3` outputPath=`dirname $3`
if [ -e "$outputPath/$1Properties" ]
then
echo "Error: file already exists $outputPath/$1Properties'"
else
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 " wrote $outputPath/$1Properties" echo " wrote $outputPath/$1Properties"
fi
} }
[ $# -ge 1 ] || usage [ $# -ge 1 ] || usage

View File

@ -16,7 +16,7 @@ FoamFile
// General m4 macros // General m4 macros
changecom(//)changequote([,]) changecom(//)changequote([,])
define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; print ($1)')]) define(calc, [esyscmd(perl -e 'use Math::Trig; use POSIX; printf ($1)')])
define(VCOUNT, 0) define(VCOUNT, 0)
define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))]) define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])