diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index 6b7aa8439ff85426d5aa82012978712ee8b0583e..805f4e128a72d215cf0eebc67d7477e4fe75b87a 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -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 diff --git a/bin/foamUpgradeTurbulenceProperties b/bin/foamUpgradeTurbulenceProperties index 8c1437aca6675224f53814c0e7cb2326e1c4e6c6..297b7e4e63567f6dc3cd6d1d817ce4e839292e3b 100755 --- a/bin/foamUpgradeTurbulenceProperties +++ b/bin/foamUpgradeTurbulenceProperties @@ -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 diff --git a/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4 b/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4 index cc851f6503f90da326a66561c0ccac74fb36f5dc..5e355fd7025a748a668cd3d55bfe9bd984c78869 100644 --- a/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4 +++ b/tutorials/interDyMFoam/sloshingTank3D/constant/polyMesh/blockMeshDict.m4 @@ -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))])