From fbac898f53ed9a4ad34c98f1a271f8578cd18358 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 14 Jul 2008 10:12:20 +0200 Subject: [PATCH] updated foamClearPolyMesh * now removes the same files as Foam::polyMesh::removeFiles() * accepts -case option --- bin/foamClearPolyMesh | 94 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/bin/foamClearPolyMesh b/bin/foamClearPolyMesh index f54f148569..07531f68bf 100755 --- a/bin/foamClearPolyMesh +++ b/bin/foamClearPolyMesh @@ -27,20 +27,94 @@ # foamClearPolyMesh # # Description -# +# Remove the contents of the constant/polyMesh directory +# as per the Foam::polyMesh::removeFiles() method. +# #------------------------------------------------------------------------------ +usage() { + while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done + cat <&2 -if [ -d constant/polyMesh ]; then - echo "there is constant/polyMesh"; - cd constant/polyMesh +usage: ${0##*/} [-case dir] -elif [ -d polyMesh ]; then - echo "there is polyMesh"; - cd polyMesh -else - echo "in polyMesh directory"; + Remove the contents of the constant/polyMesh directory + as per the Foam::polyMesh::removeFiles() method. + +USAGE + exit 1 +} + +unset caseDir +unset meshDir + +# parse options +if [ "$#" -gt 0 ]; then + case "$1" in + -h | -help) + usage + ;; + -case) + shift + caseDir=$1 + [ "$#" -ge 1 ] || usage "'-case' option requires an argument" + cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" + meshDir="constant/polyMesh" + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac fi -rm -f pointFaces pointEdges pointCells faceEdges edges edgeFaces edgeCells cellEdges cellCells owner neighbour losort faceCentres faceAreas cellVolumes cellCentres +# meshDir is only set if -case was specified: insist upon 'constant/polyMesh' +if [ -n "$meshDir" ] +then + if [ ! -d "$meshDir" ] + then + echo "Error: no '$meshDir' in $caseDir" 1>&2 + exit 1 + fi +else + if [ -d constant/polyMesh ] + then + # use constant/polyMesh + meshDir=constant/polyMesh + elif [ -d polyMesh ] + then + # likely already in constant/ + meshDir=polyMesh + elif [ "${PWD##*/}" = polyMesh ] + then + # apparently already within polyMesh/ + meshDir=. + else + echo "Error: no appropriate 'polyMesh/' directory found" 1>&2 + exit 1 + fi +fi + + +# +# remove files and subdirectories +# +echo "Clearing ${caseDir:-.}/$meshDir" 1>&2 + +for i in \ + points \ + faces \ + owner \ + neighbour \ + cells \ + boundary \ + pointZones \ + faceZones \ + cellZones \ + meshModifiers \ + parallelData \ + sets \ +; +do + rm -rf $meshDir/$i +done #------------------------------------------------------------------------------