Currently, assemble! assumes, that Ke is a Matrix. In some situations, the user might want to assemble single values into the matrix. This could look something like this:
function assemble!(a::Ferrite.Assembler{T}, rowdofs::Int, coldofs::Int, Ke::T) where {T}
push!(a.V, Ke)
push!(a.I, rowdofs)
push!(a.J, coldofs)
end
Furthermore, in the Project I'm currently working on, I know that my element matrices have a predictable pattern of zero entries (Because the entry for each node is essentially a diagonal Matrix, I would end up with 2/3 structual zeros in the final assembled Matrix). It might be worthwhile to include a keword argument dropzeros that automatically removes these zero entries:
function assemble!(a::Ferrite.Assembler{T}, rowdofs::AbstractVector{Int}, coldofs::AbstractVector{Int}, Ke::AbstractMatrix{T}; dropzeros::Bool=false) where {T}
@assert(size(Ke,1) == length(rowdofs))
@assert(size(Ke,2) == length(coldofs))
for I in CartesianIndices(Ke)
dropzeros && Ke[I] == 0 && continue
(i,j) = Tuple(I)
push!(a.V, Ke[I])
push!(a.I, rowdofs[i])
push!(a.J, coldofs[j])
end
end
This way, I wouldn't have to call dropzeros on the assembled matrix, which would probably be slightly faster and would allocate less memory during assembly.
If this is something worth including, I can get to work implementing this and creating a pull request. However, this would be my first time contributing to a project and I'd first have to figure out how that acctually works 😅
Currently, assemble! assumes, that
Keis a Matrix. In some situations, the user might want to assemble single values into the matrix. This could look something like this:Furthermore, in the Project I'm currently working on, I know that my element matrices have a predictable pattern of zero entries (Because the entry for each node is essentially a diagonal Matrix, I would end up with 2/3 structual zeros in the final assembled Matrix). It might be worthwhile to include a keword argument
dropzerosthat automatically removes these zero entries:This way, I wouldn't have to call dropzeros on the assembled matrix, which would probably be slightly faster and would allocate less memory during assembly.
If this is something worth including, I can get to work implementing this and creating a pull request. However, this would be my first time contributing to a project and I'd first have to figure out how that acctually works 😅