Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
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
124nx=""
125nx_default=1
126c=4
127Lu=20
128Ld=20
129hmin=0.1
130split=false
131clean=true
132verbose=false
133name="contraction"
134usage="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"
146pkgbindir="`rheolef-config --pkglibdir`"
147
148while 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
167done
168if test x"$nx" = x""; then
169 nx=$nx_default
170fi
171if test x"$ny" = x""; then
172 ny=$nx
173fi
174
175to_clean=""
176
177
178# edge lengths are scaled at upstream by c and in x-dir by Lu and Ld
179h=0.3
180h0=`echo $hmin $nx | awk '{print 1.0*$1/$2}'`
181hd=`echo $h $nx | awk '{print 1.0*$1/$2}'`
182hu=`echo $h $c $nx | awk '{print 1.0*$1*$2/$3}'`
183hux=`echo $h $Lu $nx | awk '{print 1.0*$1*$2/$3}'`
184huy=`echo $h $c $ny | awk '{print 1.0*$1*$2/$3}'`
185hdx=`echo $h $Ld $nx | awk '{print 1.0*$1*$2/$3}'`
186hdy=`echo $h $ny | awk '{print 1.0*$1/$2}'`
187
188#echo "hdx=$hdx"
189#echo "hdy=$hdy"
190
191m0=` echo $h0 | awk '{print 1./($1*$1) }'`
192md=` echo $hd | awk '{print 1./($1*$1) }'`
193mu=` echo $hu | awk '{print 1./($1*$1) }'`
194mux=`echo $hux | awk '{print 1./($1*$1) }'`
195muy=`echo $huy | awk '{print 1./($1*$1) }'`
196mdx=`echo $hdx | awk '{print 1./($1*$1) }'`
197mdy=`echo $hdy | awk '{print 1./($1*$1) }'`
198
199c2=`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#
218cat > $name.bamgcad << EOF2
219MeshVersionFormatted
220 0
221Dimension
222 2
223Vertices
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
236Edges
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
249EOF2
250echo "! $name.bamgcad created" 1>&2
251
252cat > $name.mtr << EOF1b
25311 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
265EOF1b
266$verbose && echo "! $name.mtr created" 1>&2
267to_clean="$to_clean $name.mtr"
268
269cat > $name.dmn << EOF3
270EdgeDomainNames
271 4
272 axis
273 downstream
274 wall
275 upstream
276EOF3
277echo "! $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
281command="bamg -g $name.bamgcad -M $name.mtr -o $name.bamg"
282if $verbose; then
283 command="$command 1>&2"
284else
285 command="$command 1> $name.bamglog"
286 to_clean="$to_clean $name.bamglog"
287fi
288$verbose && echo "! $command" 1>&2
289eval $command
290status=$?
291if 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
295fi
296echo "! $name.bamg created" 1>&2
297
298if $split; then
299 filter="| ${pkgbindir}/geo_split | geo -upgrade -geo -"
300else
301 filter=""
302fi
303command="bamg2geo $name.bamg $name.dmn $sys_coord_opt $filter > $name.geo"
304$verbose && echo "! $command" 1>&2
305eval $command
306status=$?
307if test $status -ne 0; then
308 echo "$0: command failed" 1>&2
309 exit $status
310fi
311echo "! $name.geo created" 1>&2
312if $clean; then
313 command="rm -f $to_clean"
314 $verbose && echo "! $command" 1>&2
315 eval $command
316fi