Debian Codegraph @

examples/bamg/NACA012/adap.sh-g

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=20
15 j=0
16 INIT=0
17 LastIteration=0
18 NBITER=500
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 echo -- $bamg -g MESH_g.msh -o MESH_$j.msh -hmax 2 -oamdba MESH_$j.amdba
31 $bamg -g MESH_g.msh -o MESH_$j.msh -hmax 2 -oamdba MESH_$j.amdba
32
33 while [ $j -lt $ifin ] ; do
34 # i = j + 1
35 i=`expr $j + 1`
36
37 # LastIteration = LastIteration + NBITER
38 LastIteration=`expr $LastIteration + $NBITER`
39
40
41 ## set the current MESH
42 rm -f MESH
43 ln -s MESH_$j.amdba MESH
44
45 ## create the DATA file for NSC2KE form file data
46 ## change 2 lines for initialisation
47 rm -f DATA
48 sed -e "s/^INIT/$INIT/" -e "s/^LastIteration/$LastIteration/" <data >DATA
49
50 echo "--------- NSC2KE iteration $j -----------"
51 $NSC2KE
52
53 ## find the nb of vertices in the file MESH
54 nbv=`head -1 MESH|awk '{print $1}'`
55
56 ## create the bb file for interpolation
57 echo "2 4 $nbv 2" > SOL_$j.bb
58 cat SOL_NS >> SOL_$j.bb
59
60 ## create the bb file for metric construction
61 ## in file SOL_NS on each line i we have ro ro*u ro*v energy
62 ## at vertex i
63 ## + a last line with 2 number last iteration and last time
64 echo "2 1 $nbv 2" > MACH.bb
65 awk 'NF==4 { print sqrt($2*$2+$3*$3)/$1}' SOL_NS >> MACH.bb
66
67 ## put all the residual in one file
68 cat RESIDUAL >>RESIDU
69
70 ## set HMIN = MAX($HMINGLOBAL,$HMIN*$HCOEF)
71 HMIN=`awk "END {c=$HMIN*$HCOEF;c=c<$HMINGLOBAL ?$HMINGLOBAL:c; print c};" </dev/null`
72 echo -----
73 echo $bamg -b MESH_$j.msh -err 0.001 -errg 0.05 -AbsError '\\'
74 echo -hmin $HMIN -hmax 3 -Mbb MACH.bb -o MESH_$i.msh '\\'
75 echo -oamdba MESH_$i.amdba -raison 2 -rbb SOL_$j.bb -wbb INIT_$i.bb
76
77 $bamg -b MESH_$j.msh -err 0.001 -errg 0.05 -AbsError \
78 -hmin $HMIN -hmax 3 -Mbb MACH.bb -o MESH_$i.msh \
79 -oamdba MESH_$i.amdba -raison 2 -rbb SOL_$j.bb -wbb INIT_$i.bb
80
81 ## creation of the INIT_NS for NSC2KE
82 ## remove fisrt line form bb file and add the last line of SOL_NS
83 sed 1d <INIT_$i.bb >INIT_NS
84 tail -1 SOL_NS >>INIT_NS
85
86 # change i and not initialisation
87 j=$i
88 INIT=1
89 done