Skip to content

Commit aeafc10

Browse files
committed
try this
1 parent 81559b2 commit aeafc10

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

lib/OrdinaryDiffEqDifferentiation/src/derivative_utils.jl

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function Base.convert(::Type{AbstractMatrix}, W::WOperator{IIP}) where {IIP}
335335
else
336336
# Non-allocating already updated
337337
#_W = W._concrete_form
338-
#jacobian2W!(_W, W.mass_matrix, W.gamma, convert(AbstractMatrix, W.J), W.transform)
338+
#jacobian2W!(_W, W.mass_matrix, W.gamma, W.J, W.transform)
339339
end
340340
return W._concrete_form
341341
end
@@ -392,10 +392,6 @@ function Base.:\(W::WOperator, x::Number)
392392
end
393393
end
394394

395-
function LinearSolve.defaultalg(W::WOperator, b, assump::OperatorAssumptions{Bool})
396-
LinearSolve.defaultalg(W.J, b, assump)
397-
end
398-
399395
function LinearAlgebra.mul!(Y::AbstractVecOrMat, W::WOperator, B::AbstractVecOrMat)
400396
if W.transform
401397
# Compute mass_matrix * B
@@ -455,11 +451,7 @@ function do_newJW(integrator, alg, nlsolver, repeat_step)::NTuple{2, Bool}
455451
integrator.iter <= 1 && return true, true # at least one JW eval at the start
456452
repeat_step && return false, false
457453
islin, _ = islinearfunction(integrator)
458-
if islin
459-
# no further J eval when it's linear
460-
# W eval needed if not adaptive
461-
return false, !integrator.opts.adaptive
462-
end
454+
islin && return false, false # no further JW eval when it's linear
463455
!integrator.opts.adaptive && return true, true # Not adaptive will always refactorize
464456
errorfail = integrator.EEst > one(integrator.EEst)
465457
if alg isa DAEAlgorithm
@@ -708,22 +700,12 @@ function calc_W!(W, integrator, nlsolver::Union{Nothing, AbstractNLSolver}, cach
708700
else
709701
update_coefficients!(W, uprev, p, t; transform = W_transform, dtgamma)
710702
end
711-
if W.J !== nothing && (W.J isa MatrixOperator || !(W.J isa AbstractSciMLOperator))
703+
if W.J !== nothing && !(W.J isa AbstractSciMLOperator)
712704
islin, isode = islinearfunction(integrator)
713-
if islin
714-
J = isode ? f.f : f.f1.f
715-
elseif new_jac
716-
calc_J!(W.J, integrator, lcache, next_step)
717-
end
718-
if W.J isa MatrixOperator
719-
J = J.A
720-
end
721-
if mass_matrix isa MatrixOperator
722-
mass_matrix = mass_matrix.A
723-
end
724-
if new_W && !isdae
705+
islin ? (J = isode ? f.f : f.f1.f) :
706+
(new_jac && (calc_J!(W.J, integrator, lcache, next_step)))
707+
new_W && !isdae &&
725708
jacobian2W!(W._concrete_form, mass_matrix, dtgamma, J, W_transform)
726-
end
727709
end
728710
elseif W isa AbstractSciMLOperator && !(W isa StaticWOperator)
729711
update_coefficients!(W, uprev, p, t; transform = W_transform, dtgamma)
@@ -929,7 +911,6 @@ function build_J_W(alg, u, uprev, p, t, dt, f::F, ::Type{uEltypeNoUnits},
929911
else
930912
deepcopy(f.jac_prototype)
931913
end
932-
933914
W = if alg isa DAEAlgorithm
934915
J
935916
elseif IIP

test/interface/utility_tests.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ end
6060
jac_prototype = MatrixOperator(similar(A);
6161
update_func! = (J, u, p, t) -> J .= t .*
6262
A))
63-
64-
for Alg in [ImplicitEuler, Rosenbrock23, Rodas5]
65-
println(Alg)
63+
@testset "$Alg" for Alg in [ImplicitEuler, Rosenbrock23, Rodas5]
6664
sol1 = solve(ODEProblem(fun1, u0, tspan), Alg(); adaptive = false, dt = 0.01)
6765
sol2 = solve(ODEProblem(fun2, u0, tspan), Alg(); adaptive = false, dt = 0.01)
6866
@test sol1(1.0)sol2(1.0) atol=1e-3

0 commit comments

Comments
 (0)