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

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

parent 2e6f9962
No related branches found
No related tags found
No related merge requests found
...@@ -121,17 +121,18 @@ do ...@@ -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
......
...@@ -57,15 +57,20 @@ USAGE ...@@ -57,15 +57,20 @@ USAGE
# #
convertDict() convertDict()
{ {
echo "Identified $1 turbulence model in '$3'" echo "Identified $1 turbulence model in '$3'"
outputPath=`dirname $3` outputPath=`dirname $3`
sed -e "s/turbulenceProperties/$1Properties/" \ if [ -e "$outputPath/$1Properties" ]
-e "s/$2/$1Model/" \ then
-e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \ echo "Error: file already exists $outputPath/$1Properties'"
$3 > "$outputPath/$1Properties" else
sed -e "s/turbulenceProperties/$1Properties/" \
-e "s/$2/$1Model/" \
-e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \
$3 > "$outputPath/$1Properties"
echo " wrote $outputPath/$1Properties" echo " wrote $outputPath/$1Properties"
fi
} }
[ $# -ge 1 ] || usage [ $# -ge 1 ] || usage
......
...@@ -16,7 +16,7 @@ FoamFile ...@@ -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))])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment