Skip to content

Commit 11ded45

Browse files
authored
Merge pull request #166 from fverdugo/release0.5.3
Release 0.5.3
2 parents b39eac0 + 9a0806e commit 11ded45

File tree

6 files changed

+79
-20
lines changed

6 files changed

+79
-20
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.3] - 2024-08-16
9+
10+
### Fixed
11+
- Typo: `node_coorinates_unit_cube` -> `node_coordinates_unit_cube`.
12+
- Bug in `nullspace_linear_elasticity`.
13+
- Bug in `PVector` when working in split format.
14+
15+
### Deprecated
16+
17+
- `near_nullspace_linear_elasticity` in favor of `nullspace_linear_elasticity`.
18+
819
## [0.5.2] - 2024-08-13
920

1021
### Added

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PartitionedArrays"
22
uuid = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
33
authors = ["Francesc Verdugo <[email protected]> and contributors"]
4-
version = "0.5.2"
4+
version = "0.5.3"
55

66
[deps]
77
CircularArrays = "7a955b69-7140-5f4e-a0ed-f168c5e2e749"

src/PartitionedArrays.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ include("p_timer.jl")
180180
export laplacian_fdm
181181
export laplacian_fem
182182
export linear_elasticity_fem
183-
export node_coorinates_unit_cube
183+
export node_coordinates_unit_cube
184+
export nullspace_linear_elasticity
185+
export nullspace_linear_elasticity!
184186
export near_nullspace_linear_elasticity
185187
include("gallery.jl")
186188

src/gallery.jl

+10-5
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ function node_to_dof_partition(node_partition,D)
415415
dof_partition
416416
end
417417

