Skip to content

feat: multi-field API — set!(fun, ϕ), op!, and grid/field compatibili… - #102

Open
ExpandingMan wants to merge 1 commit into
RallypointOne:mainfrom
ExpandingMan:feat/multi-field-api
Open

ExpandingMan wants to merge 1 commit into
RallypointOne:mainfrom
ExpandingMan:feat/multi-field-api

Conversation

@ExpandingMan

Copy link
Copy Markdown

…ty checks

Expand the package for contexts that combine several fields at once.

  • set! now takes the function first: set!(fun, ϕ). This is breaking (0.1 → 0.2) and makes the do-block form read naturally. Every call site in src, ext, test, docs, examples, benchmarks and the README is updated; the multi-device method in the MDLA extension becomes set!(fun, x, P) for consistency.
  • New op!(fun, ϕ, ϕs...; check=true): pointwise in-place update of ϕ from the cell coordinates and the current values of ϕ and any number of other fields, on Fields and forest fields alike.
  • Compatibility checks for multi-field functions: grid == (same discretization, device ignored), same_layout, compatible, check_compatible, check_layout, with a first-mismatch property walk, an identity fast path, an out-of-line throw, and regrid-currency checks for forest fields. Variadic forms recurse over the argument tuple and measure 0 B under --check-bounds=yes.
  • Unified leaf interface: nleaves, leaf_grid, block, _block_array and _require_current on CartesianGrid/Field, so per-block sweeps can be written once against AbstractGrid/AbstractField.
  • Docstrings for set!, op! and grid ==; new names exported; benchmark compat bumped to 0.2.

This is WIP, map! may be causing issues with enzyme.

…ty checks

Expand the package for contexts that combine several fields at once.

- `set!` now takes the function first: `set!(fun, ϕ)`. This is breaking (0.1 → 0.2)
  and makes the `do`-block form read naturally. Every call site in src, ext, test,
  docs, examples, benchmarks and the README is updated; the multi-device method in
  the MDLA extension becomes `set!(fun, x, P)` for consistency.
- New `op!(fun, ϕ, ϕs...; check=true)`: pointwise in-place update of `ϕ` from the
  cell coordinates and the current values of `ϕ` and any number of other fields,
  on `Field`s and forest fields alike.
- Compatibility checks for multi-field functions: grid `==` (same discretization,
  device ignored), `same_layout`, `compatible`, `check_compatible`, `check_layout`,
  with a first-mismatch property walk, an identity fast path, an out-of-line throw,
  and regrid-currency checks for forest fields. Variadic forms recurse over the
  argument tuple and measure 0 B under `--check-bounds=yes`.
- Unified leaf interface: `nleaves`, `leaf_grid`, `block`, `_block_array` and
  `_require_current` on `CartesianGrid`/`Field`, so per-block sweeps can be written
  once against `AbstractGrid`/`AbstractField`.
- Docstrings for `set!`, `op!` and grid `==`; new names exported; benchmark compat
  bumped to 0.2.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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