Repository navigation
Fix STATION function names in SU2_PY: SU2_GEO numbers stations from 1 - #2934
nikita-ageev wants to merge 5 commits into
Conversation
SU2_GEO writes STATION1_* ... STATIONn_* for the stations in GEO_LOCATION_STATIONS, while optnames_geo listed STATION0_* ... STATION19_*. STATION20_* was therefore rejected by SU2.eval.func/grad as an unknown function name, and STATION0_* is never written.
|
Hi! A gentle ping on this one and the two related PRs (#2935, #2952) — whenever a maintainer has a moment, could you approve the CI workflows so the regression tests can run? All three are small, rebased cleanly onto develop and pass pre-commit locally; #2952 fixes the fixed-CL issue #2937 and includes a reproduction. Happy to adjust anything. Thanks! |
| # see SU2_GEO.cpp, so the names cover stations 1 to 20. | ||
| PerStation = [] | ||
| for i in range(20): | ||
| for i in range(1, 21): |
There was a problem hiding this comment.
Why a 20-cap? Can we remove the cap in SU2_PY?
There was a problem hiding this comment.
Good point, there was no reason for it: SU2_GEO does not limit the number of stations, the 20 just came from the old list. Removed the cap in 8d4f4de: the per-station names are now matched with a regex (STATION<n>_<field>, n >= 1) in a new su2io.is_optname_geo(), used in eval/functions.py and eval/gradients.py instead of the fixed optnames_geo list. Also dropped the "1 to 20" note from config_template.cfg.
Thanks for the review!
Address review comment: instead of listing STATION1_* ... STATION20_*, match the per-station names with a regex (is_optname_geo), since SU2_GEO does not limit the number of GEO_LOCATION_STATIONS.
…spaces) (#2935) ## Proposed Changes `SU2_PY/SU2/run/interface.py` builds the command as `os.path.join(SU2_RUN, "SU2_CFD") + " config_CFD.cfg"` and runs it with `shell=True`. The executable path is quoted only on Windows (`quote = '"' if sys.platform == "win32" else ""`), so on Linux/macOS any SU2_PY script (shape_optimization.py, parallel_computation.py, ...) fails if `SU2_RUN` contains a space. This PR moves the quoting into `build_command`: the first word of the command is joined with `SU2_RUN` and quoted (`shlex.quote` on POSIX, double quotes on Windows as before), the callers pass plain `"SU2_CFD config_CFD.cfg"` strings. The quoted path is then inserted into the MPI template as before (`mpirun -n %i %s`, `srun`, `SU2_MPI_COMMAND`). The module-level `quote` variable is removed; it was not used outside `interface.py`. Reproduction on macOS, `SU2_RUN=".../su2 bin"`, `shape_opt_euler_py` from serial_regression.py: ``` before: Command = /.../su2 bin/SU2_CFD config_CFD.cfg SU2 process returned error '127' /bin/sh: /.../su2: No such file or directory after: Command = '/.../su2 bin/SU2_CFD' config_CFD.cfg optimization runs to the end ``` With the change and `SU2_RUN` containing a space, `history_project.csv` and the optimizer output of `shape_opt_euler_py` are identical to develop with a `SU2_RUN` without spaces. The MPI path was checked with `NUMBER_PART=2`: `mpirun -n 2 '/.../su2 bin/SU2_CFD' config_CFD.cfg` runs with 2 ranks. The Windows branch produces the same string as before. ## Related Work None found. Separate from #2934 (also SU2_PY). ## PR Checklist - [X] I am submitting my contribution to the develop branch. - [X] My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson). - [X] My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/). - [X] I used the pre-commit hook to prevent dirty commits and used `pre-commit run --all` to format old commits. - [X] I have added a test case that demonstrates my contribution, if necessary. — Not necessary: the change only affects how the executable path is quoted; `shape_opt_euler_py` passes unchanged, and the reproduction above (SU2_RUN with a space) fails before and passes after. - [X] I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary. — Not necessary: no user-facing option changed. Co-authored-by: Nijso <bigfootedrockmidget@hotmail.com>
SU2_GEO writes STATION1_* ... STATIONn_* for the stations in GEO_LOCATION_STATIONS, while optnames_geo listed STATION0_* ... STATION19_. STATION20_ was therefore rejected by SU2.eval.func/grad as an unknown function name, and STATION0_* is never written.
Proposed Changes
Give a brief overview of your contribution here in a few sentences.
Related Work
Resolve any issues (bug fix or feature request), note any related PRs, or mention interactions with the work of others, if any.
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.shape_opt_euler_pyare unaffected, and the reproduction above covers STATION20_.config_template.cfg: documented the 1-based STATION numbering. SU2_PY acceptsSTATION#_*for any number of stations (no 20-station cap).