Removed unnecessary return statement
[foam-extend-3.2.git] / tutorials / Alltest
bloba966519978ac4b2942c09693f507240b769a5081
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 3.2
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 # Alltest
28 # Description
30 #------------------------------------------------------------------------------
32 # FUNCTIONS
34 printUsage () {
35 cat <<EOF
36 Usage: $0
37 Quickly tests the tutorials and writes out the scheme/solver information
39 Options are:
40 -d sets up a default scheme on all schemes
41 -h help
42 EOF
45 setDefaultFvSchemes () {
46 cat<<EOF
47 gradSchemes { default Gauss linear; }
48 divSchemes
50 default Gauss linear;
51 div(phi,fu_ft_h) Gauss multivariateSelection
53 fu upwind;
54 ft upwind;
55 h upwind;
57 div(phi,ft_b_h_hu) Gauss multivariateSelection
59 fu upwind;
60 ft upwind;
61 b upwind;
62 h upwind;
63 hu upwind;
66 laplacianSchemes { default Gauss linear corrected; }
67 interpolationSchemes { default linear; }
68 snGradSchemes { default corrected; }
69 fluxRequired { default yes; }
70 EOF
73 # VARIABLE
75 MAIN_CONTROL_DICT=
77 for i in \
78 $HOME/.$WM_PROJECT-$WM_PROJECT_VERSION \
79 $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
80 $HOME/.$WM_PROJECT \
81 $WM_PROJECT_DIR/etc \
84 if [ -f "$i/controlDict" ]; then
85 MAIN_CONTROL_DICT="$i/controlDict"
86 break
88 done
89 TUTORIALS_DIR=.
90 TEST_RUN_DIR=../tutorialsTest
91 FV_SCHEMES=\
92 " \
93 gradScheme \
94 divScheme \
95 laplacianScheme \
96 interpolationScheme \
97 snGradScheme \
98 fluxRequired \
100 SCHEMES_FILE="FvSchemes"
101 SCHEMES_TEMP="FvSchemes.temp"
102 SOLVERS_FILE="FvSolution"
103 SOLVERS_TEMP="FvSolution.temp"
104 DEFAULT_SCHEMES=0
107 # OPTIONS
109 OPTS=`getopt hd $*`
110 if [ $? -ne 0 ] ; then
111 echo "Aborting due to invalid option"
112 printUsage
113 exit 1
115 eval set -- "$OPTS"
116 while [ $1 != -- ]; do
117 case $1 in
118 -d) DEFAULT_SCHEMES=1;;
119 -h) printUsage; exit 1;;
120 esac
121 shift
122 done
123 shift
126 # MAIN
129 if [ -d "$TEST_RUN_DIR" ] ; then
130 rm -rf $TEST_RUN_DIR
133 echo "Modifying ${MAIN_CONTROL_DICT}"
134 if [ -e ${MAIN_CONTROL_DICT}.org ]
135 then
136 echo "File " ${MAIN_CONTROL_DICT}.org " already exists"
137 echo "Did Alltest fail in some way and then run again?"
138 exit 1
141 # Clean up on termination and on Ctrl-C
142 trap 'mv ${MAIN_CONTROL_DICT}.org ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
143 EXIT TERM INT
144 cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org
146 sed \
147 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
148 -e s/"\(fvSolution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
149 ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT}
151 echo "Copying the tutorials"
152 cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
154 echo "Modifying the controlDicts to run only one time step"
155 cd ${TEST_RUN_DIR}
157 for CD in `find . -name "controlDict*"`
159 mv ${CD} ${CD}.org
160 sed \
161 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
162 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
163 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
164 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
165 ${CD}.org > ${CD}
166 done
168 if [ $DEFAULT_SCHEMES = 1 ] ; then
169 echo "Modifying the fvSchemes to contain only default schemes"
170 for FV_SC in `find . -name fvSchemes`
172 for S in $FV_SCHEMES
174 mv ${FV_SC} ${FV_SC}.org
175 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
176 done
177 setDefaultFvSchemes >> ${FV_SC}
178 done
181 ./Allrun
183 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
184 APPLICATIONS=\
185 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
187 rm $SCHEMES_FILE > /dev/null 2>&1
188 for APP in $APPLICATIONS
190 echo $APP >> $SCHEMES_FILE
191 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
192 for ST in $FV_SCHEMES
194 rm $SCHEMES_TEMP > /dev/null 2>&1
195 rm $SOLVERS_TEMP > /dev/null 2>&1
196 echo " ${ST}" >> $SCHEMES_FILE
197 for LOG in `find ${APP} -name "log.${APP}"`
199 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
201 echo " ${S}" >> $SCHEMES_TEMP
202 done
203 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
204 done
205 if [ -f $SCHEMES_TEMP ] ; then
206 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
208 done
209 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
210 echo "" >> $SOLVERS_FILE
211 done
214 # ----------------------------------------------------------------- end-of-file