Skip to content

Add the forward simulation API and package checks - #20

Open
peteryu0131 wants to merge 12 commits into
polyfem:mainfrom
peteryu0131:forward-api
Open

peteryu0131 wants to merge 12 commits into
polyfem:mainfrom
peteryu0131:forward-api

Conversation

@peteryu0131

@peteryu0131 peteryu0131 commented Nov 16, 2026 •

Copy link
Copy Markdown

This PR adds a Python API for forward simulations. Users can create a model with polyfem.model(), attach materials and boundary conditions to its meshes, and pass the configuration to polyfempy.solve(). The builder manages the selection IDs for file and array meshes.

The Python package pins the official PolyFEM backend at 836c923. The PR updates the generator and data submodules, keeps the extension build adapters in the Python repository, and adds a cantilever example, an installation check, and package checks for wheels and conda.

Local validation on Windows x64 with Python 3.11

  • 347 Python tests passed. Windows skipped two tests for other operating systems.
  • All 93 classic examples produced configurations equivalent to their source JSON. With Triangle disabled, 85 completed at the regression step counts through both the API and JSON with matching metrics. Of those, 83 also matched the stored reference values.
  • The README cantilever, installation check, static elasticity quickstart, and cube reference passed with the local build.

Local Triangle validation on Windows x64 with Python 3.11

I rebuilt PolyFEM 836c923 with POLYFEM_WITH_TRIANGLE=ON. All six higher-order contact examples passed with this local build. I ran each example through the Python API and its original JSON using the official regression step count. The P1, P2, P3, and P4 ball-bounce cases and the microstructure case each ran for one step. The P4 ball-bounce variant with dt=0.01 ran for 20 steps.

All 12 solves completed. The six reported metrics matched exactly between the API and JSON in every case. The largest relative error against a stored reference was 4.15e-11, within the official tolerance of 1e-5.

Open validation items

  • The Windows HDF5 proxy screw case fails while reading an integer attribute. The transient linear elasticity quickstart crashes with both Python and direct JSON input.
  • The static two-cube and five-cube hex cases differ from their stored references. The armadillo roller reached the 180-second limit on both paths.
  • Native wheel and conda installation checks across the supported platforms and Python versions remain pending for this revision.

Prepare the forward simulation API for upstream review.

Includes model building, solver runtime, examples, documentation, packaging, and CI checks. Preserve the exact file tree and pinned submodules from jingyaoyu_forward at 4440efc.

Base this review commit on official main at 4f15f37 because the fork's older history has different commit IDs after signature removal. The original development branch and history remain unchanged.
Pin the spec-driven generator and keep mesh, selection and RHS behavior in the PolyFEM package. Configure project naming and ID relationships alongside the builder.

Ship the builder with the Python package and let the existing CMake recipe find nanobind.
Let the backend merge common JSON settings. Reject explicit volume IDs that collide with an automatically assigned body ID, and preserve explicit mesh paths when a file is missing. Cover each case with a regression test.
Reuse the JSON cleaner, remove the unused point selection helper, and check the solver result directly. Read factory names from the generated manifest and consolidate the solve-path tests across all classic examples.
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.

1 participant