Skip to content

Commit 6cc12b8

Browse files
committed
Use update_eval_sol to update eval sol
1 parent 99d2453 commit 6cc12b8

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

lib/BoundaryValueDiffEqMIRK/src/interpolation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ always update the intermediate solution with discrete solution + discrete stages
377377
(Continuous MIRK: u(meshᵢ + τ*dt) = yᵢ + dt sum br(τ)*kr).
378378
"""
379379
@views function update_eval_sol!(eval_sol::EvalSol, y_, cache::MIRKCache)
380-
eval_sol.u[1:end] .= __restructure_sol(y_, cache.in_size)
381-
eval_sol.cache.k_discrete[1:end] .= cache.k_discrete
382-
eval_sol.cache.k_interp.u[1:end] .= cache.k_interp.u
380+
copyto!(eval_sol.u, __restructure_sol(y_, cache.in_size))
381+
copyto!(eval_sol.cache.k_discrete, cache.k_discrete)
382+
copyto!(eval_sol.cache.k_interp.u, cache.k_interp.u)
383383
interp_setup!(eval_sol.cache)
384384
return nothing
385385
end

test/misc/allocation_tests.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testitem "MIRK Loss Function Allocations" tags=[:allocs] begin
1+
@testitem "MIRK Loss Function Allocations" tags = [:allocs] begin
22
using BoundaryValueDiffEq, BoundaryValueDiffEqMIRK, BoundaryValueDiffEqCore, LinearAlgebra
33

44
function f!(du, u, p, t)
@@ -28,17 +28,21 @@
2828

2929
bvp = BVProblem(BVPFunction{true}(f!, bc!; bcresid_prototype = zeros(2)), u0, tspan)
3030
tpbvp = BVProblem(
31-
BVPFunction{true}(f!, (tpbc_a!, tpbc_b!);
32-
bcresid_prototype = (zeros(1), zeros(1)), twopoint = Val(true)),
33-
u0, tspan)
31+
BVPFunction{true}(
32+
f!, (tpbc_a!, tpbc_b!);
33+
bcresid_prototype = (zeros(1), zeros(1)), twopoint = Val(true)
34+
),
35+
u0, tspan
36+
)
3437

3538
# Test that the loss function allocations scale sub-linearly with mesh size
3639
# (i.e., per-step allocations are bounded, not proportional to mesh points)
3740
for (name, prob) in [("StandardBVP", bvp), ("TwoPointBVP", tpbvp)]
3841
for alg in [MIRK4(), MIRK5(), MIRK6()]
3942
cache = SciMLBase.__init(prob, alg; dt = 0.1, adaptive = false)
4043
nlprob = BoundaryValueDiffEqMIRK.__construct_problem(
41-
cache, vec(cache.y₀), copy(cache.y₀))
44+
cache, vec(cache.y₀), copy(cache.y₀)
45+
)
4246

4347
u_test = copy(nlprob.u0)
4448
resid_test = zeros(length(nlprob.u0))

test/qa/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ using BoundaryValueDiffEq, BoundaryValueDiffEqMIRK, BoundaryValueDiffEqCore,
3131
u0 = [1.0, 0.0]
3232
tspan = (0.0, 1.0)
3333
bvp = BVProblem(
34-
BVPFunction{true}(_f!, _bc!; bcresid_prototype = zeros(2)), u0, tspan)
34+
BVPFunction{true}(_f!, _bc!; bcresid_prototype = zeros(2)), u0, tspan
35+
)
3536

3637
cache = SciMLBase.__init(bvp, MIRK4(); dt = 0.1, adaptive = false)
3738
nlprob = BoundaryValueDiffEqMIRK.__construct_problem(
38-
cache, vec(cache.y₀), copy(cache.y₀))
39+
cache, vec(cache.y₀), copy(cache.y₀)
40+
)
3941

4042
u_test = copy(nlprob.u0)
4143
resid_test = zeros(length(nlprob.u0))

0 commit comments

Comments
 (0)