Skip to content

Commit

Permalink
Merge pull request #166 from fverdugo/release0.5.3
Browse files Browse the repository at this point in the history
Release 0.5.3
  • Loading branch information
fverdugo authored Aug 16, 2024
2 parents b39eac0 + 9a0806e commit 11ded45
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 20 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.3] - 2024-08-16

### Fixed
- Typo: `node_coorinates_unit_cube` -> `node_coordinates_unit_cube`.
- Bug in `nullspace_linear_elasticity`.
- Bug in `PVector` when working in split format.

### Deprecated

- `near_nullspace_linear_elasticity` in favor of `nullspace_linear_elasticity`.

## [0.5.2] - 2024-08-13

### Added
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PartitionedArrays"
uuid = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
authors = ["Francesc Verdugo <f.verdugo.rojano@vu.nl> and contributors"]
version = "0.5.2"
version = "0.5.3"

[deps]
CircularArrays = "7a955b69-7140-5f4e-a0ed-f168c5e2e749"
Expand Down
4 changes: 3 additions & 1 deletion src/PartitionedArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ include("p_timer.jl")
export laplacian_fdm
export laplacian_fem
export linear_elasticity_fem
export node_coorinates_unit_cube
export node_coordinates_unit_cube
export nullspace_linear_elasticity
export nullspace_linear_elasticity!
export near_nullspace_linear_elasticity
include("gallery.jl")

Expand Down
15 changes: 10 additions & 5 deletions src/gallery.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ function node_to_dof_partition(node_partition,D)
dof_partition
end

