Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SU2_PY/SU2/eval/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,10 @@ def update_mesh(config, state=None):
# redundancy check
deform_set = config["DV_KIND"] == config["DEFINITION_DV"]["KIND"]
deform_todo = not config["DV_VALUE_NEW"] == config["DV_VALUE_OLD"]
# the mesh of the state can already be at these values, e.g. when the objective
# of the same design was evaluated before its finite difference gradient
if state.VARIABLES.get("DV_VALUE_NEW") == config["DV_VALUE_NEW"]:
deform_todo = False
if deform_set and deform_todo:

# files to pull
Expand Down
16 changes: 6 additions & 10 deletions SU2_PY/SU2/eval/gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,14 +862,8 @@ def findiff(config, state=None):
# local config
konfig = copy.deepcopy(config)

# check deformation setup
# number of design variables
n_dv = sum(Definition_DV["SIZE"])
deform_set = konfig["DV_KIND"] == Definition_DV["KIND"]
if not deform_set:
dvs_base = [0.0] * n_dv
konfig.unpack_dvs(dvs_base, dvs_base)
else:
dvs_base = konfig["DV_VALUE_NEW"]

# initialize gradients
func_keys = ["VARIABLE"] + opt_names + ["FINDIFF_STEP"]
Expand Down Expand Up @@ -928,13 +922,15 @@ def findiff(config, state=None):
this_step = step[i_dv]
temp_config_name = "config_FINDIFF_%i.cfg" % i_dv

this_dvs = copy.deepcopy(dvs_base)
# the mesh of the base design is already deformed (zero step above),
# so only the step of this design variable is applied to it
this_dvs = [0.0] * n_dv
this_dvs[i_dv] = this_step
this_konfig = copy.deepcopy(konfig)
this_dvs[i_dv] = this_dvs[i_dv] + this_step

this_state = su2io.State()
this_state.FILES = copy.deepcopy(state.FILES)
this_konfig.unpack_dvs(this_dvs, dvs_base)
this_konfig.unpack_dvs(this_dvs)

this_konfig.dump(temp_config_name)

Expand Down