Merge commit 'b5be6201e00421a59e574a07b3d28cde5defff84'
[foam-extend-4.0.git] / bin / paraFoam
blob1ea5907b5f32c9b6777165148f52cf01b7640d2a
1 #!/bin/bash
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 4.0
6 # \\ / A nd | Web: http://www.foam-extend.org
7 # \\/ M anipulation | For copyright notice see file Copyright
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 # This is needed for systems that are using comma as the decimal separator
52 export LC_NUMERIC=C
54 # parse options
55 while [ "$#" -gt 0 ]
57 case "$1" in
58 -h | -help)
59 usage
61 -case)
62 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
63 cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
64 shift 2
66 -region)
67 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
68 regionName=$2
69 shift 2
71 -touch)
72 touchOnly=true
73 shift
75 -nativeReader)
76 useNativeReader=true
77 shift
80 usage "unknown option/argument: '$*'"
82 esac
83 done
85 # get a sensible caseName
86 caseName=${PWD##*/}
88 if [ -n "$useNativeReader" ]
89 then
90 caseFileExt=".foam"
91 else
92 caseFileExt=".OpenFOAM"
95 caseFile="$caseName$caseFileExt"
97 fvControls="system"
99 if [ -n "$regionName" ]
100 then
101 caseFile="$caseName{$regionName}$caseFileExt"
102 fvControls="$fvControls/$regionName"
105 if [ -n "$touchOnly" ]
106 then
107 touch "$caseFile"
108 echo "created '$caseFile'"
109 exit 0
112 # parent directory for normal or parallel results
113 case "$caseName" in
114 processor*) parentDir=".." ;;
115 *) parentDir="." ;;
116 esac
118 # check existence of essential files
119 for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
121 [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
122 done
125 case "$ParaView_VERSION" in
127 trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
128 touch "$caseFile"
130 # since we are now in the cwd, %CASE% is '$PWD/$caseFile'
131 sed -e s@%CASE%@$PWD/$caseFile@g \
132 $WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
134 paraview paraFoam.pvs
138 # only create/remove caseFile if it didn't already exist
139 [ -e $caseFile ] || {
140 trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
141 touch "$caseFile"
142 echo "created temporary '$caseFile'"
145 paraview --data="$caseFile"
148 esac
149 #------------------------------------------------------------------------------