function node_coorinates_unit_cube(
function node_coordinates_unit_cube(
nodes_per_dir, # free (== interior) nodes
parts_per_dir,
parts,
;
split_format = Val(true),
split_format = Val(false),
value_type::Type{Tv} = Float64,) where Tv

function setup!(own_x,mynodes)
Expand All @@ -443,7 +443,12 @@ function node_coorinates_unit_cube(
x
end

function near_nullspace_linear_elasticity(x,
function near_nullspace_linear_elasticity(a...;b...)
@warn "near_nullspace_linear_elasticity is deprecated, use nullspace_linear_elasticity instead"
nullspace_linear_elasticity(a...;b...)
end

function nullspace_linear_elasticity(x,
row_partition = node_to_dof_partition(partition(axes(x,1)),length(eltype(x)))
)
T = eltype(x)
Expand All @@ -461,10 +466,10 @@ function near_nullspace_linear_elasticity(x,
dof_partition = row_partition
split_format = Val(eltype(partition(x)) <: SplitVector)
B = [ pzeros(Tv,dof_partition;split_format) for _ in 1:nb ]
near_nullspace_linear_elasticity!(B,x)
nullspace_linear_elasticity!(B,x)
end

function near_nullspace_linear_elasticity!(B,x)
function nullspace_linear_elasticity!(B,x)
D = length(eltype(x))
if D == 1
foreach(own_values(B[1])) do own_b
Expand Down
33 changes: 25 additions & 8 deletions src/p_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ struct SplitVectorAssemblyCache{A,B,C,D}
buffer_snd::C # NB
buffer_rcv::C
exchange_setup::D
reversed::Bool
end
function Base.reverse(a::SplitVectorAssemblyCache)
SplitVectorAssemblyCache(
Expand All @@ -537,6 +538,7 @@ function Base.reverse(a::SplitVectorAssemblyCache)
a.buffer_rcv,
a.buffer_snd,
a.exchange_setup,
!(a.reversed),
)
end
function copy_cache(a::SplitVectorAssemblyCache)
Expand All @@ -549,23 +551,29 @@ function copy_cache(a::SplitVectorAssemblyCache)
a.own_indices_rcv,
buffer_snd,
buffer_rcv,
a.exchange_setup
a.exchange_setup,
a.reversed,
)
end

function p_vector_cache_impl(::Type{<:SplitVector},vector_partition,index_partition)
neighbors_snd,neighbors_rcv= assembly_neighbors(index_partition)
indices_snd,indices_rcv = assembly_local_indices(index_partition,neighbors_snd,neighbors_rcv)
map(indices_snd,indices_rcv,index_partition) do ids_snd,ids_rcv,myids
ghost_indices_snd = map(indices_snd) do ids
JaggedArray(copy(ids.data),ids.ptrs)
end
own_indices_rcv = map(indices_rcv) do ids
JaggedArray(copy(ids.data),ids.ptrs)
end
foreach(ghost_indices_snd,own_indices_rcv,index_partition) do ids_snd,ids_rcv,myids
map_local_to_ghost!(ids_snd.data,myids)
map_local_to_own!(ids_rcv.data,myids)
end
ghost_indices_snd = indices_snd
own_indices_rcv = indices_rcv
buffers_snd,buffers_rcv = map(assembly_buffers,vector_partition,indices_snd,indices_rcv) |> tuple_of_arrays
buffers_snd,buffers_rcv = map(assembly_buffers,vector_partition,ghost_indices_snd,own_indices_rcv) |> tuple_of_arrays
graph = ExchangeGraph(neighbors_snd,neighbors_rcv)
exchange_setup = setup_exchange(buffers_rcv,buffers_snd,graph)
SplitVectorAssemblyCache(neighbors_snd,neighbors_rcv,ghost_indices_snd,own_indices_rcv,buffers_snd,buffers_rcv,exchange_setup)
reversed = false
SplitVectorAssemblyCache(neighbors_snd,neighbors_rcv,ghost_indices_snd,own_indices_rcv,buffers_snd,buffers_rcv,exchange_setup,reversed)
end

function p_vector_cache_impl(::Type{<:SplitVector{<:JaggedArray}},vector_partition,index_partition)
Expand Down Expand Up @@ -610,6 +618,7 @@ function assemble_impl!(f,vector_partition,cache::JaggedArrayAssemblyCache)
end

function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
reversed = cache.reversed
ghost_indices_snd=cache.ghost_indices_snd
own_indices_rcv=cache.own_indices_rcv
neighbors_snd=cache.neighbors_snd
Expand All @@ -618,7 +627,11 @@ function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
buffer_rcv=cache.buffer_rcv
exchange_setup=cache.exchange_setup
foreach(vector_partition,ghost_indices_snd,buffer_snd) do values,ghost_indices_snd,buffer_snd
ghost_vals = values.blocks.ghost
if reversed
ghost_vals = values.blocks.own
else
ghost_vals = values.blocks.ghost
end
for (p,hid) in enumerate(ghost_indices_snd.data)
buffer_snd.data[p] = ghost_vals[hid]
end
Expand All @@ -629,7 +642,11 @@ function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
@fake_async begin
wait(t)
foreach(vector_partition,own_indices_rcv,buffer_rcv) do values,own_indices_rcv,buffer_rcv
own_vals = values.blocks.own
if reversed
own_vals = values.blocks.ghost
else
own_vals = values.blocks.own
end
for (p,oid) in enumerate(own_indices_rcv.data)
own_vals[oid] = f(own_vals[oid],buffer_rcv.data[p])
end
Expand Down
34 changes: 29 additions & 5 deletions test/gallery_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,44 @@ function gallery_tests(distribute,parts_per_dir)
@test isa(y,PVector)
A = psparse(SparseMatrixCSR{1,Float64,Int32},args...) |> fetch
A |> centralize |> display
Y = A*pones(axes(A,2))
y = A*pones(axes(A,2))
@test isa(y,PVector)

args = linear_elasticity_fem(nodes_per_dir,parts_per_dir,ranks)
A = psparse(args...) |> fetch
A |> centralize |> display
Y = A*pones(axes(A,2))
y = A*pones(axes(A,2))
@test isa(y,PVector)

x = node_coorinates_unit_cube(nodes_per_dir,parts_per_dir,ranks)
B = near_nullspace_linear_elasticity(x)
x = node_coordinates_unit_cube(nodes_per_dir,parts_per_dir,ranks)
B = nullspace_linear_elasticity(x)
@test isa(B[1],PVector)
B = near_nullspace_linear_elasticity(x,partition(axes(A,2)))
y = A*pones(axes(A,2))
@test isa(y,PVector)
B = nullspace_linear_elasticity(x,partition(axes(A,2)))
@test isa(B[1],PVector)
y = A*pones(axes(A,2))
@test isa(Y,PVector)
y = A*B[1]
@test isa(y,PVector)
nullspace_linear_elasticity!(B,x)
y = A*B[1]
@test isa(y,PVector)

x = node_coordinates_unit_cube(nodes_per_dir,parts_per_dir,ranks,split_format=true)
B = nullspace_linear_elasticity(x)
@test isa(B[1],PVector)
y = A*pones(axes(A,2))
@test isa(y,PVector)
B = nullspace_linear_elasticity(x,partition(axes(A,2)))
@test isa(B[1],PVector)
y = A*pones(axes(A,2))
@test isa(Y,PVector)
y = A*B[1]
@test isa(y,PVector)
nullspace_linear_elasticity!(B,x)
y = A*B[1]
@test isa(y,PVector)

end

Expand Down

2 comments on commit 11ded45

@fverdugo
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 register()

@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/113239

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.5.3 -m "<description of version>" 11ded45c2a486dee20f63ca69c0b4b767038a7b0
git push origin v0.5.3

Please sign in to comment.