Skip to content

Parametric sweep module - #395

Open
bburke38 wants to merge 12 commits into
smdogroup:masterfrom
bburke38:feature/sweep-module
Open

Parametric sweep module#395
bburke38 wants to merge 12 commits into
smdogroup:masterfrom
bburke38:feature/sweep-module

Conversation

@bburke38

@bburke38 bburke38 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

New funtofem.sweep submodule: a reusable, callback-driven parameter sweep framework that replaces case-specific sweep scripts. Purely additive: everything lives in a new subpackage, and the only change to existing code is the export line in funtofem/__init__.py.

Marked experimental: the API may change without a deprecation cycle. Deliberately not re-exported into the top-level funtofem namespace. Users must import explicitly:

from funtofem.sweep import ParameterSweep

What's in it

  • SweepStrategy ABC with CartesianStrategy (full product) and ZipStrategy (element-wise) built in; subclass for LHS/Sobol.
  • MeshMode enum controls which mesh callbacks fire per design point (FULL_REGEN / CFD_ONLY / STRUCT_ONLY / NONE).
  • ParameterSweep orchestrates the lifecycle: point enumeration, per-point directory isolation, mesh regeneration, model/solver construction, forward and adjoint solves, result extraction, and incremental CSV output. All set_* callbacks validate their signature at registration time and return self for chaining.
  • SlurmSweepSubmitter generates and submits one SLURM job per design point, with dry_run and skip_completed modes. Jobs re-enter the user's script through the --point-file CLI path (cli_mainrun_single).

Robustness

Per-point failures are caught and recorded as status = "failed" rather than aborting the sweep, and CSV rows are written incrementally so partial results survive an interruption. resume=True skips points already recorded as successful.

Output layout

Design keys default to a SHA-256 hash of the JSON-serialized point, truncated to pt_ + 12 hex chars, so key length is independent of parameter count. key_fn overrides this for readable keys on small sweeps.

cfd_root and struct_root share a <root>/<key>/<kind> template, so with the defaults everything for a design point lands in one directory:

sweep_output/<key>/point.json
sweep_output/<key>/cfd/
sweep_output/<key>/struct/

Setting them to different roots splits the two trees instead (e.g., for clusters where CFD output belongs on scratch while structural results stay on a backed-up filesystem).

Experimental marking

ParameterSweep and SlurmSweepSubmitter carry a .. warning:: **Experimental.** block at the top of their class docstrings, in the numpydoc slot after the short summary, so Sphinx renders it as a callout and it shows in help() and IDE hover.

Testing

tests/unit_tests/sweep/ — tests across six modules covering point execution, CSV writing, resume logic, the --point-file CLI, the SLURM submitter, and the per-point output layout. They import the sweep modules directly rather than through funtofem, so they run without native TACS or FUN3D.

@bburke38 bburke38 self-assigned this Aug 7, 2026
@bburke38 bburke38 added the enhancement New feature or request label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant