Skip to content

Commit

Permalink
Fix dofmap for 1D problem
Browse files Browse the repository at this point in the history
  • Loading branch information
KeitaNakamura committed Sep 21, 2024
1 parent 6145b75 commit 788b3b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tesserae"
uuid = "fd374396-9d9c-4d88-9aa5-37a7f6105aca"
authors = ["Keita Nakamura <keita.nakamura.1109@gmail.com>"]
version = "0.1.12"
version = "0.1.13"

[deps]
PoissonDiskSampling = "d57be0ce-7c7e-4f32-9a47-3bfb603400bb"
Expand Down
14 changes: 12 additions & 2 deletions src/implicit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,32 @@ struct DofMap{dim, N, I <: AbstractVector{CartesianIndex{N}}}
dimension::Int
gridsize::Dims{dim}
indices::I # (direction, x, y, z)
function DofMap{dim, N, I}(dimension::Int, gridsize::Dims{dim}, indices::I) where {dim, N, I <: AbstractVector{CartesianIndex{N}}}
@assert dim+1 == N
new{dim, N, I}(dimension, gridsize, indices)
end
end
function DofMap(dimension::Int, gridsize::Dims{dim}, indices::I) where {dim, N, I <: AbstractVector{CartesianIndex{N}}}
DofMap{dim, N, I}(dimension, gridsize, indices)
end

DofMap(mask::AbstractArray{Bool}) = DofMap(size(mask, 1), Base.tail(size(mask)), findall(mask))
DofMap(dims::Dims) = DofMap(dims[1], Base.tail(dims), vec(CartesianIndices(dims)))

ndofs(dofmap::DofMap) = length(dofmap.indices)

function (dofmap::DofMap{1, 2})(A::AbstractArray{T, 1}) where {T <: Vec}
A′ = reshape(reinterpret(eltype(T), A), 1, length(A))
@boundscheck checkbounds(A′, dofmap.indices)
@inbounds view(A′, dofmap.indices)
end
function (dofmap::DofMap{dim, N})(A::AbstractArray{T, dim}) where {dim, N, T <: Vec}
@assert dim+1 == N
A′ = reinterpret(reshape, eltype(T), A)
@boundscheck checkbounds(A′, dofmap.indices)
@inbounds view(A′, dofmap.indices)
end

function (dofmap::DofMap{dim, N})(A::AbstractArray{T, dim}) where {dim, N, T <: Real}
@assert dim+1 == N
A′ = reshape(A, 1, size(A)...)
indices′ = maparray(I->CartesianIndex(1,Base.tail(Tuple(I))...), dofmap.indices)
@boundscheck checkbounds(A′, indices′)
Expand Down

2 comments on commit 788b3b6

@KeitaNakamura
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/115619

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.13 -m "<description of version>" 788b3b6723b0800ee25584684da524c93a0b5107
git push origin v0.1.13

Please sign in to comment.