Merge branch 'master' of ssh://opencfd@repo.or.cz/srv/git/OpenFOAM-1.5.x
[OpenFOAM-1.5.x.git] / tutorials / Alltest
blobec3da8513b1fc09623253e12e19ade759677cac2
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2008 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
31 #------------------------------------------------------------------------------
33 # FUNCTIONS
35 printUsage () {
36 cat <<EOF
37 Usage: $0
38 Quickly tests the tutorials and writes out the scheme/solver information
40 Options are:
41 -d sets up a default scheme on all schemes
42 -h help
43 EOF
46 setDefaultFvSchemes () {
47 cat<<EOF
48 gradSchemes { default Gauss linear; }
49 divSchemes
51 default Gauss linear;
52 div(phi,fu_ft_h) Gauss multivariateSelection
54 fu upwind;
55 ft upwind;
56 h upwind;
58 div(phi,ft_b_h_hu) Gauss multivariateSelection
60 fu upwind;
61 ft upwind;
62 b upwind;
63 h upwind;
64 hu upwind;
67 laplacianSchemes { default Gauss linear corrected; }
68 interpolationSchemes { default linear; }
69 snGradSchemes { default corrected; }
70 fluxRequired { default yes; }
71 EOF
74 # VARIABLE
76 MAIN_CONTROL_DICT=
78 for i in \
79 $HOME/.$WM_PROJECT-$WM_PROJECT_VERSION \
80 $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
81 $HOME/.$WM_PROJECT \
82 $WM_PROJECT_DIR/etc \
85 if [ -f "$i/controlDict" ]; then
86 MAIN_CONTROL_DICT="$i/controlDict"
87 break
89 done
90 TUTORIALS_DIR=.
91 TEST_RUN_DIR=../tutorialsTest
92 FV_SCHEMES=\
93 " \
94 gradScheme \
95 divScheme \
96 laplacianScheme \
97 interpolationScheme \
98 snGradScheme \
99 fluxRequired \
101 SCHEMES_FILE="FvSchemes"
102 SCHEMES_TEMP="FvSchemes.temp"
103 SOLVERS_FILE="FvSolution"
104 SOLVERS_TEMP="FvSolution.temp"
105 DEFAULT_SCHEMES=0
108 # OPTIONS
110 OPTS=`getopt hd $*`
111 if [ $? -ne 0 ] ; then
112 echo "Aborting due to invalid option"
113 printUsage
114 exit 1
116 eval set -- "$OPTS"
117 while [ $1 != -- ]; do
118 case $1 in
119 -d) DEFAULT_SCHEMES=1;;
120 -h) printUsage; exit 1;;
121 esac
122 shift
123 done
124 shift
127 # MAIN
130 if [ -d "$TEST_RUN_DIR" ] ; then
131 rm -rf $TEST_RUN_DIR
134 echo "Modifying ${MAIN_CONTROL_DICT}"
135 if [ -e ${MAIN_CONTROL_DICT}.org ]
136 then
137 echo "File " ${MAIN_CONTROL_DICT}.org " already exists"
138 echo "Did Alltest fail in some way and then run again?"
139 exit 1
142 # Clean up on termination and on Ctrl-C
143 trap 'mv ${MAIN_CONTROL_DICT}.org ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
144 EXIT TERM INT
145 cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org
147 sed \
148 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
149 -e s/"\(fvSolution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
150 ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT}
152 echo "Copying the tutorials"
153 cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
155 echo "Modifying the controlDicts to run only one time step"
156 cd ${TEST_RUN_DIR}
158 for CD in `find . -name "controlDict*"`
160 mv ${CD} ${CD}.org
161 sed \
162 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
163 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
164 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
165 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
166 ${CD}.org > ${CD}
167 done
169 if [ $DEFAULT_SCHEMES = 1 ] ; then
170 echo "Modifying the fvSchemes to contain only default schemes"
171 for FV_SC in `find . -name fvSchemes`
173 for S in $FV_SCHEMES
175 mv ${FV_SC} ${FV_SC}.org
176 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
177 done
178 setDefaultFvSchemes >> ${FV_SC}
179 done
182 ./Allrun
184 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
185 APPLICATIONS=\
186 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
188 rm $SCHEMES_FILE > /dev/null 2>&1
189 for APP in $APPLICATIONS
191 echo $APP >> $SCHEMES_FILE
192 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
193 for ST in $FV_SCHEMES
195 rm $SCHEMES_TEMP > /dev/null 2>&1
196 rm $SOLVERS_TEMP > /dev/null 2>&1
197 echo " ${ST}" >> $SCHEMES_FILE
198 for LOG in `find ${APP} -name "log.${APP}"`
200 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
202 echo " ${S}" >> $SCHEMES_TEMP
203 done
204 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
205 done
206 if [ -f $SCHEMES_TEMP ] ; then
207 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
209 done
210 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
211 echo "" >> $SOLVERS_FILE
212 done
215 # ----------------------------------------------------------------- end-of-file