DiffEqOperators.jl icon indicating copy to clipboard operation
DiffEqOperators.jl copied to clipboard

Cannot create BandedMatrix from GhostDerivativeOperator

Open bclyons12 opened this issue 4 years ago • 1 comments

Trying to concretize a GhostDerivativeOperator as a BandedMatrix is throwing an error for me:

using DiffEqOperators
using SparseArrays
using BandedMatrices
Δ = CenteredDifference(2, 2, 0.1, 7);
bc = Neumann0BC(0.1, 1);
#this works
display(sparse(Δ*bc))
#this fails
BandedMatrix(Δ*bc)

Output:

(
 -100.0   100.0      ⋅       ⋅       ⋅       ⋅       ⋅ 
  100.0  -200.0   100.0      ⋅       ⋅       ⋅       ⋅ 
     ⋅    100.0  -200.0   100.0      ⋅       ⋅       ⋅ 
     ⋅       ⋅    100.0  -200.0   100.0      ⋅       ⋅ 
     ⋅       ⋅       ⋅    100.0  -200.0   100.0      ⋅ 
     ⋅       ⋅       ⋅       ⋅    100.0  -200.0   100.0
     ⋅       ⋅       ⋅       ⋅       ⋅    100.0  -100.0, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
ERROR: LoadError: MethodError: no method matching inbands_setindex!(::BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}, ::Vector{Float64}, ::Int64, ::UnitRange{Int64})
Closest candidates are:
  inbands_setindex!(::BandedMatrix, ::Any, ::Integer, ::Integer) at /Users/Lyons/.julia/packages/BandedMatrices/Gbqeq/src/banded/BandedMatrix.jl:443
  inbands_setindex!(::AbstractArray, ::Any, ::Integer, ::Integer) at /Users/Lyons/.julia/packages/BandedMatrices/Gbqeq/src/generic/indexing.jl:7
  inbands_setindex!(::LinearAlgebra.Adjoint, ::Any, ::Integer, ::Integer) at /Users/Lyons/.julia/packages/BandedMatrices/Gbqeq/src/generic/indexing.jl:16
  ...
Stacktrace:
 [1] BandedMatrix(Q::RobinBC{Float64, Vector{Float64}}, N::Int64)
   @ DiffEqOperators ~/.julia/packages/DiffEqOperators/DMNmH/src/derivative_operators/concretization.jl:126
 [2] BandedMatrix(A::GhostDerivativeOperator{Float64, DerivativeOperator{Float64, 1, false, Float64, StaticArrays.SVector{3, Float64}, StaticArrays.SVector{0, StaticArrays.SVector{4, Float64}}, StaticArrays.SVector{0, StaticArrays.SVector{4, Float64}}, Nothing, Nothing}, RobinBC{Float64, Vector{Float64}}}, N::Int64) (repeats 2 times)
   @ DiffEqOperators ~/.julia/packages/DiffEqOperators/DMNmH/src/derivative_operators/concretization.jl:718

bclyons12 avatar May 13 '21 18:05 bclyons12

Seems related to #182 and #185

bclyons12 avatar May 13 '21 19:05 bclyons12

This appears fixed with https://github.com/SciML/DiffEqOperators.jl/pull/432

bclyons12 avatar Sep 29 '22 22:09 bclyons12