Repository navigation
Support mixed derivatives in ArrayDiscretization - #648
Merged
Merged
Conversation
`Dx(Dy(u))` caused the whole equation to fall back to pointwise discretization. The scalar scheme (`mixed_central_difference`) is the tensor product of the two centered first order stencils, which is translation invariant across the interior in both directions at once, so it has a slice form: the same broadcasted sum of shifted slices `array_central_difference` builds, with a second shifted axis. - `array_shifted_slice` generalises `array_slice` to shifts along several axes, each wrapped independently where its direction is periodic, mirroring the two separately `bwrap`ped tap sets the scalar path takes the product of. - `array_interior_stencil` factors the interior `(weights, taps)` out of `array_central_difference` so both it and the mixed form take their weights from the same `DerivativeOperator`s the scalar path uses. - `array_bands` gains the directions a mixed derivative reaches along: those use the *centered* first order stencil, which at higher approximation orders is wider than the winding stencil the order 1 entry of `pdeorders` would select. Without this an equation whose only derivative in a direction is the mixed one builds a band that reaches past the grid and degrades to pointwise. Mixed patterns the scalar path has no scheme for, such as a mixed derivative of higher order in one direction, still reach `arrayify` with a spatial differential in place and fall back (and raise under `StrictArrayDiscretization`). The discretized equation sets are identical to `ScalarizedDiscretization`: on a 2D diffusion equation with `0.5*Dxy(u)` on 11x11, 21x21 and 41x41 grids the array form is 9 equations at every resolution against 121/441/1681 scalar ones, with both the right hand side at a random state and the solution matching bitwise (maxdiff 0.0). Co-Authored-By: Chris Rackauckas <[email protected]>
…n array internals
utkuyilmaz1903
marked this pull request as ready for review
August 20, 2026 14:24
ChrisRackauckas
pushed a commit
that referenced
this pull request
Aug 23, 2026
Generalize the #648 tensor-product scheme from Dx(Dy(u)) to two-direction mixed derivatives of arbitrary order on both the slice and pointwise paths.
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.
Supersedes #625: takes over the mixed-derivative work and rebases it onto current
master, which now carries WENO/functional advection, staggered grids and nonlinear/spherical Laplacians in array form. Part of #623.Summary
Dx(Dy(u))previously made the whole equation fall back to pointwise discretization underArrayDiscretization. The scalar scheme (mixed_central_difference) is the tensor product of the two centered first-order stencils, translation invariant across the interior, so it has a slice form: the existing broadcasted sum of shifted slices, with a second shifted axis.array_shifted_slicegeneralisesarray_sliceto simultaneous shifts along several axes, each wrapped independently where its direction is periodic.array_interior_stencilfactors the interior(weights, taps)out ofarray_central_difference, so the mixed form takes its weights from the sameDerivativeOperators the scalar path uses.array_bands/array_tap_extentsaccount for the directions a mixed derivative reaches along: those use the centered first-order stencil, which at approximation orders 4/6 is wider than the winding stencil the order-1 entry ofpdeorderswould select. Without this the band reaches past the grid and the equation silently degrades to pointwise.Results
All cases verified against
ScalarizedDiscretizationon the current master base:Dxy, approx order 2/4/6 (strict mode)(0.3 + 0.2xy) * Dxy(u)DxzDx^2(Dy(u))and higher combinationsThe equation count stays independent of the grid resolution in every array case.
Falls back
Patterns the scalar path has no mixed scheme for keep falling back to pointwise scalar equations (and raise under
StrictArrayDiscretization): higher-order mixed combinations, mixed derivatives inside coefficients, mixed derivatives on staggered grids, and mixed derivatives of boundary values. Results therefore always matchScalarizedDiscretization.