Debian Codegraph @

examples/bamg/NACA012/ad.sh

raw
1 #!/bin/sh -eu
2 # the -e option to stop on error
3 # we are with awk to do real operation in the shell
4 #
5 bamg=../../bamg-g
6 NSC2KE=s/NSC2KE
7
8 # for awk because in french the number 1/1000 is written 0,001 not 0.001
9 # to be sure the RADIXCHAR is '.' (cf. Native Language Support)
10 LANG=C
11 export LANG
12
13 # some VAR
14 ifin=2
15 j=0
16 INIT=0
17 LastIteration=0
18 NBITER=50
19 HMIN=0.05
20 HMINGLOBAL=0.0005
21 HCOEF=0.8
22
23 # clean of the output file
24 rm -f [A-Z]*
25
26 # create the geometry file
27 awk -f naca.awk </dev/null >MESH_g.msh
28
29 # create the initial mesh MESH_0.amdba
30 $bamg -g MESH_g.msh -o MESH_$j.msh -hmax 2 -oamdba MESH_$j.amdba
31
32 while [ $j -lt $ifin ] ; do
33 # i = j + 1
34 i=`expr $j + 1`
35
36 # LastIteration = LastIteration + NBITER
37 LastIteration=`expr $LastIteration + $NBITER`
38
39
40 ## set the current MESH
41 rm -f MESH
42 ln -s MESH_$j.amdba MESH
43
44 ## create the DATA file for NSC2KE form file data
45 ## change 2 lines for initialisation
46 rm -f DATA
47 sed -e "s/^INIT/$INIT/" -e "s/^LastIteration/$LastIteration/" <data >DATA
48
49 echo "--------- NSC2KE iteration $j -----------"
50 $NSC2KE
51 ## mv the GNU file
52 for file in GNU.MACH GNU.MESH GNU.PRES GNU.TEMP GNU.TURB GNU.VECT;do
53 mv -f $file $file.$j
54 done
55 ## find the nb of vertices in the file MESH
56 nbv=`head -1 MESH|awk '{print $1}'`
57
58 ## create the bb file for interpolation
59 echo "2 4 $nbv 2" > SOL_$j.bb
60 cat SOL_NS >> SOL_$j.bb
61
62 ## create the bb file for metric construction
63 ## in file SOL_NS on each line i we have ro ro*u ro*v energy
64 ## at vertex i
65 ## + a last line with 2 number last iteration and last time
66 echo "2 1 $nbv 2" > MACH.bb
67 awk 'NF==4 { print sqrt($2*$2+$3*$3)/$1}' SOL_NS >> MACH.bb
68
69 ## put all the residual in one file
70 cat RESIDUAL >>RESIDU
71
72 ## set HMIN = MAX($HMINGLOBAL,$HMIN*$HCOEF)
73 HMIN=`awk "END {c=$HMIN*$HCOEF;c=c<$HMINGLOBAL ?$HMINGLOBAL:c; print c};" </dev/null`
74
75 echo -b MESH_$j.msh -err 0.001 -errg 0.05 -AbsError \
76 -hmin $HMIN -hmax 3 -Mbb MACH.bb -o MESH_$i.msh \
77 -oamdba MESH_$i.amdba -raison 2 -rbb SOL_$j.bb -wbb INIT_$i.bb \
78 -maxsubdiv 2 > DATA_bamg
79 $bamg
80
81
82
83 ## creation of the INIT_NS for NSC2KE
84 ## remove fisrt line form bb file and add the last line of SOL_NS
85 sed 1d <INIT_$i.bb >INIT_NS
86 tail -1 SOL_NS >>INIT_NS
87
88 # change i and not initialisation
89 j=$i
90 INIT=1
91 done