Skip to content

Commit 04c666b

Browse files
Merge pull request #472 from ChrisRackauckas-Claude/scimlbase-v3-compat
Update for SciMLBase v3 compatibility
2 parents c992e4d + 39437b3 commit 04c666b

17 files changed

Lines changed: 41 additions & 41 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Random = "1.10"
6060
ReTestItems = "1.29"
6161
RecursiveArrayTools = "3.31.2"
6262
Reexport = "1.2"
63-
SciMLBase = "2.152.1"
63+
SciMLBase = "2.152.1, 3"
6464
Sparspak = "0.3.11"
6565
StaticArrays = "1.9.8"
6666
Test = "1.10"

lib/BoundaryValueDiffEqAscher/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Random = "1.10"
3636
ReTestItems = "1.23.1"
3737
RecursiveArrayTools = "3.27.0"
3838
Reexport = "1.2"
39-
SciMLBase = "2.152.1"
39+
SciMLBase = "2.152.1, 3"
4040
Setfield = "1.1.1"
4141
StaticArrays = "1.9.8"
4242
Test = "1.10"

lib/BoundaryValueDiffEqCore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ OptimizationBase = "5.1"
4545
PreallocationTools = "1.2"
4646
RecursiveArrayTools = "3.27.0"
4747
Reexport = "1.2"
48-
SciMLBase = "2.152.1"
48+
SciMLBase = "2.152.1, 3"
4949
SciMLLogging = "1.8.0"
5050
SciMLStructures = "1.7.0"
5151
Setfield = "1"

lib/BoundaryValueDiffEqCore/src/utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function eval_bc_residual!(
196196
resid::AbstractArray{<:AbstractArray},
197197
::StandardSecondOrderBVProblem, bc!::BC, sol, dsol, p, t
198198
) where {BC}
199-
M = length(sol[1])
199+
M = length(sol.u[1])
200200
res_bc = vcat(resid[1], resid[2])
201201
bc!(res_bc, dsol, sol, p, t)
202202
copyto!(resid[1], res_bc[1:M])
@@ -472,8 +472,8 @@ end
472472

