Skip to content

Commit bd95feb

Browse files
committed
parallel test instead of serial
1 parent b06ebdb commit bd95feb

3 files changed

Lines changed: 24 additions & 18 deletions

File tree

TestCases/parallel_regression_AD.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,19 @@ def main():
408408
test_list.append(pywrapper_FEA_AD_FlowLoad)
409409
pass_list.append(pywrapper_FEA_AD_FlowLoad.run_test())
410410

411+
# FEA unsteady AD Load Sensitivity
412+
pywrapper_Unst_FEA_AD = TestCase('pywrapper_Unst_FEA_AD')
413+
pywrapper_Unst_FEA_AD.cfg_dir = "py_wrapper/custom_load_fea"
414+
pywrapper_Unst_FEA_AD.cfg_file = "config.cfg"
415+
pywrapper_Unst_FEA_AD.test_iter = 100
416+
pywrapper_Unst_FEA_AD.test_vals = [0.2569257, 0.2569264, 0.03166391, 0.03169108]
417+
pywrapper_Unst_FEA_AD.command = TestCase.Command("mpirun -n 2", "python", "run_ad.py")
418+
pywrapper_Unst_FEA_AD.timeout = 1600
419+
pywrapper_Unst_FEA_AD.tol = 0.00001
420+
pywrapper_Unst_FEA_AD.new_output = False
421+
test_list.append(pywrapper_Unst_FEA_AD)
422+
pass_list.append(pywrapper_Unst_FEA_AD.run_test())
423+
411424
# Flow AD Mesh Displacement Sensitivity
412425
pywrapper_CFD_AD_MeshDisp = TestCase('pywrapper_CFD_AD_MeshDisp')
413426
pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens"

TestCases/py_wrapper/custom_load_fea/run_ad.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,13 @@ def RunAdjoint(density, peak_load):
190190
# Finalize the solver and exit cleanly.
191191
driver.Finalize()
192192

193-
return load_sens
193+
return comm.allreduce(load_sens)
194194

195195

196196
def main():
197+
comm = MPI.COMM_WORLD
198+
rank = comm.Get_rank()
199+
197200
# Run the primal with 2 loads to compute the sensitivity via finite differences.
198201
obj_pert_load = RunPrimal(1, 2.002)
199202
obj_pert_rho = RunPrimal(1.0001, 2)
@@ -206,15 +209,18 @@ def main():
206209
with open('Results_Reverse_Adjoint.txt') as f:
207210
sens_rho = float(f.readlines()[-1].strip().split('\t')[-1])
208211

209-
print(" Finite Differences\tDiscrete Adjoint")
210-
print(f"Load {sens_load_fd}\t{sens_load}")
211-
print(f"Rho {sens_rho_fd}\t{sens_rho}")
212+
if rank == 0:
213+
print(" Finite Differences\tDiscrete Adjoint")
214+
print(f"Load {sens_load_fd}\t{sens_load}")
215+
print(f"Rho {sens_rho_fd}\t{sens_rho}")
212216

213217
assert abs(sens_load / sens_load_fd - 1) < 1e-4, "Error in load derivative."
214218
assert abs(sens_rho / sens_rho_fd - 1) < 1e-3, "Error in density derivative."
215219

216220
# Print results for the regression script to check.
217-
print(100, 100, sens_load_fd, sens_load, sens_rho_fd, sens_rho)
221+
if rank == 0:
222+
print("\n")
223+
print(100, 100, sens_load_fd, sens_load, sens_rho_fd, sens_rho)
218224

219225

220226
if __name__ == '__main__':

TestCases/serial_regression_AD.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -343,19 +343,6 @@ def main():
343343
test_list.append(pywrapper_FEA_AD_FlowLoad)
344344
pass_list.append(pywrapper_FEA_AD_FlowLoad.run_test())
345345

346-
# FEA unsteady AD Load Sensitivity
347-
pywrapper_Unst_FEA_AD = TestCase('pywrapper_Unst_FEA_AD')
348-
pywrapper_Unst_FEA_AD.cfg_dir = "py_wrapper/custom_load_fea"
349-
pywrapper_Unst_FEA_AD.cfg_file = "config.cfg"
350-
pywrapper_Unst_FEA_AD.test_iter = 100
351-
pywrapper_Unst_FEA_AD.test_vals = [0.2569256889872473, 0.256926360722213, 0.03166391031539373, 0.0316910814265723]
352-
pywrapper_Unst_FEA_AD.command = TestCase.Command(exec = "python", param = "run_ad.py")
353-
pywrapper_Unst_FEA_AD.timeout = 1600
354-
pywrapper_Unst_FEA_AD.tol = 0.00001
355-
pywrapper_Unst_FEA_AD.new_output = False
356-
test_list.append(pywrapper_Unst_FEA_AD)
357-
pass_list.append(pywrapper_Unst_FEA_AD.run_test())
358-
359346
# Flow AD Mesh Displacement Sensitivity
360347
pywrapper_CFD_AD_MeshDisp = TestCase('pywrapper_CFD_AD_MeshDisp')
361348
pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens"

0 commit comments

Comments
 (0)