Repository navigation
Make ArrayDiscretization the default discretization strategy - #618
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
The array form has a scalarize fallback, so any pattern without a slice representation still produces the pointwise equations and identical numbers. An A/B run of the full test suite with the default flipped -- identical package versions, differing only in this one line -- passed every group the scalarized default passes. What this buys, on the heat equation: the discretized system has 3^N equations for an N-dimensional problem regardless of grid resolution (3 / 9 / 27 in 1D / 2D / 3D), against one per grid point. Discretization takes 0.23 s rather than 47.9 s at 400 points in 1D, 0.14 s rather than 7.5 s at 30x30, and 0.13 s rather than 7.8 s at 11^3. This is breaking, hence 0.12.0: mtkcompile still scalarizes, so solving is unaffected, but anything inspecting the symbolic system sees array equations where it previously saw one scalar equation per point. ScalarizedDiscretization() remains available and unchanged for code that wants the pointwise form, and StrictArrayDiscretization() errors rather than falling back. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S1dxUEPGysx27SSSpxtiQ9
This was referenced Aug 20, 2026
Member
Author
|
The requested default change is subsumed by the combined v1 draft at #650. The stale branch was not replayed because its current diff would revert newer array-discretization work; the combined draft implements the intent by removing strategy selection entirely. Please review that draft there; it should be ignored until reviewed by @ChrisRackauckas. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Draft — please ignore until reviewed by @ChrisRackauckas.
Follow-up to #604, which added
ArrayDiscretizationas opt-in. This makes it the default.Why this is safe
The array path falls back to pointwise discretization for any pattern with no slice
representation, so those cases produce the identical scalar equations and identical
numbers. Where it does apply, solutions match
ScalarizedDiscretizationbitwise, becauseeach region reuses the scalar path's own weight computation rather than re-deriving
stencils.
A/B evidence. Two git worktrees at the same commit with identical package manifests,
differing only in this one default line, running all 23 functional test groups:
Both differences are accounted for and neither is a regression:
2D_Diffusionfails in both arms — a pre-existing nonlinear-Laplacian rule failurewith current dependency versions, unrelated to this change.
Array_Discretizationfailed only in the array arm because of the"default strategy is unchanged" guard test, which asserts the default is scalar.
That test failing when the default flips is it doing its job; this PR inverts it.
The array test group passes 75/75 with the default flipped.
What it buys
Heat equation, discretization only:
Equation count is
3^Nfor anN-dimensional problem regardless of grid resolution.Why this is breaking (0.12.0)
mtkcompilestill scalarizes, so solving is unaffected — same solver, same numbers,same performance. But anything inspecting the symbolic system sees array equations where
it previously saw one scalar equation per grid point. Code doing
length(get_eqs(sys))orpattern-matching on equation structure will see something different, hence the minor bump
rather than a patch.
ScalarizedDiscretization()remains available and unchanged for anything that wants thepointwise form, and
StrictArrayDiscretization()errors rather than falling back.Not included
Documentation examples are unchanged: they call
discretize(pdesys, discretization)andare unaffected by which strategy produces the equations. The pages that describe the
strategies (
MOLFiniteDifference.md, the docstrings) are updated here.Coverage of the docs examples under the array form, and periodic-BC support (which the
Brusselator and several examples need), are being measured/implemented separately — see
#623 for the catalogue of what still falls back.
🤖 Generated with Claude Code
https://claude.ai/code/session_01S1dxUEPGysx27SSSpxtiQ9