Adjust pexports and perl
[foam-extend-4.0.git] / bin / paraFoam
blob0b8c5a424b150b6a7870b6f73d0e68bdc39e3237
1 #!/bin/bash
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration |
6 # \\ / A nd | For copyright notice see file Copyright
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. 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 or .foam file
41 -nativeReader use the paraview native reader for OpenFOAM
43 * start paraview $ParaView_VERSION with the OpenFOAM libraries
45 USAGE
46 exit 1
49 unset regionName touchOnly useNativeReader
51 # parse options
52 while [ "$#" -gt 0 ]
54 case "$1" in
55 -h | -help)
56 usage
58 -case)
59 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
60 cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
61 shift 2
63 -region)
64 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
65 regionName=$2
66 shift 2
68 -touch)
69 touchOnly=true
70 shift
72 -nativeReader)
73 useNativeReader=true
74 shift
77 usage "unknown option/argument: '$*'"
79 esac
80 done
82 # get a sensible caseName
83 caseName=${PWD##*/}
85 if [ -n "$useNativeReader" ]
86 then
87 caseFileExt=".foam"
88 else
89 caseFileExt=".OpenFOAM"
92 caseFile="$caseName$caseFileExt"
94 fvControls="system"
96 if [ -n "$regionName" ]
97 then
98 caseFile="$caseName{$regionName}$caseFileExt"
99 fvControls="$fvControls/$regionName"
102 if [ -n "$touchOnly" ]
103 then
104 touch "$caseFile"
105 echo "created '$caseFile'"
106 exit 0
109 # parent directory for normal or parallel results
110 case "$caseName" in
111 processor*) parentDir=".." ;;
112 *) parentDir="." ;;
113 esac
115 # check existence of essential files
116 for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
118 [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
119 done
122 case "$ParaView_VERSION" in
124 trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
125 touch "$caseFile"
127 # since we are now in the cwd, %CASE% is '$PWD/$caseFile'
128 sed -e s@%CASE%@$PWD/$caseFile@g \
129 $WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
131 paraview paraFoam.pvs
135 # only create/remove caseFile if it didn't already exist
136 [ -e $caseFile ] || {
137 trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
138 touch "$caseFile"
139 echo "created temporary '$caseFile'"
142 paraview --data="$caseFile"
145 esac
146 #------------------------------------------------------------------------------