2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
8 #-------------------------------------------------------------------------------
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
29 # Remove the contents of the constant/polyMesh directory
30 # as per the Foam::polyMesh::removeFiles() method.
32 #------------------------------------------------------------------------------
35 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
38 Usage: ${0##*/} [OPTION]
40 -case <dir> specify alternative case directory, default is the cwd
41 -region <name> specify alternative mesh region
44 Remove the contents of the constant/polyMesh directory as per the
45 Foam::polyMesh::removeFiles() method.
51 unset caseDir regionName
53 # parse a single option
61 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
62 cd "$2" 2>/dev
/null || usage
"directory does not exist: '$2'"
67 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
72 usage
"unknown option/argument: '$*'"
77 if [ -n "$regionName" ]
79 meshDir
=$regionName/polyMesh
84 # if -case was specified: insist upon 'constant/polyMesh'
87 if [ -d constant
/$meshDir ]
89 # use constant/polyMesh
90 meshDir
=constant
/$meshDir
92 echo "Error: no 'constant/$meshDir' in $caseDir" 1>&2
96 if [ -d constant
/$meshDir ]
98 # use constant/polyMesh
99 meshDir
=constant
/$meshDir
102 # likely already in constant/ - do not adjust anything
104 elif [ "${PWD##*/}" = polyMesh
-a -z "$regionName" ]
106 # apparently already within polyMesh/
109 echo "Error: no appropriate 'polyMesh/' directory found" 1>&2
116 # remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
117 # also remove .gz versions of the same files
119 echo "Clearing ${caseDir:-.}/$meshDir" 1>&2
140 rm -rf $meshDir/$i $meshDir/$i.gz
143 #------------------------------------------------------------------------------