From 188b3f696f9ac081bd7f6cd27517c9848ce423d4 Mon Sep 17 00:00:00 2001 From: "Burke, Brian" Date: Wed, 20 Nov 2024 12:32:21 -0500 Subject: [PATCH] Only do shape sens for thickness struct vars --- funtofem/driver/funtofem_shape_driver.py | 3 ++- funtofem/model/_base.py | 10 +++++----- funtofem/model/funtofem_model.py | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/funtofem/driver/funtofem_shape_driver.py b/funtofem/driver/funtofem_shape_driver.py index ead54c2d..2b1783da 100644 --- a/funtofem/driver/funtofem_shape_driver.py +++ b/funtofem/driver/funtofem_shape_driver.py @@ -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 diff --git a/funtofem/model/_base.py b/funtofem/model/_base.py index 5e6179a2..2cf0008c 100644 --- a/funtofem/model/_base.py +++ b/funtofem/model/_base.py @@ -370,9 +370,9 @@ 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) @@ -380,7 +380,7 @@ def _print_variables(self, vartype): self._print_long("Coupled", width=9, end_line=True) print( - " --------------------------------------------------------------------------------------" + " ----------------------------------------------------------------------------------------------" ) for var in self.variables[vartype]: _name = "{:s}".format(var.name) @@ -392,7 +392,7 @@ 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) @@ -400,7 +400,7 @@ def _print_variables(self, vartype): self._print_long(_coupled, width=9, end_line=True) print( - " --------------------------------------------------------------------------------------" + " ----------------------------------------------------------------------------------------------" ) return diff --git a/funtofem/model/funtofem_model.py b/funtofem/model/funtofem_model.py index dacba448..af0f5768 100644 --- a/funtofem/model/funtofem_model.py +++ b/funtofem/model/funtofem_model.py @@ -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. @@ -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)