Skip to content

Commit

Permalink
Merge pull request #165 from timryanb/update-tacs-api
Browse files Browse the repository at this point in the history
Update TacsBuilder API
  • Loading branch information
kejacobson authored Oct 30, 2023
2 parents 4e41f53 + bdd7a10 commit b725bf7
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 113 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 3 additions & 7 deletions examples/aerostructural/crm9/fun3d_meld_tacs/mphys_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions examples/aerothermal/conjugate_hx_naca0012/run_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
7 changes: 2 additions & 5 deletions examples/struct_only/beam_shape_opt/shape_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions examples/struct_only/crm9/run_tacs_mphys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
9 changes: 2 additions & 7 deletions examples/struct_only/mach_tutorial_wing/mphys_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

################################################################################
Expand Down
3 changes: 2 additions & 1 deletion examples/struct_only/tank_shape_opt/run_tacs_mphys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions tests/integration_tests/test_oas_tacs_meld_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 4 additions & 6 deletions tests/integration_tests/test_oas_tacs_meld_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 3 additions & 6 deletions tests/integration_tests/test_tacs_derivs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
9 changes: 3 additions & 6 deletions tests/integration_tests/test_tacs_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 3 additions & 5 deletions tests/integration_tests/vlm_tacs_meld_check_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 3 additions & 5 deletions tests/integration_tests/vlm_tacs_meld_check_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 3 additions & 7 deletions tests/regression_tests/test_aerostruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
9 changes: 2 additions & 7 deletions tests/regression_tests/test_dafoam_aerostruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit b725bf7

Please sign in to comment.