forked from ACea15/FENIAX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_tools.sh
executable file
·235 lines (204 loc) · 5 KB
/
bash_tools.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
#python variables.py
#python loads.py
for i in {50..900..50}
do
#python aero_loads.py "$i"
#python ../../../../pyfem2nl_maint.py GolandWing confi_GW1
#python ../../../../Utils/tool4main.py GolandWing confi_GW1
echo "Welcome $i times"
done
function t1() {
echo 'hello'
}
function fact_elements() {
var=("$1")
mul=1
for i in ${var[@]}
do
mul=$(($mul*i))
done
echo $mul
}
function run_feminas() {
varx=("$1")
loadsx=("$2")
aloadsx=("$3")
#nvar=${#var[@]}
#nloads=${#loads[*]}
#naloads=${#aloads[@]}
nvar=0
var=()
for j in ${varx[@]}
do
var+=($j)
nvar=$((nvar+1))
done
nloads=0
loads=()
for j in ${loadsx[@]}
do
loads+=($j)
nloads=$((nloads+1))
done
naloads=0
aloads=()
for j in ${aloadsx[@]}
do
aloads+=($j)
naloads=$((naloads+1))
done
#echo "loadsx ${loads[0]}"
nnvar=()
for j in ${var[@]}
do
my_array=()
IFS=',' read -ra my_array <<< $j
nj=${#my_array[@]}
#echo ${my_array[@]}
nnvar+=($nj)
done
nnloads=()
for j in ${loads[@]}
do
my_array=()
IFS=',' read -ra my_array <<< $j
nj=${#my_array[@]}
#echo ${my_array[@]}
nnloads+=($nj)
done
nnaloads=()
for j in ${aloads[@]}
do
my_array=()
IFS=',' read -ra my_array <<< $j
nj=${#my_array[@]}
#echo ${my_array[*]}
#echo $nj
nnaloads+=($nj)
done
#echo ${var[@]}
#echo ${loads[@]}
#echo ${aloads[@]}
#echo start
#echo ${nnaloads[1]}
#echo ${nnvar[@]}
#echo ${nnloads[@]}
#echo ${nnaloads[@]}
echo start
perm=(${nnvar[@]} ${nnloads[@]} ${nnaloads[@]})
#echo ${perm[@]}
ntotal=$(fact_elements "${perm[*]}")
#echo ${ntotal[@]}
for i in $(seq 0 $((ntotal-1)))
do
echo "seq ${i}"
if [ $nvar -gt 0 ]
then
#echo $nvar
vari=()
for j in $(seq 0 $((nvar-1)))
do
IFS=',' read -ra my_array <<< ${var[j]}
nj=$((i%nnvar[j]))
nvari=${my_array[nj]}
vari+=($nvari)
done
echo "variable ${vari[@]}"
python variables.py $vari
else
echo "none"
#python variables_trim.py
fi
if [ $nloads -gt 0 ]
then
loadsi=()
for j in $(seq 0 $((nloads-1)))
do
IFS=',' read -ra my_array <<< ${loads[j]}
nj=$((i%nnloads[j]))
nloadsi=${my_array[nj]}
#echo ${my_array[@]}
#echo ${nnloads[@]}
#echo "loads $j"
loadsi+=($nloadsi)
done
echo " loads ${loadsi[@]}"
python loads.py $loadsi
else
echo "none"
#python loads.py
fi
if [ $naloads -gt 0 ]
then
aloadsi=()
for j in $(seq 0 $((naloads-1)))
do
IFS=',' read -ra my_array <<< ${aloads[j]}
nj=$((i%nnaloads[j]))
naloadsi=${my_array[nj]}
aloadsi+=($naloadsi)
done
echo "aloads ${aloadsi[@]}"
python aero_loads.py $aloadsi
else
echo "none"
#python aero_loads.py
fi
feminas_main.py XRF1-trim confi_trim
done
}
# for vi in ${var[*]}
# do
# IFS=',' read -ra my_array <<< $vi
# for vj in ${my_array[@]}
# do
# for li in ${loads[*]}
# do
# IFS=',' read -ra my_array2 <<< $li
# for lj in ${my_array2[@]}
# do
# for ai in ${aloads[*]}
# do
# IFS=',' read -ra my_array3 <<< $ai
# for aj in ${my_array3[@]}
# do
# python variables_trim.py "$vj"
# python loads.py "$lj"
# python aero_loads.py "$aj"
# feminas_main.py XRF1-trim confi_trim
# done
# done
# done
# done
# done
# done
# for i in ${var[*]}
# do
# IFS=',' read -ra my_array2 <<< $i
# for j in ${my_array2[@]}
# do
# echo $j
# echo '#############'
# done
# done
function write2config() {
echo $#
for i in $@
do
echo $i
done
}
function sumOverArray() {
val=("$1")
#shift
arr=("$2")
echo ${val[@]}
echo ${arr[@]}
#for i in "${arr[@]}";
#do
# sum=$((i + val))
# echo "sum: $sum"
#done
}