Bugfix: added mapping methods to point patch vector fields that have pointField ...
[foam-extend-4.0.git] / tutorials / Alltest
blobafb5ac90b45e4cc414ffd8e627de91110cd9e7d7
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 4.0
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 EOF
72 # VARIABLE
74 MAIN_CONTROL_DICT=
76 for i in \
77 $HOME/.$WM_PROJECT-$WM_PROJECT_VERSION \
78 $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
79 $HOME/.$WM_PROJECT \
80 $WM_PROJECT_DIR/etc \
83 if [ -f "$i/controlDict" ]; then
84 MAIN_CONTROL_DICT="$i/controlDict"
85 break
87 done
88 TUTORIALS_DIR=.
89 TEST_RUN_DIR=../tutorialsTest
90 FV_SCHEMES=\
91 " \
92 gradScheme \
93 divScheme \
94 laplacianScheme \
95 interpolationScheme \
96 snGradScheme \
97 fluxRequired \
99 SCHEMES_FILE="FvSchemes"
100 SCHEMES_TEMP="FvSchemes.temp"
101 SOLVERS_FILE="FvSolution"
102 SOLVERS_TEMP="FvSolution.temp"
103 DEFAULT_SCHEMES=0
106 # OPTIONS
108 OPTS=`getopt hd $*`
109 if [ $? -ne 0 ] ; then
110 echo "Aborting due to invalid option"
111 printUsage
112 exit 1
114 eval set -- "$OPTS"
115 while [ $1 != -- ]; do
116 case $1 in
117 -d) DEFAULT_SCHEMES=1;;
118 -h) printUsage; exit 1;;
119 esac
120 shift
121 done
122 shift
125 # MAIN
128 if [ -d "$TEST_RUN_DIR" ] ; then
129 rm -rf $TEST_RUN_DIR
132 echo "Modifying ${MAIN_CONTROL_DICT}"
133 if [ -e ${MAIN_CONTROL_DICT}.org ]
134 then
135 echo "File " ${MAIN_CONTROL_DICT}.org " already exists"
136 echo "Did Alltest fail in some way and then run again?"
137 exit 1
140 # Clean up on termination and on Ctrl-C
141 trap 'mv ${MAIN_CONTROL_DICT}.org ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \
142 EXIT TERM INT
143 cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org
145 sed \
146 -e s/"\(fvSchemes[ \t]*\)\([0-9]\);"/"\1 1;"/g \
147 -e s/"\(fvSolution[ \t]*\)\([0-9]\);"/"\1 1;"/g \
148 ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT}
150 echo "Copying the tutorials"
151 cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
153 echo "Modifying the controlDicts to run only one time step"
154 cd ${TEST_RUN_DIR}
156 for CD in `find . -name "controlDict*"`
158 mv ${CD} ${CD}.org
159 sed \
160 -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
161 -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
162 -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
163 -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
164 ${CD}.org > ${CD}
165 done
167 if [ $DEFAULT_SCHEMES = 1 ] ; then
168 echo "Modifying the fvSchemes to contain only default schemes"
169 for FV_SC in `find . -name fvSchemes`
171 for S in $FV_SCHEMES
173 mv ${FV_SC} ${FV_SC}.org
174 sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC}
175 done
176 setDefaultFvSchemes >> ${FV_SC}
177 done
180 ./Allrun
182 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
183 APPLICATIONS=\
184 `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'`
186 rm $SCHEMES_FILE > /dev/null 2>&1
187 for APP in $APPLICATIONS
189 echo $APP >> $SCHEMES_FILE
190 echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
191 for ST in $FV_SCHEMES
193 rm $SCHEMES_TEMP > /dev/null 2>&1
194 rm $SOLVERS_TEMP > /dev/null 2>&1
195 echo " ${ST}" >> $SCHEMES_FILE
196 for LOG in `find ${APP} -name "log.${APP}"`
198 for S in `grep ${ST} ${LOG} | cut -d" " -f4`
200 echo " ${S}" >> $SCHEMES_TEMP
201 done
202 echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
203 done
204 if [ -f $SCHEMES_TEMP ] ; then
205 cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
207 done
208 cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE
209 echo "" >> $SOLVERS_FILE
210 done
213 # ----------------------------------------------------------------- end-of-file