473473
# Restructure Solution
474474
function __restructure_sol(sol::AbstractVectorOfArray, u_size)
475-
(size(first(sol)) == u_size) && return sol
476-
return VectorOfArray(map(Base.Fix2(reshape, u_size), sol))
475+
(size(first(sol.u)) == u_size) && return sol
476+
return VectorOfArray(map(Base.Fix2(reshape, u_size), sol.u))
477477
end
478478
function __restructure_sol(sol::AbstractArray{<:AbstractArray}, u_size)
479479
(size(first(sol)) == u_size) && return sol
@@ -586,7 +586,7 @@ Returns the length of the initial guess. If the initial guess is a function or n
586586
guess is supplied, it returns `-1`.
587587
"""
588588
@inline __initial_guess_length(u₀::AbstractVector{<:AbstractArray}) = length(u₀)
589-
@inline __initial_guess_length(u₀::VectorOfArray) = length(u₀)
589+
@inline __initial_guess_length(u₀::VectorOfArray) = length(u₀.u)
590590
@inline __initial_guess_length(u₀::DiffEqArray) = length(u₀.t)
591591
@inline __initial_guess_length(u₀::SciMLBase.ODESolution) = length(u₀.t)
592592
@inline __initial_guess_length(u₀::F) where {F} = -1

lib/BoundaryValueDiffEqFIRK/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Random = "1.10"
5353
ReTestItems = "1.23.1"
5454
RecursiveArrayTools = "3.27.0"
5555
Reexport = "1.2"
56-
SciMLBase = "2.152.1"
56+
SciMLBase = "2.152.1, 3"
5757
SciMLStructures = "1.7.0"
5858
Setfield = "1.1.1"
5959
SparseArrays = "1.10"

lib/BoundaryValueDiffEqFIRK/src/adaptivity.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ After we construct an interpolant, we use interp_eval to evaluate it.
1010
) where {iip, T}
1111
j = interval(mesh, t)
1212
h = mesh_dt[j]
13-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
13+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
1414
if lf > 1
1515
h *= lf
1616
end
@@ -55,7 +55,7 @@ end
5555
) where {iip, T}
5656
j = interval(mesh, t)
5757
h = mesh_dt[j]
58-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
58+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
5959
if lf > 1
6060
h *= lf
6161
end
@@ -103,7 +103,7 @@ end
103103

104104
j = interval(mesh, t)
105105
h = mesh_dt[j]
106-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
106+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
107107
if lf > 1
108108
h *= lf
109109
end
@@ -150,7 +150,7 @@ end
150150

151151
j = interval(mesh, t)
152152
h = mesh_dt[j]
153-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
153+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1) # Cache length factor. We use a h corresponding to cache.y. Note that this assumes equidistributed mesh
154154
if lf > 1
155155
h *= lf
156156
end

lib/BoundaryValueDiffEqFIRK/src/firk.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,18 @@ function SciMLBase.solve!(
485485
if tune_parameters && SciMLStructures.isscimlstructure(prob.p)
486486
tunable_part, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), prob.p)
487487
length_u = cache.M - length(tunable_part)
488-
new_p = repack(first(cache.y₀)[(length_u + 1):end])
488+
new_p = repack(cache.y₀.u[1][(length_u + 1):end])
489489
prob = remake(prob; p = new_p)
490-
map(x -> resize!(x, length_u), cache.y₀)
490+
foreach(x -> resize!(x, length_u), cache.y₀.u)
491491
resize!(cache.fᵢ₂_cache, length_u)
492492
elseif tune_parameters
493493
length_u = cache.M - length(prob.p)
494-
prob = remake(prob; p = first(cache.y₀)[(length_u + 1):end])
495-
map(x -> resize!(x, length_u), cache.y₀)
494+
prob = remake(prob; p = cache.y₀.u[1][(length_u + 1):end])
495+
foreach(x -> resize!(x, length_u), cache.y₀.u)
496496
resize!(cache.fᵢ₂_cache, length_u)
497497
end
498498

499-
u = shrink_y([reshape(y, length_u) for y in cache.y₀], length(cache.mesh), cache.stage)
499+
u = shrink_y([reshape(y, length_u) for y in cache.y₀.u], length(cache.mesh), cache.stage)
500500

501501
interpolation = __build_interpolation(cache, u)
502502

@@ -530,14 +530,14 @@ function SciMLBase.solve!(
530530
if tune_parameters && SciMLStructures.isscimlstructure(prob.p)
531531
tunable_part, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), prob.p)
532532
length_u = cache.M - length(tunable_part)
533-
new_p = repack(first(cache.y₀)[(length_u + 1):end])
533+
new_p = repack(cache.y₀.u[1][(length_u + 1):end])
534534
prob = remake(prob; p = new_p)
535-
map(x -> resize!(x, length_u), cache.y₀)
535+
foreach(x -> resize!(x, length_u), cache.y₀.u)
536536
resize!(cache.fᵢ₂_cache, length_u)
537537
elseif tune_parameters
538538
length_u = cache.M - length(prob.p)
539-
prob = remake(prob; p = first(cache.y₀)[(length_u + 1):end])
540-
map(x -> resize!(x, length_u), cache.y₀)
539+
prob = remake(prob; p = cache.y₀.u[1][(length_u + 1):end])
540+
foreach(x -> resize!(x, length_u), cache.y₀.u)
541541
resize!(cache.fᵢ₂_cache, length_u)
542542
end
543543

lib/BoundaryValueDiffEqFIRK/src/interpolation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ end
9898

9999
j = interval(mesh, t)
100100
h = mesh_dt[j]
101-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1)
101+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1)
102102
if lf > 1
103103
h *= lf
104104
end
@@ -145,7 +145,7 @@ end
145145

146146
j = interval(mesh, t)
147147
h = mesh_dt[j]
148-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1)
148+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1)
149149
if lf > 1
150150
h *= lf
151151
end
@@ -239,7 +239,7 @@ end
239239
) where {iip}
240240
j = interval(mesh, t)
241241
h = mesh_dt[j]
242-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1)
242+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1)
243243
if lf > 1
244244
h *= lf
245245
end
@@ -284,7 +284,7 @@ end
284284
) where {iip}
285285
j = interval(mesh, t)
286286
h = mesh_dt[j]
287-
lf = (length(cache.y₀) - 1) / (length(cache.y) - 1)
287+
lf = (length(cache.y₀.u) - 1) / (length(cache.y) - 1)
288288
if lf > 1
289289
h *= lf
290290
end

lib/BoundaryValueDiffEqFIRK/test/expanded/ensemble_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
residual[2] = u(1.0)[1]
1212
end
1313

14-
prob_func(prob, i, repeat) = remake(prob, p = [rand()])
14+
prob_func(prob, ctx) = remake(prob, p = [rand()])
1515

1616
u0 = [0.0, 1.0]
1717
tspan = (0, pi / 2)

lib/BoundaryValueDiffEqFIRK/test/nested/ensemble_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
residual[2] = u(1.0)[1]
1212
end
1313

14-
prob_func(prob, i, repeat) = remake(prob, p = [rand()])
14+
prob_func(prob, ctx) = remake(prob, p = [rand()])
1515

1616
u0 = [0.0, 1.0]
1717
tspan = (0, pi / 2)

0 commit comments

Comments
 (0)