Skip to content

[ad-16] expose GVEC preconditioner operator#50

Open
krystophny wants to merge 24 commits into
developfrom
ad-16-preconditioner-operator
Open

[ad-16] expose GVEC preconditioner operator#50
krystophny wants to merge 24 commits into
developfrom
ad-16-preconditioner-operator

Conversation

@krystophny

Copy link
Copy Markdown
Member

Closes #17.

Expose the current-state GVEC preconditioner as a reusable flat-vector operator:

  • State.apply_preconditioner(vector) validates the shared flat layout and returns a new transformed vector.
  • The pyGVEC wrapper assembles the MHD3D preconditioner from the current state without changing q.
  • The Fortran operator applies boundary RHS transforms and the factorized preconditioner matrices to the supplied vector, not to the solver force.
  • Builds with PrecondType <= 0 raise a typed UnsupportedFeatureError instead of silently returning a non-preconditioned solver transform.

Verification

Test fails on main

On the parent of this PR branch:

$ uv run pytest test-CI/unit-pygvec/test_ad_preconditioner.py -q --require-pygvec
FFFFFFF                                                                  [100%]
AttributeError: 'State' object has no attribute 'apply_preconditioner'
7 failed in 0.90s

Test passes after fix

$ uv pip install -e .
Built gvec
Installed gvec

$ uv run pytest test-CI/unit-pygvec/test_ad_preconditioner.py -q --require-pygvec
........                                                                 [100%]
8 passed in 12.82s

$ uv run pytest test-CI/unit-pygvec/test_ad_layout.py test-CI/unit-pygvec/test_ad_energy.py test-CI/unit-pygvec/test_ad_raw_force.py test-CI/unit-pygvec/test_ad_context.py test-CI/unit-pygvec/test_ad_public_api.py test-CI/unit-pygvec/test_ad_preconditioner.py -q --require-pygvec
..........................sss..s...                                      [100%]
31 passed, 4 skipped in 13.26s

$ git diff --check
# no output

$ fo
fo: no Fortran project detected

@krystophny

Copy link
Copy Markdown
Member Author

Fixed AD-16 by adding State.apply_preconditioner(vector), backed by the existing MHD3D preconditioner matrices rather than solver-force evaluation. The operator validates flat-vector layout, preserves the loaded state and input vector, is deterministic and linear on the fixture, and raises UnsupportedFeatureError when PrecondType disables the preconditioner.

@krystophny krystophny force-pushed the ad-16-preconditioner-operator branch from e68d373 to 62d6c2b Compare July 9, 2026 20:01
@krystophny krystophny force-pushed the ad-16-preconditioner-operator branch from 62d6c2b to f936c8f Compare July 9, 2026 20:58
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