initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / tutorials / Alltest
blob69eb8b9a28a25130e96fd1498717cd1e36aebd59
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2009 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 the
14 # Free Software Foundation; either version 2 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 # Alltest
29 # Description
30 # quickly tests the tutorials and writes out the scheme/solver information
32 #------------------------------------------------------------------------------
34 cd ${0%/*} || exit 1 # run from this directory
36 usage() {
37 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
38 cat<<USAGE
40 usage: $0 [OPTION]
42 options:
43 -d sets up a default scheme on all schemes
44 -h this usage
46 * quickly tests the tutorials and writes out the scheme/solver information
48 USAGE
49 exit 1
53 setDefaultFvSchemes() {
54 cat<<EOF
55 gradSchemes { default Gauss linear; }
56 divSchemes
58 default Gauss linear;
59 div(phi,fu_ft_h) Gauss multivariateSelection
61 fu upwind;
62 ft upwind;
63 h upwind;
65 div(phi,ft_b_h_hu) Gauss multivariateSelection
67 fu upwind;
68 ft upwind;
69 b upwind;
70 h upwind;
71 hu upwind;
74 laplacianSchemes { default Gauss linear corrected; }
75 interpolationSchemes { default linear; }
76 snGradSchemes { default corrected; }
77 fluxRequired { default yes; }
78 EOF
82 # VARIABLE
84 unset MAIN_CONTROL_DICT
86 for i in \
87 $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
88 $HOME/.$WM_PROJECT \
89 $WM_PROJECT_DIR/etc \
92 if [ -f "$i/controlDict" ]
93 then
94 MAIN_CONTROL_DICT="$i/controlDict"
95 break
97 done
99 [ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
101 TUTORIALS_DIR=.
102 TEST_RUN_DIR=../tutorialsTest
103 FV_SCHEMES=\
105 gradScheme \
106 divScheme \
107 laplacianScheme \
108 interpolationScheme \
109 snGradScheme \
110 fluxRequired \
112 SCHEMES_FILE="FvSchemes"
113 SCHEMES_TEMP="FvSchemes.temp"
114 SOLVERS_FILE="FvSolution"
115 SOLVERS_TEMP="FvSolution.temp"
116 DEFAULT_SCHEMES=0
119 # OPTIONS
121 OPTS=`getopt hd $*`
122 if [ $? -ne 0 ]
123 then
124 usage "Aborting due to invalid option"
126 eval set -- "$OPTS"
127 while [ $1 != -- ]
129 case $1 in
130 -d) DEFAULT_SCHEMES=1;;
131 -h) usage;;
132 esac
133 shift
134 done
135 shift
138 # MAIN
141 if [ -d "$TEST_RUN_DIR" ]
142 then
143 rm -rf $TEST_RUN_DIR
146 echo "Modifying ${MAIN_CONTROL_DICT}"
147 if [ -e ${MAIN_CONTROL_DICT}.org ]
148 then
149 echo "File ${MAIN_CONTROL_DICT}.org already exists"
150 echo "Did Alltest fail in some way and then run again?"
151 exit 1
154 # Clean up on termination and on Ctrl-C
155 trap 'mv ${MAIN_CONTROL_DICT}.org ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
156 EXIT TERM INT
157 cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org
159 sed \
160 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
161 -e s/"\(fvSolution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
162 ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT}
164 echo "Copying the tutorials"
165 cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
167 echo "Modifying the controlDicts to run only one time step"
168 cd ${TEST_RUN_DIR} || exit 1
170 for CD in `find . -name "controlDict*"`
172 mv ${CD} ${CD}.org
173 sed \
174 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
175 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
176 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
177 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
178 ${CD}.org > ${CD}
179 done
181 if [ $DEFAULT_SCHEMES = 1 ]
182 then
183 echo "Modifying the fvSchemes to contain only default schemes"
184 for FV_SC in `find . -name fvSchemes`
186 for S in $FV_SCHEMES
188 mv ${FV_SC} ${FV_SC}.org
189 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
190 done
191 setDefaultFvSchemes >> ${FV_SC}
192 done
195 ./Allrun
197 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
198 APPLICATIONS=\
199 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
201 rm $SCHEMES_FILE > /dev/null 2>&1
202 for APP in $APPLICATIONS
204 echo $APP >> $SCHEMES_FILE
205 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
206 for ST in $FV_SCHEMES
208 rm $SCHEMES_TEMP > /dev/null 2>&1
209 rm $SOLVERS_TEMP > /dev/null 2>&1
210 echo " ${ST}" >> $SCHEMES_FILE
211 for LOG in `find ${APP} -name "log.${APP}"`
213 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
215 echo " ${S}" >> $SCHEMES_TEMP
216 done
217 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
218 done
219 if [ -f $SCHEMES_TEMP ]
220 then
221 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
223 done
224 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
225 echo "" >> $SOLVERS_FILE
226 done
229 # ----------------------------------------------------------------- end-of-file