Commit 6c1eac1
committed
Fix __resize! on AbstractVectorOfArray under RecursiveArrayTools v4
Closes #484.
`__resize!(::AbstractVectorOfArray, n, M)` was missed by the
SciMLBase-v3 / RecursiveArrayTools-v4 compatibility patch
(bea82b8). Under RAT v4, `AbstractVectorOfArray` subtypes
`AbstractArray` with column-major linear-indexing semantics, so:
- `length(x)` is now the total scalar count (`prod(size(x))`),
not the number of timesteps.
- `last(x)` is now the last scalar, not the last timestep vector.
- `append!(x, ::AbstractVectorOfArray)` falls back to the generic
AbstractArray `append!`, which iterates scalars rather than
timestep vectors.
The old code in `__resize!`:
N = n - length(x)
N > 0 ? append!(x, VectorOfArray([safe_similar(last(x)) for _ in 1:N])) :
resize!(x, n)
silently miscomputes `N` (target timesteps minus scalar count)
and never grows `x.u`, so subsequent `cache.y₀.u[i]` reads on
the post-mesh-refinement loop in MIRK / FIRK hit `#undef` and
throw `UndefRefError` from `mirk.jl:342` (`firk.jl` analog).
Switch to `x.u` for both `length` and `last`, and `append!`
directly into `x.u` instead of constructing a wrapper
`VectorOfArray`. `resize!(x, n)` already delegates to
`resize!(x.u, n)` in RAT v4 and is left as-is.
The same pattern fix applies to the FIRK-specific overloads
in `BoundaryValueDiffEqFIRK/src/utils.jl` for both
`FIRKTableau{false}` and `FIRKTableau{true}`.
Adds a regression test based on the issue MWE (torus geodesic
BVP that triggers adaptive mesh refinement).
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>1 parent e0cd15b commit 6c1eac1
4 files changed
Lines changed: 43 additions & 7 deletions
File tree
- lib
- BoundaryValueDiffEqCore
- src
- BoundaryValueDiffEqFIRK/src
- BoundaryValueDiffEqMIRK/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
0 commit comments