Rheolef  7.2
an efficient C++ finite element environment
mkgeo_contraction.sh
Go to the documentation of this file.
1 #!/bin/sh
2 #
3 # This file is part of Rheolef.
4 #
5 # Copyright (C) 2000-2009 Pierre Saramito
6 #
7 # Rheolef is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # Rheolef is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Rheolef; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #
21 # -------------------------------------------------------------------------
22 # author: Pierre.Saramito@imag.fr
23 # date: 2 february 2018
24 
25 
123 
124 nx=""
125 nx_default=1
126 c=4
127 Lu=20
128 Ld=20
129 hmin=0.1
130 split=false
131 clean=true
132 verbose=false
133 name="contraction"
134 usage="usage: mkgeo_contraction
135  [nx=$nx_default [ny=nx]]
136  [-c float=$c]
137  [-Lu float=$Lu]
138  [-Ld float=$Ld]
139  [-rz|-zr]
140  [-hmin float=$hmin]
141  [-name string=$name]
142  [-[no]split]
143  [-[no]clean]
144  [-[no]verbose]
145 "
146 pkgbindir="`rheolef-config --pkglibdir`"
147 
148 while test $# -ne 0; do
149  case $1 in
150  [0-9]*) if test x$nx = x""; then nx=$1; else ny=$1; fi;;
151  -c) c="$2"; shift;;
152  -Lu) Lu="$2"; shift;;
153  -Ld) Ld="$2"; shift;;
154  -zr|-rz|-cartesian) sys_coord_opt="$1";;
155  -name) name=$2; shift;;
156  -hmin) hmin=$2; shift;;
157  -split) split=true;;
158  -nosplit) split=false;;
159  -clean) clean=true;;
160  -noclean) clean=false;;
161  -verbose) verbose=true;;
162  -noverbose) verbose=false;;
163  -h) /bin/echo -E ${usage} >&2; exit 0;;
164  *) /bin/echo -E ${usage} >&2; exit 1;;
165  esac
166  shift
167 done
168 if test x"$nx" = x""; then
169  nx=$nx_default
170 fi
171 if test x"$ny" = x""; then
172  ny=$nx
173 fi
174 
175 to_clean=""
176 
177 
178 # edge lengths are scaled at upstream by c and in x-dir by Lu and Ld
179 h=0.3
180 h0=`echo $hmin $nx | awk '{print 1.0*$1/$2}'`
181 hd=`echo $h $nx | awk '{print 1.0*$1/$2}'`
182 hu=`echo $h $c $nx | awk '{print 1.0*$1*$2/$3}'`
183 hux=`echo $h $Lu $nx | awk '{print 1.0*$1*$2/$3}'`
184 huy=`echo $h $c $ny | awk '{print 1.0*$1*$2/$3}'`
185 hdx=`echo $h $Ld $nx | awk '{print 1.0*$1*$2/$3}'`
186 hdy=`echo $h $ny | awk '{print 1.0*$1/$2}'`
187 
188 #echo "hdx=$hdx"
189 #echo "hdy=$hdy"
190 
191 m0=` echo $h0 | awk '{print 1./($1*$1) }'`
192 md=` echo $hd | awk '{print 1./($1*$1) }'`
193 mu=` echo $hu | awk '{print 1./($1*$1) }'`
194 mux=`echo $hux | awk '{print 1./($1*$1) }'`
195 muy=`echo $huy | awk '{print 1./($1*$1) }'`
196 mdx=`echo $hdx | awk '{print 1./($1*$1) }'`
197 mdy=`echo $hdy | awk '{print 1./($1*$1) }'`
198 
199 c2=`echo $c $Ld | awk '{ c2 = 2*$1; print (c2 < $2 ? c2 : $2) }'`
200 
201 #
202 # background mesh for bamg mesh generator:
203 # with anisotropic (1/hx^2, 1/hy^2) metric
204 #
205 # 11 10 9
206 # +-------------------+-----------+
207 # | |\ |
208 # | | \ T3 |
209 # | | \ |
210 # | | \ |
211 # | Q1 | \ |
212 # | | \|8 7 6
213 # | | Q2 +-----------+---------------+
214 # |1 |2 |3 Q4 |4 Q5 | 5
215 # +-------------------+-----------+-----------+---------------+
216 # -Lu -c 0 c2 Ld
217 #
218 cat > $name.bamgcad << EOF2
219 MeshVersionFormatted
220  0
221 Dimension
222  2
223 Vertices
224  11
225  -$Lu 0 1
226  -$c 0 2
227  -0 0 3
228  $c2 0 4
229  $Ld 0 5
230  $Ld 1 6
231  $c2 1 7
232  0 1 8
233  0 $c 9
234  -$c $c 10
235  -$Lu $c 11
236 Edges
237  11
238  1 2 101
239  2 3 101
240  3 4 101
241  4 5 101
242  5 6 102
243  6 7 103
244  7 8 103
245  8 9 103
246  9 10 103
247  10 11 103
248  11 1 104
249 EOF2
250 echo "! $name.bamgcad created" 1>&2
251 
252 cat > $name.mtr << EOF1b
253 11 3
254 $mux 0 $muy
255 $mu 0 $mu
256 $md 0 $md
257 $md 0 $md
258 $mdx 0 $mdy
259 $mdx 0 $mdy
260 $md 0 $md
261 $m0 0 $m0
262 $mu 0 $mu
263 $mu 0 $mu
264 $mux 0 $muy
265 EOF1b
266 $verbose && echo "! $name.mtr created" 1>&2
267 to_clean="$to_clean $name.mtr"
268 
269 cat > $name.dmn << EOF3
270 EdgeDomainNames
271  4
272  axis
273  downstream
274  wall
275  upstream
276 EOF3
277 echo "! $name.dmn created" 1>&2
278 
279 # bamg -coef 1 -err 0.01 -errg 0.1 -hmin 0.004 -hmax 0.3 -ratio 0 -anisomax 1e+06 -nbv 50000 -NbJacobi 1 -CutOff 1e-07 -splitpbedge -RelError -b sector-10-P2-Bi-0.5-n-1-v2.bamg -Mbb sector-10-P2-Bi-0.5-n-1-v2-crit.bb -o sector-10-P2-Bi-0.5-n-1-v2-001.bamg 1>&2
280 
281 command="bamg -g $name.bamgcad -M $name.mtr -o $name.bamg"
282 if $verbose; then
283  command="$command 1>&2"
284 else
285  command="$command 1> $name.bamglog"
286  to_clean="$to_clean $name.bamglog"
287 fi
288 $verbose && echo "! $command" 1>&2
289 eval $command
290 status=$?
291 if test $status -ne 0; then
292  if $verbose; then true; else cat $name.bamglog 1>&2; fi
293  echo "$0: command failed" 1>&2
294  exit $status
295 fi
296 echo "! $name.bamg created" 1>&2
297 
298 if $split; then
299  filter="| ${pkgbindir}/geo_split | geo -upgrade -geo -"
300 else
301  filter=""
302 fi
303 command="bamg2geo $name.bamg $name.dmn $sys_coord_opt $filter > $name.geo"
304 $verbose && echo "! $command" 1>&2
305 eval $command
306 status=$?
307 if test $status -ne 0; then
308  echo "$0: command failed" 1>&2
309  exit $status
310 fi
311 echo "! $name.geo created" 1>&2
312 if $clean; then
313  command="rm -f $to_clean"
314  $verbose && echo "! $command" 1>&2
315  eval $command
316 fi