Merge remote-tracking branch 'origin/BUGFIX/signInHerschelBuckley'
[foam-extend-3.0.git] / bin / foamProbe
bloba79f1d2adc5bf9639754ff28baadc3b2ae21051f
1 #!/bin/bash
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright held by original author
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 the
14 # Free Software Foundation; either version 3 of the License, or (at your
15 # 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, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # Script
27 # foamProbe
29 # Description
30 # Proccess a scalar, vetorial or tensorial field of OpenFOAM
31 # probe file (for monitoring points). The original file will not be changed
32 # and the fields of each monitoring point will be stored in a new
33 # directory named probe<Name> (where <Name> is the field name) in the
34 # directory where are the original probes files.
35 # The fourth optional parameter can be used to create xmgrace sequentially
36 # graphs (case is 0)
37 # for monitoring points or automatically create eps figures (case is 1).
40 # Author:
41 # Jovani L. Favero, J. F. Mitre (2009)
43 #------------------------------------------------------------------------------
45 if [ $# -lt 3 ]; then
46 echo "Usage: foamProbe [<probes files directory> <numbers of monitoring points> <field name> <optional value: 0 - open in xmgrace, 1 - save to eps file>]"
47 exit 1
50 # File name, NAME.
51 NAME=$(basename "$1")
52 DNAME="$1"
53 shift
55 # Number of points, P.
56 P="$1"
57 shift
59 NAME=$(basename "$1")
60 CNAME="$1"
61 shift
62 xmgrace=0
64 if [ $# -eq 1 ]; then
65 # Choose to save eps.
66 save="$1"
67 xmgrace=1
70 if [ ! -d "$DNAME" ]; then
71 echo "Directory $DNAME does not exist."
72 exit 1
75 if [ $P -lt 1 ]; then
76 echo "Can not be less than 1 single monitoring point."
77 exit 1
80 cd $DNAME
82 if [ ! -f "$CNAME" ]; then
83 echo "Field $CNAME does not exist."
84 exit 1
87 # Screen information
88 echo ""
89 echo "Wait: Processing $P point(s) in $CNAME file ...."
91 # Base directory to place processed files
92 DIR="./probe$NAME/"
93 if [ ! -d "$DIR" ]; then
94 mkdir "$DIR"
96 sed -e "s/ *(/\t/g" -e 's/)//g' "$CNAME" >"$DIR/$NAME"
97 cd $DIR
98 column=1
99 while [ "$column" -le "$P" ]; do
100 point=$column
101 column=`expr $column + 1`
102 cut -f 1,$column "$NAME" |sed -e "s/\t/ /g" -e '/^#/d' >$NAME.base
103 echo -e "# Time \t Point_$point" >$NAME\_$point
104 cat $NAME.base >>$NAME\_$point
105 rm -f $NAME.base
106 done
107 cd - &>/dev/null
109 if [ "$xmgrace" = 1 ]; then
110 cd probe$CNAME/
111 field=1
112 underscore=_
113 while [ "$field" -le "$P" ]; do
114 point=$field
115 field=`expr $field + 1`
116 echo " Opening file $CNAME$underscore$point"
117 if [ "$save" = 0 ]; then
118 echo " Opened $CNAME$underscore$point"
119 xmgrace -nxy $CNAME\_$point -noask
122 if [ "$save" -ne 0 ]; then
123 xmgrace -nxy $CNAME\_$point -hardcopy -printfile $CNAME\_$point.eps -hdevice EPS
124 echo " Saving file $CNAME$underscore$point.eps"
126 echo " Closing file $CNAME$underscore$point"
127 echo ""
128 done
131 echo ""
132 echo "Done!!!"
133 echo ""
135 exit 0