Skip to content

Commit

Permalink
Merge pull request #200 from ErikQQY/qqy/nonadaptive_interpolation
Browse files Browse the repository at this point in the history
Fix non-adaptive interpolation
  • Loading branch information
ChrisRackauckas authored Jul 26, 2024
2 parents d9bc98d + 3f31f89 commit 6693e3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BoundaryValueDiffEq"
uuid = "764a87c0-6b3e-53db-9096-fe964310641d"
version = "5.9.0"
version = "5.9.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
5 changes: 2 additions & 3 deletions src/solve/mirk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ function SciMLBase.__init(prob::BVProblem, alg::AbstractMIRK; dt = 0.0,

k_discrete = [__maybe_allocate_diffcache(similar(X, N, stage), chunksize, alg.jac_alg)
for _ in 1:Nig]
k_interp = [similar(X, ifelse(adaptive, N, 0), ifelse(adaptive, ITU.s_star - stage, 0))
for _ in 1:Nig]
k_interp = [similar(X, N, ITU.s_star - stage) for _ in 1:Nig]

bcresid_prototype, resid₁_size = __get_bcresid_prototype(prob.problem_type, prob, X)

Expand All @@ -72,7 +71,7 @@ function SciMLBase.__init(prob::BVProblem, alg::AbstractMIRK; dt = 0.0,
end

defect = [similar(X, ifelse(adaptive, N, 0)) for _ in 1:Nig]
new_stages = [similar(X, ifelse(adaptive, N, 0)) for _ in 1:Nig]
new_stages = [similar(X, N) for _ in 1:Nig]

# Transform the functions to handle non-vector inputs
bcresid_prototype = __vec(bcresid_prototype)
Expand Down
10 changes: 9 additions & 1 deletion test/mirk/mirk_basic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,21 @@ end
@eval mirk_solver(::Val{$order}) = $(s)()
end

@testset "MIRK$order" for order in (2, 3, 4, 5, 6)
@testset "Interpolation for adaptive MIRK$order" for order in (2, 3, 4, 5, 6)
sol = solve(prob_bvp_linear, mirk_solver(Val(order)); dt = 0.001)
@test sol(0.001)[0.998687464, -1.312035941] atol=testTol
@test sol(0.001; idxs = [1, 2])[0.998687464, -1.312035941] atol=testTol
@test sol(0.001; idxs = 1)0.998687464 atol=testTol
@test sol(0.001; idxs = 2)-1.312035941 atol=testTol
end

@testset "Interpolation for non-adaptive MIRK$order" for order in (2, 3, 4, 5, 6)
sol = solve(prob_bvp_linear, mirk_solver(Val(order)); dt = 0.001, adaptive=false)
@test_nowarn sol(0.01)
@test_nowarn sol(0.01; idxs = [1, 2])
@test_nowarn sol(0.01; idxs = 1)
@test_nowarn sol(0.01; idxs = 2)
end
end

@testitem "Swirling Flow III" begin
Expand Down

0 comments on commit 6693e3a

Please sign in to comment.