Skip to content

Fix CUSTOM_OBJFUNC and TAVG_CUSTOM_OBJFUNC missing from historyMap#2747

Closed
Ovocode05 wants to merge 1 commit intosu2code:masterfrom
Ovocode05:objective-function_#2586-complete-and-tested
Closed

Fix CUSTOM_OBJFUNC and TAVG_CUSTOM_OBJFUNC missing from historyMap#2747
Ovocode05 wants to merge 1 commit intosu2code:masterfrom
Ovocode05:objective-function_#2586-complete-and-tested

Conversation

@Ovocode05
Copy link

Fix: Add CUSTOM_OBJFUNC and TAVG_CUSTOM_OBJFUNC to historyMap.py

Fixes Issue

#2586Custom Objective Function Does not Work with shape_optimization.py


Root Cause

historyMap.py is the bridge between the C++ solver output and the Python
optimization framework. Every objective function used in shape_optimization.py
must have a corresponding entry in this map. The entry tells Python:

  • Which GROUP to look in (e.g. COMBO, AERO_COEFF)
  • Which HEADER column to read from the history CSV file
  • What TYPE the field is

CUSTOM_OBJFUNC was never added to this map, despite being fully implemented
in C++ since v7.0.


Test Case

Tested using TestCases/optimization_euler/steady_naca0012/inv_NACA0012_basic.cfg
with the following custom objective (p-norm of surface pressure):

CUSTOM_OUTPUTS= 'P50_avg : AreaAvg{pow(PRESSURE,50)}[airfoil]; P_pnorm50 : Function{pow(P50_avg, 1.0/50.0)}'
CUSTOM_OBJFUNC= 'P_pnorm50'
OBJECTIVE_FUNCTION= CUSTOM_OBJFUNC
OPT_OBJECTIVE= CUSTOM_OBJFUNC * 1.0

How to Run

cd TestCases/optimization_euler/steady_naca0012/

python SU2_PY/shape_optimization.py -g DISCRETE_ADJOINT -f inv_NACA0012_basic.cfg

Before Fix

Screenshot 2026-03-07 173836

Crashes immediately — no simulation runs at all.

After Fix

Screenshot 2026-03-07 174010

Full optimization loop completes successfully.


Related Issues

@Ovocode05 Ovocode05 changed the title pr init Fix CUSTOM_OBJFUNC and TAVG_CUSTOM_OBJFUNC missing from historyMap Mar 7, 2026
@pcarruscag
Copy link
Member

There is a PR open, you can see what are the issues there #2587

@pcarruscag pcarruscag closed this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Objective Function Does not Work

2 participants