Skip to content

Commit

Permalink
Modify arguments for create_sparse_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
KeitaNakamura committed Aug 6, 2024
1 parent 257d73b commit b54fd7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/literate/examples/dam_break.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ function main(transfer::Transfer = FLIP(1.0))
update!(mp, xc, grid.X)
end

## BlockSpace for threaded computation
## BlockSpace for multithreading
blockspace = BlockSpace(grid.X)

## Sparse matrix
A = create_sparse_matrix(Vec{3}, it, grid.X)
A = create_sparse_matrix(it, grid.X; ndofs=3)

## Output
outdir = mkpath(joinpath("output", "dam_break"))
Expand Down
2 changes: 1 addition & 1 deletion docs/literate/examples/implicit_jacobian_based.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function main()
end

## Sparse matrix
A = create_sparse_matrix(Vec{3}, it, grid.X)
A = create_sparse_matrix(it, grid.X)

## Outputs
outdir = mkpath(joinpath("output", "implicit_jacobian_based"))
Expand Down
12 changes: 6 additions & 6 deletions src/implicit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ function (dofmap::DofMap{dim, N})(A::AbstractArray{T, dim}) where {dim, N, T <:
@inbounds view(A′, indices′)
end

function create_sparse_matrix(::Type{Vec{dim}}, it::Interpolation, mesh::AbstractMesh) where {dim}
create_sparse_matrix(Vec{dim, Float64}, it, mesh)
function create_sparse_matrix(it::Interpolation, mesh::AbstractMesh{dim}; ndofs::Int = dim) where {dim}
create_sparse_matrix(Float64, it, mesh; ndofs)
end
function create_sparse_matrix(::Type{Vec{dim, T}}, it::Interpolation, mesh::CartesianMesh) where {dim, T}
function create_sparse_matrix(::Type{T}, it::Interpolation, mesh::CartesianMesh{dim}; ndofs::Int = dim) where {T, dim}
dims = size(mesh)
spy = falses(dim, prod(dims), dim, prod(dims))
spy = falses(ndofs, prod(dims), ndofs, prod(dims))
LI = LinearIndices(dims)
mesh = CartesianMesh(float(T), 1, map(d->(0,d-1), dims)...)
for i in eachindex(mesh)
unit = gridspan(it) * oneunit(i)
indices = intersect((i-unit):(i+unit), eachindex(mesh))
for j in indices
spy[1:dim, LI[i], 1:dim, LI[j]] .= true
spy[1:ndofs, LI[i], 1:ndofs, LI[j]] .= true
end
end
create_sparse_matrix(T, reshape(spy, dim*prod(dims), dim*prod(dims)))
create_sparse_matrix(T, reshape(spy, ndofs*prod(dims), ndofs*prod(dims)))
end

function create_sparse_matrix(::Type{T}, spy::AbstractMatrix{Bool}) where {T}
Expand Down

0 comments on commit b54fd7b

Please sign in to comment.