Skip to content

Commit

Permalink
Only do shape sens for thickness struct vars
Browse files Browse the repository at this point in the history
  • Loading branch information
bburke38 committed Nov 20, 2024
1 parent cf74a0f commit 188b3f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion funtofem/driver/funtofem_shape_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,8 @@ def _get_struct_shape_derivatives(self, scenario):
gradients.append([])
for ivar, var in enumerate(variables):
derivative = None
if var.analysis_type == "structural":
# Hack to only get shape derivatives for thickness from CAPS
if var.analysis_type == "structural" and "-T" in var.name:
if self.struct_aim.root_proc:
derivative = self.struct_aim.aim.dynout[func.full_name].deriv(
var.full_name
Expand Down
10 changes: 5 additions & 5 deletions funtofem/model/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,17 @@ def _print_functions(self):

def _print_variables(self, vartype):
print(
" --------------------------------------------------------------------------------------"
" ----------------------------------------------------------------------------------------------"
)
self._print_long("Variable", width=12, indent_line=5)
self._print_long("Variable", width=20, indent_line=5)
self._print_long("Var. ID", width=10)
self._print_long("Value", width=16)
self._print_long("Bounds", width=24)
self._print_long("Active", width=8)
self._print_long("Coupled", width=9, end_line=True)

print(
" --------------------------------------------------------------------------------------"
" ----------------------------------------------------------------------------------------------"
)
for var in self.variables[vartype]:
_name = "{:s}".format(var.name)
Expand All @@ -392,15 +392,15 @@ def _print_variables(self, vartype):
_coupled = str(var.coupled)
_bounds = " ".join(("[", _lower, ",", _upper, "]"))

self._print_long(_name, width=12, indent_line=5)
self._print_long(_name, width=20, indent_line=5)
self._print_long(_id, width=10, align="<")
self._print_long(_value, width=16)
self._print_long(_bounds, width=24)
self._print_long(_active, width=8)
self._print_long(_coupled, width=9, end_line=True)

print(
" --------------------------------------------------------------------------------------"
" ----------------------------------------------------------------------------------------------"
)

return
Expand Down
14 changes: 12 additions & 2 deletions funtofem/model/funtofem_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,13 @@ def write_unsteady_aero_loads(self, comm, prefix, suffix=".txt", root=0):
return loads_files

def write_sensitivity_file(
self, comm, filename, discipline="aerodynamic", root=0, write_dvs: bool = True
self,
comm,
filename,
discipline="aerodynamic",
root=0,
write_dvs: bool = True,
only_thickness=True,
):
"""
Write the sensitivity file.
Expand Down Expand Up @@ -859,7 +865,11 @@ def write_sensitivity_file(
for var in variables:
# Write the variables whose analysis_type matches the discipline string.
if discipline == var.analysis_type and var.active:
discpline_vars.append(var)
if discipline == "structural" and only_thickness:
if "-T" in var.name:
discpline_vars.append(var)
else:
discpline_vars.append(var)

# Write out the number of sets of discpline variables
num_dvs = len(discpline_vars)
Expand Down

0 comments on commit 188b3f6

Please sign in to comment.