Ferrite-FEM / Ferrite-FEM/Ferrite.jl

allocating symmetric csr fails

Open
#1,311 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Julia
Stars
453
Forks
115
Avg merge
1d 17h
Merged PRs (30d)
11

Description

Discovered in #1302 that the following doesn't work (Symmetric of non `SparseMatrixCSC` matrices)
```julia
using Ferrite
using LinearAlgebra, SparseMatricesCSR, SparseArrays

CT = Triangle
RS = getrefshape(CT)
dim = Ferrite.getrefdim(RS)
grid = generate_grid(CT, ntuple(_ -> 5, dim))
dh = DofHandler(grid)
add!(dh, :a, Lagrange{RS, 1}())
add!(dh, :b, Lagrange{RS, 2}()^dim)
return close!(dh)

allocate_matrix(Symmetric{Float64, SparseMatrixCSC{Float64, Int}}, dh); # Works

allocate_matrix(Symmetric{Float64, SparseMatrixCSR{1,Float64,Int}}, dh) # Fails:

ERROR: MethodError: no method matching allocate_matrix(::Type{Symmetric{Float64, SparseMatrixCSR{1, Float64, Int64}}}, ::SparsityPattern)
The function `allocate_matrix` exists, but no method is defined for this combination of argument types.
```

Should be easily fixable by changing
https://github.com/Ferrite-FEM/Ferrite.jl/blob/9134b54f48b7d6bf118d577fc3acc82da3445714/src/Dofs/sparsity_pattern.jl#L357-L366

To dispatch as
```julia
allocate_matrix(::Type{Symmetric{Tv, S}}, sp::AbstractSparsityPattern) where {Tv, Ti, S <: AbstractSparseMatrix{Tv, Ti}}
```

But this is not related to #1302 and could have other side-effects and changes the user-facing API, so leaving this out of that.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.