418-
function node_coorinates_unit_cube(
418+
function node_coordinates_unit_cube(
419419
nodes_per_dir, # free (== interior) nodes
420420
parts_per_dir,
421421
parts,
422422
;
423-
split_format = Val(true),
423+
split_format = Val(false),
424424
value_type::Type{Tv} = Float64,) where Tv
425425

426426
function setup!(own_x,mynodes)
@@ -443,7 +443,12 @@ function node_coorinates_unit_cube(
443443
x
444444
end
445445

446-
function near_nullspace_linear_elasticity(x,
446+
function near_nullspace_linear_elasticity(a...;b...)
447+
@warn "near_nullspace_linear_elasticity is deprecated, use nullspace_linear_elasticity instead"
448+
nullspace_linear_elasticity(a...;b...)
449+
end
450+
451+
function nullspace_linear_elasticity(x,
447452
row_partition = node_to_dof_partition(partition(axes(x,1)),length(eltype(x)))
448453
)
449454
T = eltype(x)
@@ -461,10 +466,10 @@ function near_nullspace_linear_elasticity(x,
461466
dof_partition = row_partition
462467
split_format = Val(eltype(partition(x)) <: SplitVector)
463468
B = [ pzeros(Tv,dof_partition;split_format) for _ in 1:nb ]
464-
near_nullspace_linear_elasticity!(B,x)
469+
nullspace_linear_elasticity!(B,x)
465470
end
466471

467-
function near_nullspace_linear_elasticity!(B,x)
472+
function nullspace_linear_elasticity!(B,x)
468473
D = length(eltype(x))
469474
if D == 1
470475
foreach(own_values(B[1])) do own_b

src/p_vector.jl

+25-8
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ struct SplitVectorAssemblyCache{A,B,C,D}
527527
buffer_snd::C # NB
528528
buffer_rcv::C
529529
exchange_setup::D
530+
reversed::Bool
530531
end
531532
function Base.reverse(a::SplitVectorAssemblyCache)
532533
SplitVectorAssemblyCache(
@@ -537,6 +538,7 @@ function Base.reverse(a::SplitVectorAssemblyCache)
537538
a.buffer_rcv,
538539
a.buffer_snd,
539540
a.exchange_setup,
541+
!(a.reversed),
540542
)
541543
end
542544
function copy_cache(a::SplitVectorAssemblyCache)
@@ -549,23 +551,29 @@ function copy_cache(a::SplitVectorAssemblyCache)
549551
a.own_indices_rcv,
550552
buffer_snd,
551553
buffer_rcv,
552-
a.exchange_setup
554+
a.exchange_setup,
555+
a.reversed,
553556
)
554557
end
555558

556559
function p_vector_cache_impl(::Type{<:SplitVector},vector_partition,index_partition)
557560
neighbors_snd,neighbors_rcv= assembly_neighbors(index_partition)
558561
indices_snd,indices_rcv = assembly_local_indices(index_partition,neighbors_snd,neighbors_rcv)
559-
map(indices_snd,indices_rcv,index_partition) do ids_snd,ids_rcv,myids
562+
ghost_indices_snd = map(indices_snd) do ids
563+
JaggedArray(copy(ids.data),ids.ptrs)
564+
end
565+
own_indices_rcv = map(indices_rcv) do ids
566+
JaggedArray(copy(ids.data),ids.ptrs)
567+
end
568+
foreach(ghost_indices_snd,own_indices_rcv,index_partition) do ids_snd,ids_rcv,myids
560569
map_local_to_ghost!(ids_snd.data,myids)
561570
map_local_to_own!(ids_rcv.data,myids)
562571
end
563-
ghost_indices_snd = indices_snd
564-
own_indices_rcv = indices_rcv
565-
buffers_snd,buffers_rcv = map(assembly_buffers,vector_partition,indices_snd,indices_rcv) |> tuple_of_arrays
572+
buffers_snd,buffers_rcv = map(assembly_buffers,vector_partition,ghost_indices_snd,own_indices_rcv) |> tuple_of_arrays
566573
graph = ExchangeGraph(neighbors_snd,neighbors_rcv)
567574
exchange_setup = setup_exchange(buffers_rcv,buffers_snd,graph)
568-
SplitVectorAssemblyCache(neighbors_snd,neighbors_rcv,ghost_indices_snd,own_indices_rcv,buffers_snd,buffers_rcv,exchange_setup)
575+
reversed = false
576+
SplitVectorAssemblyCache(neighbors_snd,neighbors_rcv,ghost_indices_snd,own_indices_rcv,buffers_snd,buffers_rcv,exchange_setup,reversed)
569577
end
570578

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

612620
function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
621+
reversed = cache.reversed
613622
ghost_indices_snd=cache.ghost_indices_snd
614623
own_indices_rcv=cache.own_indices_rcv
615624
neighbors_snd=cache.neighbors_snd
@@ -618,7 +627,11 @@ function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
618627
buffer_rcv=cache.buffer_rcv
619628
exchange_setup=cache.exchange_setup
620629
foreach(vector_partition,ghost_indices_snd,buffer_snd) do values,ghost_indices_snd,buffer_snd
621-
ghost_vals = values.blocks.ghost
630+
if reversed
631+
ghost_vals = values.blocks.own
632+
else
633+
ghost_vals = values.blocks.ghost
634+
end
622635
for (p,hid) in enumerate(ghost_indices_snd.data)
623636
buffer_snd.data[p] = ghost_vals[hid]
624637
end
@@ -629,7 +642,11 @@ function assemble_impl!(f,vector_partition,cache::SplitVectorAssemblyCache)
629642
@fake_async begin
630643
wait(t)
631644
foreach(vector_partition,own_indices_rcv,buffer_rcv) do values,own_indices_rcv,buffer_rcv
632-
own_vals = values.blocks.own
645+
if reversed
646+
own_vals = values.blocks.ghost
647+
else
648+
own_vals = values.blocks.own
649+
end
633650
for (p,oid) in enumerate(own_indices_rcv.data)
634651
own_vals[oid] = f(own_vals[oid],buffer_rcv.data[p])
635652
end

test/gallery_tests.jl

+29-5
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,44 @@ function gallery_tests(distribute,parts_per_dir)
3232
@test isa(y,PVector)
3333
A = psparse(SparseMatrixCSR{1,Float64,Int32},args...) |> fetch
3434
A |> centralize |> display
35-
Y = A*pones(axes(A,2))
35+
y = A*pones(axes(A,2))
3636
@test isa(y,PVector)
3737

3838
args = linear_elasticity_fem(nodes_per_dir,parts_per_dir,ranks)
3939
A = psparse(args...) |> fetch
4040
A |> centralize |> display
41-
Y = A*pones(axes(A,2))
41+
y = A*pones(axes(A,2))
4242
@test isa(y,PVector)
4343

44-
x = node_coorinates_unit_cube(nodes_per_dir,parts_per_dir,ranks)
45-
B = near_nullspace_linear_elasticity(x)
44+
x = node_coordinates_unit_cube(nodes_per_dir,parts_per_dir,ranks)
45+
B = nullspace_linear_elasticity(x)
4646
@test isa(B[1],PVector)
47-
B = near_nullspace_linear_elasticity(x,partition(axes(A,2)))
47+
y = A*pones(axes(A,2))
48+
@test isa(y,PVector)
49+
B = nullspace_linear_elasticity(x,partition(axes(A,2)))
4850
@test isa(B[1],PVector)
51+
y = A*pones(axes(A,2))
52+
@test isa(Y,PVector)
53+
y = A*B[1]
54+
@test isa(y,PVector)
55+
nullspace_linear_elasticity!(B,x)
56+
y = A*B[1]
57+
@test isa(y,PVector)
58+
59+
x = node_coordinates_unit_cube(nodes_per_dir,parts_per_dir,ranks,split_format=true)
60+
B = nullspace_linear_elasticity(x)
61+
@test isa(B[1],PVector)
62+
y = A*pones(axes(A,2))
63+
@test isa(y,PVector)
64+
B = nullspace_linear_elasticity(x,partition(axes(A,2)))
65+
@test isa(B[1],PVector)
66+
y = A*pones(axes(A,2))
67+
@test isa(Y,PVector)
68+
y = A*B[1]
69+
@test isa(y,PVector)
70+
nullspace_linear_elasticity!(B,x)
71+
y = A*B[1]
72+
@test isa(y,PVector)
4973

5074
end
5175

0 commit comments

Comments
 (0)