Skip to content

Commit

Permalink
Added donorview and haloview functions
Browse files Browse the repository at this point in the history
  • Loading branch information
smillerc committed Sep 27, 2022
1 parent 811137b commit cb3c1a6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockHaloArrays"
uuid = "8029ca6b-11ad-4a59-88a2-2e6eee4ef8a2"
authors = ["Sam Miller <[email protected]> and contributors"]
version = "0.3.0"
version = "0.3.1"

[deps]
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
Expand Down
7 changes: 7 additions & 0 deletions src/BlockHaloArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export flatten, repartition!, updatehalo!, updateblockhalo!
export globalindices, nblocks
export domainview
export onboundary
export donorview, haloview

abstract type AbstractBlockHaloArray end

Expand Down Expand Up @@ -309,4 +310,10 @@ function domainview(A::BlockHaloArray, blockid::Integer)
return @views A.blocks[blockid][.., Tuple(idx_range_vec)...]
end

"""Get the halo region at a particular location, e.g. `:ilo` for block `blockid`"""
haloview(A::BlockHaloArray, blockid::Integer, location::Symbol) = A._halo_views[blockid][location]

"""Get the domain donor region at a particular location, e.g. `:ilo` for block `blockid`"""
donorview(A::BlockHaloArray, blockid::Integer, location::Symbol) = A._donor_views[blockid][location]

end # module
30 changes: 30 additions & 0 deletions test/unit/test_util_funcs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@testitem "halo/donorview" begin
include("common.jl")
dims = (50, 50)
nhalo = 2
nblocks = 4
A = BlockHaloArray(dims, nhalo, nblocks)

@test size(donorview(A, 1, :ilo)) == (2, 25)
@test size(haloview(A, 1, :ilo)) == (2, 25)
@test size(donorview(A, 1, :jhi)) == (25, 2)
@test size(haloview(A, 1, :jhi)) == (25, 2)
end

@testitem "nblocks" begin
include("common.jl")
A = BlockHaloArray((50,50), 2, 4)
@test nblocks(A) == 4
end

@testitem "eltype" begin
include("common.jl")
A = BlockHaloArray((50,50), 2, 4, T=Int32)
@test eltype(A) == Int32
end

@testitem "size" begin
include("common.jl")
A = BlockHaloArray((50,50), 2, 4, T=Int32)
@test size(A) == (50, 50)
end

2 comments on commit cb3c1a6

@smillerc
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/69053

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.3.1 -m "<description of version>" cb3c1a6b88a8228e700621643a3b0da74cd4b329
git push origin v0.3.1

Please sign in to comment.