FIX: Different log-files for the multiple changeDictionary-calls in Allrun script
[freefoam.git] / tutorials / Alltest.in
blobd98583a0c7e0825226122f3fbb889b9ced91f53f
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="$PWD"
81 TEST_RUN_DIR="$PWD/../tutorialsTest"
82 MODIFIED_CONTROL_DICT="${TEST_RUN_DIR}/etc/controlDict"
83 FV_SCHEMES=\
84 " \
85 gradScheme \
86 divScheme \
87 laplacianScheme \
88 interpolationScheme \
89 snGradScheme \
90 fluxRequired \
92 SCHEMES_FILE="FvSchemes"
93 SCHEMES_TEMP="FvSchemes.temp"
94 SOLVERS_FILE="FvSolution"
95 SOLVERS_TEMP="FvSolution.temp"
96 DEFAULT_SCHEMES=0
99 # OPTIONS
101 OPTS=`getopt hd $*`
102 if [ $? -ne 0 ] ; then
103 echo "Aborting due to invalid option"
104 printUsage
105 exit 1
107 eval set -- "$OPTS"
108 while [ $1 != -- ]; do
109 case $1 in
110 -d) DEFAULT_SCHEMES=1;;
111 -h) printUsage; exit 1;;
112 esac
113 shift
114 done
115 shift
118 # MAIN
121 if [ -d "$TEST_RUN_DIR" ] ; then
122 rm -rf $TEST_RUN_DIR
125 echo "Copying the tutorials"
126 cp @FF_CP_A_FLAGS@ ${TUTORIALS_DIR} ${TEST_RUN_DIR}
128 echo "Copying `dirname ${MAIN_CONTROL_DICT}` to ${TEST_RUN_DIR}/etc"
129 echo "and modifying ${MODIFIED_CONTROL_DICT}"
131 cp @FF_CP_A_FLAGS@ "`dirname ${MAIN_CONTROL_DICT}`" "${TEST_RUN_DIR}/etc"
133 sed \
134 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
135 -e s/"\(fvSolution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
136 ${MAIN_CONTROL_DICT} > ${MODIFIED_CONTROL_DICT}
138 echo "Modifying the controlDicts to run only one time step"
139 cd ${TEST_RUN_DIR}
141 for CD in `find . -name "controlDict*"`
143 mv ${CD} ${CD}.org
144 sed \
145 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
146 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
147 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
148 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
149 ${CD}.org > ${CD}
150 done
152 if [ $DEFAULT_SCHEMES = 1 ] ; then
153 echo "Modifying the fvSchemes to contain only default schemes"
154 for FV_SC in `find . -name fvSchemes`
156 for S in $FV_SCHEMES
158 mv ${FV_SC} ${FV_SC}.org
159 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
160 done
161 setDefaultFvSchemes >> ${FV_SC}
162 done
165 for f in `find ${TEST_RUN_DIR} -type f -name Allrun`; do
166 echo "Modifying ${f}"
167 cp -f @FF_CP_A_FLAGS@ ${f} ${f}.tmp
168 sed -e 's|^\(export FREEFOAM_TEST_MODE=\)no|\1yes|' ${f}.tmp \
169 -e "s|\${TEST_CONFIG_DIR}|${TEST_RUN_DIR}/etc|g" > ${f}
170 rm -f ${f}.tmp
171 done
173 ./Allrun
175 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
176 APPLICATIONS=\
177 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
179 rm $SCHEMES_FILE > /dev/null 2>&1
180 for APP in $APPLICATIONS
182 echo $APP >> $SCHEMES_FILE
183 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
184 for ST in $FV_SCHEMES
186 rm $SCHEMES_TEMP > /dev/null 2>&1
187 rm $SOLVERS_TEMP > /dev/null 2>&1
188 echo " ${ST}" >> $SCHEMES_FILE
189 for LOG in `find ${APP} -name "log.${APP}"`
191 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
193 echo " ${S}" >> $SCHEMES_TEMP
194 done
195 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
196 done
197 if [ -f $SCHEMES_TEMP ] ; then
198 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
200 done
201 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
202 echo "" >> $SOLVERS_FILE
203 done
206 # ----------------------------------------------------------------- end-of-file