Skip to content

Commit

Permalink
Allow setting inactive thickness variables (smdogroup#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
bburke38 authored Jan 30, 2024
1 parent 2ce0820 commit dae543f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 17 additions & 8 deletions tacs/caps2tacs/tacs_aim.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ def setup_aim(
# link the egads aim to the tacs aim
self.aim.input["Mesh"].link(self._mesh_aim.aim.output["Surface_Mesh"])

# add the design variables to the DesignVariable and DesignVariableRelation properties
# Add the design variables to the DesignVariable and DesignVariableRelation properties
# for active variables only.
DV_dict = {}
if len(self.thickness_variables) > 0:
if len(self.active_thickness_variables) > 0:
self.aim.input.Design_Variable_Relation = {
dv.name: dv.DVR_dictionary
for dv in self._design_variables
if isinstance(dv, ThicknessVariable)
if isinstance(dv, ThicknessVariable) and dv._active
}

# register all thickness variables to each proc
Expand Down Expand Up @@ -268,10 +269,17 @@ def variables(self) -> List[ShapeVariable or ThicknessVariable]:
def shape_variables(self) -> List[ShapeVariable]:
return [dv for dv in self.variables if isinstance(dv, ShapeVariable)]

@property
def active_thickness_variables(self) -> List[ThicknessVariable]:
"""
Return only active sorted thickness variables.
"""
return [dv for dv in self.thickness_variables if dv._active]

@property
def thickness_variables(self) -> List[ThicknessVariable]:
"""
return sorted thickness vars so that the TACS derivatives can be appropriately obtained
Return sorted thickness vars so that the TACS derivatives can be appropriately obtained.
"""
thick_var_names = [
dv.name for dv in self.variables if isinstance(dv, ThicknessVariable)
Expand Down Expand Up @@ -362,13 +370,14 @@ def update_properties(self):
dv, ThicknessVariable
):
if property.caps_group == dv.caps_group:
property.membrane_thickness == dv.value
property.membrane_thickness = dv.value
break

# input new design var and property cards
self.aim.input.Design_Variable = {
dv.name: dv.DV_dictionary for dv in self._design_variables
}
if len([_ for _ in self._design_variables if _._active]) > 0:
self.aim.input.Design_Variable = {
dv.name: dv.DV_dictionary for dv in self._design_variables
}
self.aim.input.Property = {
prop.caps_group: prop.dictionary for prop in self._properties
}
Expand Down
3 changes: 1 addition & 2 deletions tacs/caps2tacs/tacs_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ def update_design(self, input_dict: dict = None):
changed_design = True

# update thickness prop cards in t
if self.tacs_aim.change_shape:
self.tacs_aim.update_properties()
self.tacs_aim.update_properties()

# record whether the design has changed & first analysis flag as well
if self._first_analysis:
Expand Down

0 comments on commit dae543f

Please sign in to comment.