Merge branch 'upstream' into master
[freefoam.git] / tutorials / Alltest.in
blob365e9f6395fe7671092a6ca5fede0bdc7037ffb0
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 . @FF_DATA_DIR@/shellFunctions/jobControlFunctions
37 printUsage () {
38 cat <<EOF
39 Usage: $0
40 Quickly tests the tutorials and writes out the scheme/solver information
42 Options are:
43 -d sets up a default scheme on all schemes
44 -h help
45 EOF
48 setDefaultFvSchemes () {
49 cat<<EOF
50 gradSchemes { default Gauss linear; }
51 divSchemes
53 default Gauss linear;
54 div(phi,fu_ft_h) Gauss multivariateSelection
56 fu upwind;
57 ft upwind;
58 h upwind;
60 div(phi,ft_b_h_hu) Gauss multivariateSelection
62 fu upwind;
63 ft upwind;
64 b upwind;
65 h upwind;
66 hu upwind;
69 laplacianSchemes { default Gauss linear corrected; }
70 interpolationSchemes { default linear; }
71 snGradSchemes { default corrected; }
72 fluxRequired { default yes; }
73 EOF
76 # VARIABLE
79 MAIN_CONTROL_DICT=`findControlDict`
80 TUTORIALS_DIR=.
81 TEST_RUN_DIR=../tutorialsTest
82 FV_SCHEMES=\
83 " \
84 gradScheme \
85 divScheme \
86 laplacianScheme \
87 interpolationScheme \
88 snGradScheme \
89 fluxRequired \
91 SCHEMES_FILE="FvSchemes"
92 SCHEMES_TEMP="FvSchemes.temp"
93 SOLVERS_FILE="FvSolution"
94 SOLVERS_TEMP="FvSolution.temp"
95 DEFAULT_SCHEMES=0
98 # OPTIONS
100 OPTS=`getopt hd $*`
101 if [ $? -ne 0 ] ; then
102 echo "Aborting due to invalid option"
103 printUsage
104 exit 1
106 eval set -- "$OPTS"
107 while [ $1 != -- ]; do
108 case $1 in
109 -d) DEFAULT_SCHEMES=1;;
110 -h) printUsage; exit 1;;
111 esac
112 shift
113 done
114 shift
117 # MAIN
120 if [ -d "$TEST_RUN_DIR" ] ; then
121 rm -rf $TEST_RUN_DIR
124 echo "Modifying ${MAIN_CONTROL_DICT}"
125 if [ -e ${MAIN_CONTROL_DICT}.org ]
126 then
127 echo "File " ${MAIN_CONTROL_DICT}.org " already exists"
128 echo "Did Alltest fail in some way and then run again?"
129 exit 1
132 # Clean up on termination and on Ctrl-C
133 trap 'mv ${MAIN_CONTROL_DICT}.org ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
134 EXIT TERM INT
135 cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org
137 sed \
138 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
139 -e s/"\(fvSolution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
140 ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT}
142 echo "Copying the tutorials"
143 cp @FF_CP_A_FLAGS@ ${TUTORIALS_DIR} ${TEST_RUN_DIR}
145 echo "Modifying the controlDicts to run only one time step"
146 cd ${TEST_RUN_DIR}
148 for CD in `find . -name "controlDict*"`
150 mv ${CD} ${CD}.org
151 sed \
152 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
153 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
154 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
155 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
156 ${CD}.org > ${CD}
157 done
159 if [ $DEFAULT_SCHEMES = 1 ] ; then
160 echo "Modifying the fvSchemes to contain only default schemes"
161 for FV_SC in `find . -name fvSchemes`
163 for S in $FV_SCHEMES
165 mv ${FV_SC} ${FV_SC}.org
166 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
167 done
168 setDefaultFvSchemes >> ${FV_SC}
169 done
172 ./Allrun
174 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
175 APPLICATIONS=\
176 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
178 rm $SCHEMES_FILE > /dev/null 2>&1
179 for APP in $APPLICATIONS
181 echo $APP >> $SCHEMES_FILE
182 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
183 for ST in $FV_SCHEMES
185 rm $SCHEMES_TEMP > /dev/null 2>&1
186 rm $SOLVERS_TEMP > /dev/null 2>&1
187 echo " ${ST}" >> $SCHEMES_FILE
188 for LOG in `find ${APP} -name "log.${APP}"`
190 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
192 echo " ${S}" >> $SCHEMES_TEMP
193 done
194 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
195 done
196 if [ -f $SCHEMES_TEMP ] ; then
197 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
199 done
200 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
201 echo "" >> $SOLVERS_FILE
202 done
205 # ----------------------------------------------------------------- end-of-file