updated foamClearPolyMesh
* now removes the same files as Foam::polyMesh::removeFiles() * accepts -case option
This commit is contained in:
parent
f22d251d60
commit
fbac898f53
@ -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 <<USAGE 1>&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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user