Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-adaptive interpolation #200

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading