Rheolef  7.1
an efficient C++ finite element environment
mkgeo_sector.sh
Go to the documentation of this file.
1 #!/bin/bash
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 
98 
99 n=""
100 n_default=10
101 a=1
102 b=1
103 name="sector"
104 clean=true
105 verbose=false
106 
107 usage="usage: mkgeo_contraction
108  [n=$n_default]
109  [-a float=$a]
110  [-b float=$b]
111  [-name string=$name]
112  [-[no]clean]
113  [-[no]verbose]
114 "
115 
116 while test $# -ne 0; do
117  case $1 in
118  [0-9]*) if test x$n = x""; then n=$1; else m=$1; fi;;
119  -a) a="$2"; shift;;
120  -b) b="$2"; shift;;
121  -name) name=$2; shift;;
122  -clean) clean=true;;
123  -noclean) clean=false;;
124  -verbose) verbose=true;;
125  -noverbose) verbose=false;;
126  -h) echo ${usage} >&2; exit 0;;
127  *) echo ${usage} >&2; exit 1;;
128  esac
129  shift
130 done
131 if test x"$n" = x""; then
132  n=$n_default
133 fi
134 
135 to_clean=""
136 
137 h=`echo $n | awk '{printf("%.15g\n", 1./$1)}'`
138 cat > $name.bamgcad << EOF1
139  MeshVersionFormatted
140  0
141  Dimension
142  2
143  Vertices
144  3
145  0 0 1
146  $a 0 2
147  $a $b 3
148  Edges
149  3
150  1 2 101
151  2 3 102
152  3 1 103
153  hVertices
154  $h $h $h
155 EOF1
156 echo "! file $name.bamgcad created" 1>&2
157 
158 cat > $name.dmn << EOF2
159  EdgeDomainNames
160  3
161  axis
162  boundary
163  bisector
164 EOF2
165 echo "! file $name.dmn created" 1>&2
166 
167 command="bamg -g $name.bamgcad -o $name.bamg"
168 if $verbose; then
169  echo "! $command" 1>&2
170  command="$command 1>&2"
171 else
172  command="($command 2>&1) > $name.bamglog"
173  to_clean="$to_clean $name.bamglog"
174 fi
175 eval $command
176 if test $? -ne 0; then
177  echo "$0: command failed"
178  if $verbose; then true; else cat $name.bamglog; fi
179  exit 1
180 fi
181 echo "! file $name.bamg created" 1>&2
182 
183 command="bamg2geo $name.bamg $name.dmn > $name.geo"
184 if $verbose; then
185  echo "! $command" 1>&2
186 else
187  command="$command 2> $name.bamglog"
188  to_clean="$to_clean $name.bamglog"
189 fi
190 eval $command
191 if test $? -ne 0; then
192  echo "$0: command failed"
193  if $verbose; then true; else cat $name.bamglog; fi
194  exit 1
195 fi
196 echo "! file $name.geo created" 1>&2
197 
198 if $clean; then
199  command="rm -f $to_clean"
200  $verbose && echo "! $command" 1>&2
201  eval $command
202 fi