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 merge requests found
......@@ -121,17 +121,18 @@ do
if grep FoamFile $caseFile >/dev/null 2>&1
then
echo "Updating case file: $caseFile"
sed -n '/FoamFile/,/}/p' $caseFile > FoamFile
sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp
CLASS=`FoamFileAttribute class FoamFile`
OBJECT=`FoamFileAttribute object FoamFile`
FORMAT=`FoamFileAttribute format FoamFile`
CLASS=`FoamFileAttribute class FoamFile.tmp`
OBJECT=`FoamFileAttribute object FoamFile.tmp`
FORMAT=`FoamFileAttribute format FoamFile.tmp`
printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp
mv FoamFile.tmp $caseFile
rm FoamFile
# use cat to avoid removing/replace soft-links
[ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile
rm FoamFile.tmp
else
echo " Invalid case file: $caseFile"
fi
......
......@@ -57,15 +57,20 @@ USAGE
#
convertDict()
{
echo "Identified $1 turbulence model in '$3'"
outputPath=`dirname $3`
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"
if [ -e "$outputPath/$1Properties" ]
then
echo "Error: file already exists $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
......
......@@ -16,7 +16,7 @@ FoamFile
// General m4 macros
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(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
......
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