ENH: partialWrite: support regions
[OpenFOAM-1.7.x.git] / tutorials / Alltest
blobf0464a306e742c390db44d50c08d55e661d2f0cf
1 #!/bin/sh
2 #---------------------------------*- sh -*-------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2010 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
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your 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, see <http://www.gnu.org/licenses/>.
25 # Script
26 # Alltest
28 # Description
29 # quickly tests the tutorials and writes out the scheme/solver information
31 #------------------------------------------------------------------------------
33 cd ${0%/*} || exit 1 # run from this directory
35 usage() {
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
37 cat<<USAGE
39 usage: $0 [OPTION]
41 options:
42 -d sets up a default scheme on all schemes
43 -h this usage
45 * quickly tests the tutorials and writes out the scheme/solver information
47 USAGE
48 exit 1
52 setDefaultFvSchemes() {
53 cat<<EOF
54 gradSchemes { default Gauss linear; }
55 divSchemes
57 default Gauss linear;
58 div(phi,fu_ft_h) Gauss multivariateSelection
60 fu upwind;
61 ft upwind;
62 h upwind;
64 div(phi,ft_b_h_hu) Gauss multivariateSelection
66 fu upwind;
67 ft upwind;
68 b upwind;
69 h upwind;
70 hu upwind;
73 laplacianSchemes { default Gauss linear corrected; }
74 interpolationSchemes { default linear; }
75 snGradSchemes { default corrected; }
76 fluxRequired { default yes; }
77 EOF
81 # VARIABLE
83 unset MAIN_CONTROL_DICT
85 for i in \
86 $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
87 $HOME/.$WM_PROJECT \
88 $WM_PROJECT_DIR/etc \
91 if [ -f "$i/controlDict" ]
92 then
93 MAIN_CONTROL_DICT="$i/controlDict"
94 break
96 done
98 [ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
100 TUTORIALS_DIR=.
101 TEST_RUN_DIR=../tutorialsTest
102 FV_SCHEMES=\
104 gradScheme \
105 divScheme \
106 laplacianScheme \
107 interpolationScheme \
108 snGradScheme \
109 fluxRequired \
111 SCHEMES_FILE="FvSchemes"
112 SCHEMES_TEMP="FvSchemes.temp"
113 SOLVERS_FILE="FvSolution"
114 SOLVERS_TEMP="FvSolution.temp"
115 DEFAULT_SCHEMES=0
118 # OPTIONS
120 OPTS=`getopt hd $*`
121 if [ $? -ne 0 ]
122 then
123 usage "Aborting due to invalid option"
125 eval set -- "$OPTS"
126 while [ $1 != -- ]
128 case $1 in
129 -d) DEFAULT_SCHEMES=1;;
130 -h) usage;;
131 esac
132 shift
133 done
134 shift
137 # MAIN
140 if [ -d "$TEST_RUN_DIR" ]
141 then
142 rm -rf $TEST_RUN_DIR
145 echo "Modifying ${MAIN_CONTROL_DICT}"
146 if [ -e ${MAIN_CONTROL_DICT}.org ]
147 then
148 echo "File ${MAIN_CONTROL_DICT}.org already exists"
149 echo "Did Alltest fail in some way and then run again?"
150 exit 1
153 # Clean up on termination and on Ctrl-C
154 trap 'mv ${MAIN_CONTROL_DICT}.org ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
155 EXIT TERM INT
156 cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org
158 sed \
159 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
160 -e s/"\(solution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
161 ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT}
163 echo "Copying the tutorials"
164 cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
166 echo "Modifying the controlDicts to run only one time step"
167 cd ${TEST_RUN_DIR} || exit 1
169 for CD in `find . -name "controlDict*"`
171 mv ${CD} ${CD}.org
172 sed \
173 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
174 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
175 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
176 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
177 ${CD}.org > ${CD}
178 done
180 if [ $DEFAULT_SCHEMES = 1 ]
181 then
182 echo "Modifying the fvSchemes to contain only default schemes"
183 for FV_SC in `find . -name fvSchemes`
185 for S in $FV_SCHEMES
187 mv ${FV_SC} ${FV_SC}.org
188 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
189 done
190 setDefaultFvSchemes >> ${FV_SC}
191 done
194 ./Allrun
196 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
197 APPLICATIONS=\
198 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
200 rm $SCHEMES_FILE > /dev/null 2>&1
201 for APP in $APPLICATIONS
203 echo $APP >> $SCHEMES_FILE
204 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
205 for ST in $FV_SCHEMES
207 rm $SCHEMES_TEMP > /dev/null 2>&1
208 rm $SOLVERS_TEMP > /dev/null 2>&1
209 echo " ${ST}" >> $SCHEMES_FILE
210 for LOG in `find ${APP} -name "log.${APP}"`
212 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
214 echo " ${S}" >> $SCHEMES_TEMP
215 done
216 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
217 done
218 if [ -f $SCHEMES_TEMP ]
219 then
220 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
222 done
223 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
224 echo "" >> $SOLVERS_FILE
225 done
228 # ----------------------------------------------------------------- end-of-file