From c9ddb0d08e70ca83763d0ccecc5fa885bd02315a Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 14:52:12 -0400 Subject: [PATCH 1/7] resolve method ambiguity --- src/derivative_utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index 6bfef84229..2107af3c6e 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -355,7 +355,7 @@ function Base.convert(::Type{Number}, W::WOperator) end return W._concrete_form end -Base.size(W::WOperator, args...) = size(W.J, args...) +Base.size(W::WOperator, d::Integer) = d <= 2 ? size(W.J)[d] : 1 function Base.getindex(W::WOperator, i::Int) if W.transform -W.mass_matrix[i] / W.gamma + W.J[i] From 1d6ab83202178ada5473d4be189df75e0ed12a99 Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 15:10:21 -0400 Subject: [PATCH 2/7] fix --- src/derivative_utils.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index 2107af3c6e..d5dafd5347 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -355,6 +355,7 @@ function Base.convert(::Type{Number}, W::WOperator) end return W._concrete_form end +Base.size(W::WOperator) = size(W.J) Base.size(W::WOperator, d::Integer) = d <= 2 ? size(W.J)[d] : 1 function Base.getindex(W::WOperator, i::Int) if W.transform From edcae7cc81e1a31243dcec5feb2ebca2e222a98d Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 15:11:02 -0400 Subject: [PATCH 3/7] fix --- src/derivative_utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index d5dafd5347..7288dbc6dc 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -356,7 +356,7 @@ function Base.convert(::Type{Number}, W::WOperator) return W._concrete_form end Base.size(W::WOperator) = size(W.J) -Base.size(W::WOperator, d::Integer) = d <= 2 ? size(W.J)[d] : 1 +Base.size(W::WOperator, d::Integer) = d <= 2 ? size(W)[d] : 1 function Base.getindex(W::WOperator, i::Int) if W.transform -W.mass_matrix[i] / W.gamma + W.J[i] From 188133d59e2e6ee285642d57397621c6d6b6023d Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 15:44:43 -0400 Subject: [PATCH 4/7] weird ambiguity --- src/derivative_utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index 7288dbc6dc..ac99befdec 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -16,7 +16,7 @@ struct StaticWOperator{isinv, T} end end isinv(W::StaticWOperator{S}) where {S} = S -Base.:\(W::StaticWOperator, v) = isinv(W) ? W.W * v : W.W \ v +Base.:\(W::StaticWOperator, v::AbstractArray) = isinv(W) ? W.W * v : W.W \ v function calc_tderivative!(integrator, cache, dtd1, repeat_step) @inbounds begin From 69cb21aeae438ccaef5d762eae9785f2a7004e19 Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 16:03:18 -0400 Subject: [PATCH 5/7] ambig with scimlops --- src/derivative_utils.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index ac99befdec..1040b9488f 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -371,7 +371,14 @@ function Base.getindex(W::WOperator, I::Vararg{Int, N}) where {N} -W.mass_matrix[I...] + W.gamma * W.J[I...] end end -function Base.:*(W::WOperator, x::Union{AbstractVecOrMat, Number}) +function Base.:*(W::WOperator, x::AbstractVecOrMat) + if W.transform + (W.mass_matrix * x) / -W.gamma + W.J * x + else + -W.mass_matrix * x + W.gamma * (W.J * x) + end +end +function Base.:*(W::WOperator, x::Number) if W.transform (W.mass_matrix * x) / -W.gamma + W.J * x else From 26edd9f21aa9dcfca91530bc66bba588ddba58f7 Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 16:29:06 -0400 Subject: [PATCH 6/7] comments --- src/derivative_utils.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index 1040b9488f..09565e940f 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -835,6 +835,9 @@ end function build_J_W(alg, u, uprev, p, t, dt, f::F, ::Type{uEltypeNoUnits}, ::Val{IIP}) where {IIP, uEltypeNoUnits, F} + # TODO - make J, W AbstractSciMLOperators + # TODO - if jvp given, make it SciMLOperators.FunctionOperator + # TODO - make mass matrix a SciMLOperator so it can be updated with time. Default to IdentityOperator islin, isode = islinearfunction(f, alg) if f.jac_prototype isa DiffEqBase.AbstractDiffEqLinearOperator W = WOperator{IIP}(f, u, dt) From 576f5b1366a94b10ddd7cef495ccc7e6e20227a5 Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 21 Sep 2022 16:30:42 -0400 Subject: [PATCH 7/7] comment --- src/derivative_utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/derivative_utils.jl b/src/derivative_utils.jl index 09565e940f..04a633198b 100644 --- a/src/derivative_utils.jl +++ b/src/derivative_utils.jl @@ -835,7 +835,7 @@ end function build_J_W(alg, u, uprev, p, t, dt, f::F, ::Type{uEltypeNoUnits}, ::Val{IIP}) where {IIP, uEltypeNoUnits, F} - # TODO - make J, W AbstractSciMLOperators + # TODO - make J, W AbstractSciMLOperators (lazily defined with scimlops functionality) # TODO - if jvp given, make it SciMLOperators.FunctionOperator # TODO - make mass matrix a SciMLOperator so it can be updated with time. Default to IdentityOperator islin, isode = islinearfunction(f, alg)