ENH: paraFoam : override LC_ALL to read ascii files
[OpenFOAM-1.7.x.git] / bin / paraFoam
blob63d08703f179835fdaae075696e4ee18876a8c96
1 #!/bin/sh
2 #---------------------------------*- sh -*-------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 #------------------------------------------------------------------------------
32 usage() {
33 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
34 cat<<USAGE
36 usage: ${0##*/} [OPTION]
37 options:
38 -case dir specify alternative case directory
39 -region name specify mesh region name
40 -touch only create the .OpenFOAM file
42 * start paraview $ParaView_VERSION with the OpenFOAM libraries
44 USAGE
45 exit 1
48 unset regionName touchOnly
50 # We want to do nice exit when running paraview to give paraview opportunity
51 # to clean up
52 unset FOAM_ABORT
55 # Hack: change all locale to 'C' i.e. using '.' for decimal point. This is
56 # only needed temporarily until paraview is locale aware.
57 export LC_ALL=C
60 # parse options
61 while [ "$#" -gt 0 ]
63 case "$1" in
64 -h | -help)
65 usage
67 -case)
68 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
69 cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
70 shift 2
72 -region)
73 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
74 regionName=$2
75 shift 2
77 -touch)
78 touchOnly=true
79 shift
82 usage "unknown option/argument: '$*'"
84 esac
85 done
87 # get a sensible caseName
88 caseName=${PWD##*/}
89 caseFile="$caseName.OpenFOAM"
90 fvControls="system"
92 if [ -n "$regionName" ]
93 then
94 caseFile="$caseName{$regionName}.OpenFOAM"
95 fvControls="$fvControls/$regionName"
98 if [ -n "$touchOnly" ]
99 then
100 touch "$caseFile"
101 echo "created '$caseFile'"
102 exit 0
105 # parent directory for normal or parallel results
106 case "$caseName" in
107 processor*) parentDir=".." ;;
108 *) parentDir="." ;;
109 esac
111 # check existence of essential files
112 for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
114 [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
115 done
118 case "$ParaView_VERSION" in
120 trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
121 touch "$caseFile"
123 # since we are now in the cwd, %CASE% is '$PWD/$caseFile'
124 sed -e s@%CASE%@$PWD/$caseFile@g \
125 $WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
127 paraview paraFoam.pvs
131 # only create/remove caseFile if it didn't already exist
132 [ -e $caseFile ] || {
133 trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
134 touch "$caseFile"
135 echo "created temporary '$caseFile'"
138 paraview --data="$caseFile"
141 esac
142 #------------------------------------------------------------------------------