From 2e5695cb6da62d19cbd773282c6000796d9f27d0 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:50:58 -0400 Subject: [PATCH 1/3] Refactor tacs examples to use new tacs builder api --- .../crm9/fun3d_meld_tacs/mphys_analysis.py | 10 +++------- .../adflow_meld_tacs/mphys_as_2scenario.py | 9 ++------- .../mach_tutorial_wing/vlm_meld_tacs/as_opt.py | 9 +++------ .../vlm_meld_tacs/run_analysis.py | 11 +++-------- .../vlm_meld_tacs/run_analysis_parallel.py | 9 +++------ .../aerothermal/conjugate_hx_naca0012/run_opt.py | 13 ++----------- examples/struct_only/beam_shape_opt/shape_opt.py | 7 ++----- examples/struct_only/crm9/run_tacs_mphys.py | 9 +++------ .../struct_only/mach_tutorial_wing/mphys_struct.py | 9 ++------- .../struct_only/tank_shape_opt/run_tacs_mphys.py | 3 ++- .../test_oas_tacs_meld_partials.py | 10 ++++------ .../integration_tests/test_oas_tacs_meld_totals.py | 10 ++++------ tests/integration_tests/test_tacs_derivs.py | 9 +++------ tests/integration_tests/test_tacs_partials.py | 9 +++------ .../vlm_tacs_meld_check_partials.py | 8 +++----- .../integration_tests/vlm_tacs_meld_check_totals.py | 8 +++----- tests/regression_tests/test_aerostruct.py | 10 +++------- tests/regression_tests/test_dafoam_aerostruct.py | 9 ++------- 18 files changed, 50 insertions(+), 112 deletions(-) diff --git a/examples/aerostructural/crm9/fun3d_meld_tacs/mphys_analysis.py b/examples/aerostructural/crm9/fun3d_meld_tacs/mphys_analysis.py index f02d072b..cb387401 100644 --- a/examples/aerostructural/crm9/fun3d_meld_tacs/mphys_analysis.py +++ b/examples/aerostructural/crm9/fun3d_meld_tacs/mphys_analysis.py @@ -36,13 +36,9 @@ def setup(self): dvs.add_output('yaw', val=0.0, units='deg') aero_dvs = ['aoa','mach','reynolds','q_inf','yaw'] - # TACS options - tacs_options = { - 'element_callback': tacs_setup.element_callback, - 'problem_setup': tacs_setup.problem_setup, - 'mesh_file' : 'CRM_box_2nd.bdf' - } - struct_builder = TacsBuilder(tacs_options, coupled=True) + # TACS + struct_builder = TacsBuilder(mesh_file='CRM_box_2nd.bdf', element_callback=element_callback, + problem_setup=problem_setup, coupled=True) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py b/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py index beba41e3..d8362c3b 100644 --- a/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py +++ b/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py @@ -74,13 +74,8 @@ def setup(self): ################################################################################ # TACS Setup ################################################################################ - tacs_options = { - "element_callback": tacs_setup.element_callback, - "problem_setup": tacs_setup.problem_setup, - "mesh_file": "wingbox.bdf", - } - - struct_builder = TacsBuilder(tacs_options) + struct_builder = TacsBuilder(mesh_file="wingbox.bdf", element_callback=tacs_setup.element_callback, + problem_setup=tacs_setup.problem_setup) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/as_opt.py b/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/as_opt.py index 783ab4e2..41a2a91b 100644 --- a/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/as_opt.py +++ b/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/as_opt.py @@ -34,12 +34,9 @@ def setup(self): self.add_subsystem('mesh_aero',aero_builder.get_mesh_coordinate_subsystem()) - # TACS - tacs_options = {'element_callback': tacs_setup.element_callback, - 'problem_setup': tacs_setup.problem_setup, - 'mesh_file': 'wingbox_Y_Z_flip.bdf'} - - struct_builder = TacsBuilder(tacs_options) + # TACS setup + struct_builder = TacsBuilder(mesh_file='wingbox_Y_Z_flip.bdf', element_callback= tacs_setup.element_callback, + problem_setup= tacs_setup.problem_setup) struct_builder.initialize(self.comm) self.add_subsystem('mesh_struct',struct_builder.get_mesh_coordinate_subsystem()) diff --git a/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis.py b/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis.py index b269d248..98db9ec4 100644 --- a/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis.py +++ b/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis.py @@ -37,14 +37,9 @@ def setup(self): self.add_subsystem("mesh_aero", aero_builder.get_mesh_coordinate_subsystem()) - # TACS - tacs_options = { - "element_callback": tacs_setup.element_callback, - "problem_setup": tacs_setup.problem_setup, - "mesh_file": "wingbox_Y_Z_flip.bdf", - } - - struct_builder = TacsBuilder(tacs_options, coupled=True) + # TACS setup + struct_builder = TacsBuilder(mesh_file="wingbox_Y_Z_flip.bdf", element_callback=tacs_setup.element_callback, + problem_setup=tacs_setup.problem_setup, coupled=True) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis_parallel.py b/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis_parallel.py index ff0d3c3c..058c664d 100644 --- a/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis_parallel.py +++ b/examples/aerostructural/mach_tutorial_wing/vlm_meld_tacs/run_analysis_parallel.py @@ -19,12 +19,9 @@ def setup(self): mesh_file = 'wing_VLM.dat' aero_builder = VlmBuilder(mesh_file) - # TACS - tacs_options = {'element_callback': tacs_setup.element_callback, - 'problem_setup': tacs_setup.problem_setup, - 'mesh_file': 'wingbox_Y_Z_flip.bdf'} - - struct_builder = TacsBuilder(tacs_options, coupled=True) + # TACS setup + struct_builder = TacsBuilder(mesh_file='wingbox_Y_Z_flip.bdf', element_callback=tacs_setup.element_callback, + problem_setup=tacs_setup.problem_setup, coupled=True) # MELD isym = 1 diff --git a/examples/aerothermal/conjugate_hx_naca0012/run_opt.py b/examples/aerothermal/conjugate_hx_naca0012/run_opt.py index 7ca39436..3ac5b737 100644 --- a/examples/aerothermal/conjugate_hx_naca0012/run_opt.py +++ b/examples/aerothermal/conjugate_hx_naca0012/run_opt.py @@ -160,17 +160,8 @@ def setup(self): ################################################################################ # TACS Setup ################################################################################ - tacs_options = { - "element_callback": add_elements, - # 'get_funcs' : get_funcs, - "mesh_file": "./meshes/n0012_hexa.bdf", - # "f5_writer": f5_writer, - # "surface_mapping": get_surface_mapping, - # "Conduction": True, - "outputDir": "./output", - } - - thermal_builder = TacsBuilder(tacs_options, discipline="thermal", surface_mapper=get_surface_mapping) + thermal_builder = TacsBuilder(mesh_file="./meshes/n0012_hexa.bdf", element_callback=add_elements, + discipline="thermal", surface_mapper=get_surface_mapping) thermal_builder.initialize(self.comm) ndv_struct = thermal_builder.get_ndv() diff --git a/examples/struct_only/beam_shape_opt/shape_opt.py b/examples/struct_only/beam_shape_opt/shape_opt.py index 968b7d7e..e9fe5260 100644 --- a/examples/struct_only/beam_shape_opt/shape_opt.py +++ b/examples/struct_only/beam_shape_opt/shape_opt.py @@ -81,12 +81,9 @@ def problem_setup(scenario_name, fea_assembler, problem): class Top(Multipoint): def setup(self): - tacs_options = {'element_callback': element_callback, - 'problem_setup': problem_setup, - 'mesh_file': bdf_file} - # Initialize MPHYS builder for TACS - struct_builder = TacsBuilder(tacs_options, coupled=False) + struct_builder = TacsBuilder(mesh_file=bdf_file, element_callback=element_callback, problem_setup=problem_setup, + coupled=False) struct_builder.initialize(self.comm) # Add mesh component diff --git a/examples/struct_only/crm9/run_tacs_mphys.py b/examples/struct_only/crm9/run_tacs_mphys.py index ad1e8412..5aec8ba0 100644 --- a/examples/struct_only/crm9/run_tacs_mphys.py +++ b/examples/struct_only/crm9/run_tacs_mphys.py @@ -13,12 +13,9 @@ class Top(Multipoint): def setup(self): - tacs_options = {'element_callback': tacs_setup.element_callback, - 'problem_setup': tacs_setup.problem_setup, - 'constraint_setup': tacs_setup.constraint_setup, - 'mesh_file': 'CRM_box_2nd.bdf'} - - struct_builder = TacsBuilder(tacs_options, coupled=False, check_partials=True) + struct_builder = TacsBuilder(mesh_file='CRM_box_2nd.bdf', element_callback=tacs_setup.element_callback, + problem_setup=tacs_setup.problem_setup, + constraint_setup=tacs_setup.constraint_setup, coupled=False) struct_builder.initialize(self.comm) dv_array = struct_builder.get_initial_dvs() diff --git a/examples/struct_only/mach_tutorial_wing/mphys_struct.py b/examples/struct_only/mach_tutorial_wing/mphys_struct.py index 76cf0d6c..583fc015 100644 --- a/examples/struct_only/mach_tutorial_wing/mphys_struct.py +++ b/examples/struct_only/mach_tutorial_wing/mphys_struct.py @@ -72,13 +72,8 @@ def problem_setup(scenario_name, fea_assembler, problem): F[2::ndof] = 100.0 problem.addLoadToRHS(F) - tacs_options = { - "element_callback": element_callback, - "problem_setup": problem_setup, - "mesh_file": "wingbox.bdf", - } - - tacs_builder = TacsBuilder(tacs_options, coupled=False) + tacs_builder = TacsBuilder(mesh_file="wingbox.bdf", element_callback=element_callback, + problem_setup=problem_setup, coupled=False) tacs_builder.initialize(self.comm) ################################################################################ diff --git a/examples/struct_only/tank_shape_opt/run_tacs_mphys.py b/examples/struct_only/tank_shape_opt/run_tacs_mphys.py index a68ff6f4..20d67433 100644 --- a/examples/struct_only/tank_shape_opt/run_tacs_mphys.py +++ b/examples/struct_only/tank_shape_opt/run_tacs_mphys.py @@ -32,7 +32,8 @@ def setup(self): 'problem_setup': problem_setup, 'constraint_setup': constraint_setup} - struct_builder = TacsBuilder(tacs_options, coupled=False) + struct_builder = TacsBuilder(mesh_file=bdf_file, problem_setup=problem_setup, + constraint_setup=constraint_setup, coupled=False) struct_builder.initialize(self.comm) # Add mesh component diff --git a/tests/integration_tests/test_oas_tacs_meld_partials.py b/tests/integration_tests/test_oas_tacs_meld_partials.py index 420bc41a..ac29e6b5 100644 --- a/tests/integration_tests/test_oas_tacs_meld_partials.py +++ b/tests/integration_tests/test_oas_tacs_meld_partials.py @@ -113,12 +113,10 @@ def setup(self): self.add_subsystem('mesh_aero', aero_builder.get_mesh_coordinate_subsystem()) - # TACS - tacs_options = {'element_callback': element_callback, - 'problem_setup': problem_setup, - 'mesh_file': '../input_files/debug.bdf'} - - struct_builder = TacsBuilder(tacs_options, check_partials=True, coupled=True, write_solution=False) + # TACS setup + struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback, + problem_setup=problem_setup, check_partials=True, coupled=True, + write_solution=False) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/tests/integration_tests/test_oas_tacs_meld_totals.py b/tests/integration_tests/test_oas_tacs_meld_totals.py index 28fbb4b6..03bafefb 100644 --- a/tests/integration_tests/test_oas_tacs_meld_totals.py +++ b/tests/integration_tests/test_oas_tacs_meld_totals.py @@ -110,12 +110,10 @@ def setup(self): self.add_subsystem('mesh_aero', aero_builder.get_mesh_coordinate_subsystem()) - # TACS - tacs_options = {'element_callback' : element_callback, - 'problem_setup': problem_setup, - 'mesh_file': '../input_files/debug.bdf'} - - struct_builder = TacsBuilder(tacs_options, check_partials=True, coupled=True, write_solution=False) + # TACS setup + struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback, + problem_setup=problem_setup, check_partials=True, coupled=True, + write_solution=False) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/tests/integration_tests/test_tacs_derivs.py b/tests/integration_tests/test_tacs_derivs.py index 2e97afc2..8534c2d5 100644 --- a/tests/integration_tests/test_tacs_derivs.py +++ b/tests/integration_tests/test_tacs_derivs.py @@ -66,12 +66,9 @@ def problem_setup(scenario_name, fea_assembler, problem): class Top(Multipoint): def setup(self): - - tacs_options = {'element_callback' : element_callback, - 'problem_setup' : problem_setup, - 'mesh_file': '../input_files/debug.bdf'} - - tacs_builder = TacsBuilder(tacs_options, check_partials=True, coupled=True, write_solution=False) + tacs_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback, + problem_setup=problem_setup, + check_partials=True, coupled=True, write_solution=False) tacs_builder.initialize(self.comm) ndv_struct = tacs_builder.get_ndv() diff --git a/tests/integration_tests/test_tacs_partials.py b/tests/integration_tests/test_tacs_partials.py index 07624b2e..a70a2efa 100644 --- a/tests/integration_tests/test_tacs_partials.py +++ b/tests/integration_tests/test_tacs_partials.py @@ -51,12 +51,9 @@ def problem_setup(scenario_name, fea_assembler, problem): class Top(Multipoint): def setup(self): - - tacs_options = {'element_callback' : element_callback, - 'problem_setup': problem_setup, - 'mesh_file': '../input_files/debug.bdf'} - - tacs_builder = TacsBuilder(tacs_options, check_partials=True, coupled=False, write_solution=False) + tacs_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback, + problem_setup=problem_setup, check_partials=True, coupled=False, + write_solution=False) tacs_builder.initialize(self.comm) ndv_struct = tacs_builder.get_ndv() diff --git a/tests/integration_tests/vlm_tacs_meld_check_partials.py b/tests/integration_tests/vlm_tacs_meld_check_partials.py index bd5e54e6..b2b50db2 100644 --- a/tests/integration_tests/vlm_tacs_meld_check_partials.py +++ b/tests/integration_tests/vlm_tacs_meld_check_partials.py @@ -72,15 +72,13 @@ def setup(self): self.add_subsystem('mesh_aero', aero_builder.get_mesh_coordinate_subsystem()) # TACS - tacs_options = {'element_callback' : element_callback, - 'problem_setup': problem_setup, - 'mesh_file': '../input_files/debug.bdf'} - if use_modal: tacs_options['nmodes'] = 15 #struct_assembler = ModalStructAssembler(tacs_options) else: - struct_builder = TacsBuilder(tacs_options, check_partials=True, coupled=True, write_solution=False) + struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback, + problem_setup=problem_setup, check_partials=True, coupled=True, + write_solution=False) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/tests/integration_tests/vlm_tacs_meld_check_totals.py b/tests/integration_tests/vlm_tacs_meld_check_totals.py index db3f0bcd..cffa5324 100644 --- a/tests/integration_tests/vlm_tacs_meld_check_totals.py +++ b/tests/integration_tests/vlm_tacs_meld_check_totals.py @@ -73,15 +73,13 @@ def setup(self): self.add_subsystem('mesh_aero', aero_builder.get_mesh_coordinate_subsystem()) # TACS - tacs_options = {'element_callback' : element_callback, - "problem_setup": problem_setup, - 'mesh_file': '../input_files/debug.bdf'} - if use_modal: tacs_options['nmodes'] = 15 #struct_assembler = ModalStructAssembler(tacs_options) else: - struct_builder = TacsBuilder(tacs_options, check_partials=True, coupled=True, write_solution=False) + struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback, + problem_setup=problem_setup, check_partials=True, coupled=True, + write_solution=False) struct_builder.initialize(self.comm) ndv_struct = struct_builder.get_ndv() diff --git a/tests/regression_tests/test_aerostruct.py b/tests/regression_tests/test_aerostruct.py index a275e902..56bf3673 100644 --- a/tests/regression_tests/test_aerostruct.py +++ b/tests/regression_tests/test_aerostruct.py @@ -128,14 +128,10 @@ def setup(self): self.add_subsystem("mesh_aero", aero_builder.get_mesh_coordinate_subsystem()) ################################################################################ - # TACS options + # TACS setup ################################################################################ - - tacs_options = {'element_callback' : element_callback, - "problem_setup": problem_setup, - 'mesh_file': '../input_files/wingbox.bdf'} - - struct_builder = TacsBuilder(tacs_options, coupled=True) + struct_builder = TacsBuilder(mesh_file='../input_files/wingbox.bdf', element_callback=element_callback, + problem_setup=problem_setup, coupled=True) struct_builder.initialize(self.comm) self.add_subsystem("mesh_struct", struct_builder.get_mesh_coordinate_subsystem()) diff --git a/tests/regression_tests/test_dafoam_aerostruct.py b/tests/regression_tests/test_dafoam_aerostruct.py index a9374faf..37e26480 100644 --- a/tests/regression_tests/test_dafoam_aerostruct.py +++ b/tests/regression_tests/test_dafoam_aerostruct.py @@ -184,13 +184,8 @@ def problem_setup(scenario_name, fea_assembler, problem): problem.addInertialLoad(g) # TACS Setup - tacs_options = { - "element_callback": element_callback, - "problem_setup": problem_setup, - "mesh_file": "wingbox.bdf", - } - - struct_builder = TacsBuilder(tacs_options) + struct_builder = TacsBuilder(mesh_file="wingbox.bdf", element_callback=element_callback, + problem_setup=problem_setup) struct_builder.initialize(self.comm) self.add_subsystem("mesh_struct", struct_builder.get_mesh_coordinate_subsystem()) From 23299518f802a03e2d31a89343d4d944633907e4 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:51:50 -0400 Subject: [PATCH 2/3] Update TACS recommended version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 447d0687..a620d29b 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Open-source codes with builders and components compatible with mphys: | [MELD](https://github.com/smdogroup/funtofem) | 0.1.0 | Load and Displacement Transfer | Point cloud based transfer scheme. Part of the FUNtoFEM package. | | [pyCycle](https://github.com/OpenMDAO/pyCycle) | 4.2.1 | Propulsion | Thermodynamic cycle modeling library for engines. | | [pyGeo](https://github.com/mdolab/pygeo) | 1.12.3 | Geometric Parameterization | Wrapper for ESP, OpenVSP, and a free-form deformation parameterization. | -| [TACS](https://github.com/smdogroup/tacs) | 3.3.0 | Structures | Parallel Finite Element Analysis. | +| [TACS](https://github.com/smdogroup/tacs) | 3.5.0 | Structures | Parallel Finite Element Analysis. | \* Recommended version to run mphys examples. Older versions may still be supported. From 5daea2c549ca342b684fbe33d20f39201249f69a Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:54:31 -0400 Subject: [PATCH 3/3] pin 3.1.4 mpi4py --- .github/workflows/unit_tests_and_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests_and_docs.yml b/.github/workflows/unit_tests_and_docs.yml index 61fda918..cc6cb743 100644 --- a/.github/workflows/unit_tests_and_docs.yml +++ b/.github/workflows/unit_tests_and_docs.yml @@ -45,7 +45,7 @@ jobs: echo "============================================================="; echo "Install PETSc"; echo "============================================================="; - conda install -c conda-forge mpi4py petsc4py -q -y; + conda install -c conda-forge mpi4py=3.1.4 petsc4py -q -y; echo "============================================================="; echo "Install OpenMDAO"; echo "=============================================================";