BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / bin / paraFoam
blob867212e50c458c471de76f86a6bd76b9b1a2e171
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
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
20 # for more details.
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/>.
25 # Script
26 # paraFoam
28 # Description
29 # start paraview with the OpenFOAM libraries
31 # Note
32 # combining -block or -builtin options with the -region option yields
33 # undefined behaviour
34 #------------------------------------------------------------------------------
35 usage() {
36 exec 1>&2
37 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
38 cat<<USAGE
40 Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
41 options:
42 -block use blockMesh reader (uses .blockMesh extension)
43 -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
44 -case <dir> specify alternative case directory, default is the cwd
45 -region <name> specify alternative mesh region
46 -touch only create the file (eg, .blockMesh, .OpenFOAM, etc)
47 -touchAll create .blockMesh, .OpenFOAM files (and for all regions)
48 -help print the usage
51 paraview options start with a double dashes
53 * start paraview $ParaView_VERSION with the OpenFOAM libraries
55 USAGE
56 exit 1
59 # We want to do nice exit when running paraview to give paraview opportunity
60 # to clean up
61 unset FOAM_ABORT
63 unset regionName optTouch
65 # Hack: change all locale to 'C' i.e. using '.' for decimal point. This is
66 # only needed temporarily until paraview is locale aware. (git version is
67 # already 2010-07)
68 export LC_ALL=C
70 # reader extension
71 extension=OpenFOAM
73 requirePV=1
75 # parse options
76 while [ "$#" -gt 0 ]
78 case "$1" in
79 -h | -help)
80 usage
82 -block | -blockMesh)
83 extension=blockMesh
84 shift
86 -builtin)
87 extension=foam
88 shift
90 -case)
91 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
92 cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
93 shift 2
95 -region)
96 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
97 regionName=$2
98 shift 2
100 -touch)
101 optTouch=true
102 requirePV=0
103 shift
105 -touchAll)
106 optTouch=all
107 requirePV=0
108 shift
111 shift
112 break # stop here, treat balance as paraview options
114 --*)
115 break # stop here, treat this and balance as paraview options
118 usage "unknown option/argument: '$*'"
120 esac
121 done
125 # check that reader module has been built
127 if [ $requirePV -eq 1 -a ! -f $PV_PLUGIN_PATH/libPV3FoamReader_SM.so ]
128 then
129 cat<< BUILDREADER
131 FATAL ERROR: ParaView reader module libraries do not exist
133 Please build the reader module before continuing:
134 cd \$FOAM_UTILITIES/postProcessing/graphics/PV3Readers
135 ./Allwclean
136 ./Allwmake
138 BUILDREADER
139 exit 1
143 # check for --data=... argument
145 hasDataArg()
147 hasData=false
148 while [ "$#" -gt 0 ]
150 case "$1" in
151 (--data=*)
152 hasData=true
153 break
155 esac
156 shift
157 done
160 hasDataArg $@
163 # get a sensible caseName from the directory name
164 caseName=${PWD##*/}
165 caseFile="$caseName.$extension"
166 fvControls="system"
168 if [ -n "$regionName" ]
169 then
170 caseFile="$caseName{$regionName}.$extension"
171 fvControls="$fvControls/$regionName"
174 case "${optTouch:-false}" in
175 all)
176 extension=OpenFOAM
177 if [ -f constant/polyMesh/blockMeshDict ]
178 then
179 touch "$caseName.blockMesh"
180 echo "created '$caseName.blockMesh'"
182 touch "$caseName.$extension"
183 echo "created '$caseName.$extension'"
184 # discover probable regions
185 for region in constant/*
187 if [ -d $region -a -d $region/polyMesh ]
188 then
189 regionName=${region##*/}
190 touch "$caseName{$regionName}.$extension"
191 echo "created '$caseName{$regionName}.$extension'"
193 done
194 exit 0
196 true)
197 touch "$caseFile"
198 echo "created '$caseFile'"
199 exit 0
201 esac
204 # parent directory for normal or parallel results
205 case "$caseName" in
206 processor*) parentDir=".." ;;
207 *) parentDir="." ;;
208 esac
211 if [ "${hasData:-false}" = true ]
212 then
214 # has --data=.., send directly to paraview
215 exec paraview "$@"
217 else
219 # check existence of essential files
220 warn="WARN file does not exist:"
221 case $extension in
222 blockMesh)
223 for check in \
224 system/controlDict \
225 constant/polyMesh/blockMeshDict \
228 [ -s "$parentDir/$check" ] || {
229 [ -n "$warn" ] && echo "$warn" 1>&2
230 echo " $parentDir/$check" 1>&2
231 unset warn
233 done
236 builtin | OpenFOAM)
237 for check in \
238 system/controlDict \
239 $fvControls/fvSchemes \
240 $fvControls/fvSolution \
243 [ -s "$parentDir/$check" ] || {
244 [ -n "$warn" ] && echo "$warn" 1>&2
245 echo " $parentDir/$check" 1>&2
246 unset warn
248 done
250 esac
252 # only create/remove caseFile if it didn't already exist
253 [ -e $caseFile ] || {
254 trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
255 touch "$caseFile"
256 echo "created temporary '$caseFile'"
259 # For now filter out any ld.so errors. Caused by non-system compiler?
260 paraview --data="$caseFile" "$@" 2>&1 | fgrep -v 'Inconsistency detected by ld.so'
264 #------------------------------------------------------------------------------