|
6 | 6 | import time |
7 | 7 | import os |
8 | 8 | import subprocess |
| 9 | + |
9 | 10 | # get the path to su2 executable |
10 | 11 | su2_run= os.environ["SU2_RUN"] + "/" |
11 | 12 | print("SU2 executable obtained from ", su2_run) |
|
15 | 16 | # nr of cores for mpi |
16 | 17 | ncores="2" |
17 | 18 |
|
| 19 | +# Set to true if you want to use the restart files of previous design iterations |
| 20 | +# this set RESTART= NO to RESTART=YES after the first design iteration |
| 21 | +update_restart_file = False |
| 22 | + |
18 | 23 | # total number of design iterations. |
19 | 24 | number_of_design_iterations = 1 |
20 | 25 |
|
21 | 26 | configMaster="sudo.cfg" |
22 | 27 | meshName="sudo_coarse_FFD.su2" |
23 | | -# inlet BC file |
| 28 | + |
| 29 | +# inlet BC file, needs to be copied |
24 | 30 | inletName="inlet.dat" |
25 | 31 | restartAdjName="solution_adj_dp.csv" |
26 | 32 |
|
|
135 | 141 | # Evaluations ---------------------------------------------------------- # |
136 | 142 |
|
137 | 143 | def_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_DEF " + configCopy |
138 | | -cfd_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD " + configCopy |
139 | | -cfd_ad_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD_AD " + configCopy |
140 | | -cfd_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD " + configCopy + " && cp restart.csv ../../solution.csv" |
141 | | -cfd_ad_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD_AD " + configCopy + " && cp restart_adj_" + objstring + ".csv ../../solution_adj_"+objstring+".csv" |
142 | | -dot_ad_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_DOT_AD " + configCopy |
143 | 144 |
|
144 | | -# global iteration |
145 | | -global_iter = 0 |
| 145 | +if update_restart_file = True: |
| 146 | + cfd_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD " + configCopy + " && cp restart.csv ../../solution.csv" |
| 147 | + cfd_ad_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD_AD " + configCopy + " && cp restart_adj_" + objstring + ".csv ../../solution_adj_"+objstring+".csv" |
| 148 | +else : |
| 149 | + cfd_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD " + configCopy |
| 150 | + cfd_ad_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_CFD_AD " + configCopy |
146 | 151 |
|
| 152 | +dot_ad_command = "mpirun --allow-run-as-root -n " + ncores + " " + su2_run + "SU2_DOT_AD " + configCopy |
147 | 153 |
|
148 | 154 | max_tries = 1 |
149 | 155 |
|
| 156 | +##################################################################### |
150 | 157 | # mesh deformation, running in subdirectory DEFORM |
| 158 | +##################################################################### |
151 | 159 | deform = ExternalRun("DEFORM",def_command,True) # True means sym links are used for addData |
152 | 160 | deform.setMaxTries(max_tries) |
153 | 161 | deform.addConfig(configCopy) |
|
159 | 167 | deform.addParameter(enable_def) |
160 | 168 | deform.addParameter(enable_obj) |
161 | 169 |
|
| 170 | +##################################################################### |
162 | 171 | # direct run, running in subdirectory DIRECT |
| 172 | +##################################################################### |
163 | 173 | direct = ExternalRun("DIRECT",cfd_command,True) |
164 | 174 | direct.setMaxTries(max_tries) |
165 | 175 | direct.addConfig(configCopy) |
|
173 | 183 | direct.addParameter(enable_not_def) |
174 | 184 | direct.addParameter(enable_obj) |
175 | 185 |
|
| 186 | +##################################################################### |
176 | 187 | # adjoint run, running in subdorectory ADJOINT |
| 188 | +##################################################################### |
177 | 189 | adjoint = ExternalRun("ADJOINT",cfd_ad_command,True) |
178 | 190 | adjoint.setMaxTries(max_tries) |
179 | 191 | adjoint.addConfig(configCopy) |
|
200 | 212 | adjoint.addParameter(enable_not_def) |
201 | 213 | adjoint.addParameter(enable_obj) |
202 | 214 |
|
| 215 | +##################################################################### |
203 | 216 | # gradient projection, running in subdirectory DOT |
| 217 | +##################################################################### |
204 | 218 | dot = ExternalRun("DOT",dot_ad_command,True) |
205 | 219 | dot.setMaxTries(max_tries) |
206 | 220 | dot.addConfig(configCopy) |
|
225 | 239 | dot.addParameter(enable_def) |
226 | 240 | dot.addParameter(enable_obj) # necessary for correct file extension |
227 | 241 |
|
| 242 | +##################################################################### |
228 | 243 | # update restart file |
| 244 | +##################################################################### |
229 | 245 | update_restart = ExternalRun("UPDATE_RESTART",restart_yes,False) # True means sym links are used for addData |
230 | 246 | update_restart.addData(configCopy) |
231 | 247 |
|
|
246 | 262 | func_surfdp.addValueEvalStep(deform) |
247 | 263 | func_surfdp.addValueEvalStep(direct) |
248 | 264 | func_surfdp.addGradientEvalStep(adjoint) |
249 | | -func_surfdp.addGradientEvalStep(update_restart) |
| 265 | +if update_restart_file == True: |
| 266 | + func_surfdp.addGradientEvalStep(update_restart) |
250 | 267 | func_surfdp.addGradientEvalStep(dot) |
251 | 268 | func_surfdp.setDefaultValue(0.0) |
252 | 269 |
|
|
0 commit comments