feat(transforms): add xeltofab mesh transform bridge#240
feat(transforms): add xeltofab mesh transform bridge#240xarthurx wants to merge 2 commits intoIDEALLab:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new engibench.transforms.xeltofab transform module to convert EngiBench density-field designs (2D/3D) into fabrication-ready contours/meshes via the optional xeltofab dependency, with presets and validation plus a dedicated test suite.
Changes:
- Introduces
to_mesh()/save()API, per-problem pipeline presets, and input/output validation for density-field → contour/mesh conversion. - Adds
transformsoptional dependency (Python >= 3.13 marker) and mypy missing-import overrides forxeltofab. - Adds
pytestsuite for validation, presets, parameter overrides, and basic mesh/contour outputs (skipped whenxeltofabisn’t installed).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
engibench/transforms/__init__.py |
Adds transforms package root. |
engibench/transforms/xeltofab/__init__.py |
Exposes public API (to_mesh, save, PROBLEM_PRESETS). |
engibench/transforms/xeltofab/_core.py |
Implements bridge logic using xeltofab pipeline. |
engibench/transforms/xeltofab/_presets.py |
Defines per-problem default pipeline parameter dicts. |
engibench/transforms/xeltofab/_validate.py |
Adds density-field input sanitization and post-pipeline validation. |
pyproject.toml |
Adds transforms extra (py>=3.13) and mypy import overrides for xeltofab. |
tests/transforms/__init__.py |
Creates tests subpackage for transforms. |
tests/transforms/test_xeltofab.py |
Adds tests for validation, presets, 2D/3D conversion, saving, and overrides. |
Comments suppressed due to low confidence (1)
pyproject.toml:44
- CI currently installs
.[all](see.github/workflows/test.yml), but theallextra here doesn’t includetransforms, soxeltofabwon’t be installed and the newtests/transforms/test_xeltofab.pysuite will be skipped even on the Python 3.13 jobs. Consider addingtransformsintoallbehind the samepython_version >= '3.13'marker (or updating CI to install.[transforms]on 3.13) so this feature is exercised in CI.
[project.optional-dependencies]
airfoil = ["sqlitedict>=1.6"] # for pyopt_history.py
electronics = ["networkx >= 3.2.1"]
beams2d = ["cvxopt >= 1.3.2", "seaborn", "scipy"]
thermoelastic2d = ["cvxopt >= 1.3.2", "mmapy >= 0.3.0"]
thermoelastic3d = ["cvxopt >= 1.3.2", "mmapy >= 0.3.0", "napari", "pyamg"]
photonics2d = ["ceviche >= 0.1.3"]
transforms = ["xeltofab >= 0.3.0; python_version >= '3.13'"]
all = [
# All dependencies above
"engibench[airfoil,beams2d,thermoelastic2d,thermoelastic3d,photonics2d,electronics]"
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
772edea to
dc07d42
Compare
Add engibench.transforms.xeltofab module that converts density-field problem outputs to fabrication-ready meshes via the xeltofab library. Covers 6 of 8 builtin problems (all density-field types). Includes per-problem pipeline presets, input/output validation, and 18 tests. xeltofab is an optional dependency requiring Python 3.13+.
dc07d42 to
a4ecfc8
Compare
|
For questions in #142: 1. Make Matrix of EngiBench/EngiOpt Input and Output typesSee above chart. 2. Prioritize which conversions are highest value / can we just convert to/from a single one?Yes — single interchange format: the 3. How do we parametrize any conversion parameters?Per-problem presets in PROBLEM_PRESETS dict (
# Defaults from preset
state = to_mesh(problem, design)
# User override
state = to_mesh(problem, design, smooth_sigma=2.0, threshold=0.4)4. How do we tell that it was successful/validated?Two-stage validation in
|
g-braeunlich
left a comment
There was a problem hiding this comment.
Only very minor suggestions. Otherwise looks very good to me (including optional dependency handling).
|
I removed I kept it in |
Description
Add
engibench.transforms.xeltofabmodule that bridges EngiBench density-field problem outputs to fabrication-ready meshes via the xeltofab library.This addresses the roadmap item: Transforms ability — Make Matrix of EngiBench/EngiOpt Input and Output types.
Demo Results
2D: Density Field → Contour Extraction
3D: Density Field → Mesh Extraction
I/O Type Matrix
volfracvolfracvolfracvolumevolumeSingle interchange format: The numpy density array — all 6 compatible problems already output this natively. Airfoil (boundary coordinates) and PowerElectronics (circuit parameters) require fundamentally different conversion paths and are excluded.
Approach
to_mesh(problem, design, **kwargs)— One-call conversion. Auto-selects per-problem pipeline presets (threshold, smoothing, extraction method, decimation).**kwargsor explicitPipelineParams. Presets serve as sensible defaults.RuntimeError; volume drift warns.Usage
Install:
pip install engibench[transforms](requires Python >= 3.13)Type of change
Files
engibench/transforms/__init__.pyengibench/transforms/xeltofab/__init__.pyto_mesh,save,PROBLEM_PRESETSengibench/transforms/xeltofab/_core.pyengibench/transforms/xeltofab/_presets.pyengibench/transforms/xeltofab/_validate.pytests/transforms/test_xeltofab.pypyproject.tomltransforms+ mypy overrideChecklist:
pre-commitchecks withpre-commit run --all-filesruff check .andruff formatmypy .