Skip to content

Commit 46ae438

Browse files
authored
Merge pull request #163 from fverdugo/split_vector
Split vector
2 parents 37e60ca + 541eec6 commit 46ae438

File tree

6 files changed

+436
-27
lines changed

6 files changed

+436
-27
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
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+
## "master" branch
9+
10+
### Added
11+
12+
- Split format support for `PVector`.
13+
- Helper functions to build partitioned sparse matrices and vectors in split format, `pvector_from_split_blocks` and `psparse_from_split_blocks`.
14+
15+
### Deprecated
16+
17+
- `OwnAndGhostVectors` is replaced by `SplitVector`.
18+
819
## [0.5.1] - 2024-07-26
920

1021
### Added

src/PartitionedArrays.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,16 @@ export repartition
134134
export repartition!
135135
export renumber
136136
export find_local_indices
137+
export SplitVector
138+
export split_vector
139+
export split_vector_blocks
140+
export pvector_from_split_blocks
137141
include("p_vector.jl")
138142

139143
export SplitMatrix
144+
export split_matrix
145+
export split_matrix_blocks
146+
export psparse_from_split_blocks
140147
export PSparseMatrix
141148
export psparse
142149
export psparse!

src/p_sparse_matrix.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,16 @@ function split_matrix(
637637
SplitMatrix(blocks,row_permutation,col_permutation)
638638
end
639639

640+
function split_matrix(
641+
own_own::AbstractMatrix,
642+
own_ghost::AbstractMatrix,
643+
ghost_own::AbstractMatrix,
644+
ghost_ghost::AbstractMatrix,
645+
row_permutation,
646+
col_permutation)
647+
blocks = split_matrix_blocks(own_own,own_ghost,ghost_own,ghost_ghost)
648+
split_matrix(blocks,row_permutation,col_permutation)
649+
end
640650

641651
Base.size(a::AbstractSplitMatrix) = (length(a.row_permutation),length(a.col_permutation))
642652
Base.IndexStyle(::Type{<:AbstractSplitMatrix}) = IndexCartesian()
@@ -1294,6 +1304,33 @@ function psparse!(C,V,cache)
12941304
end
12951305
end
12961306

1307+
function psparse_from_split_blocks(oo,oh,ho,hh,rowp,colp;assembled=false)
1308+
rperms = map(local_permutation,rowp)
1309+
cperms = map(local_permutation,colp)
1310+
values = map(split_matrix,oo,oh,ho,hh,rperms,cperms)
1311+
PSparseMatrix(values,rowp,colp,assembled)
1312+
end
1313+
1314+
function psparse_from_split_blocks(oo,oh,rowp,colp;assembled=true)
1315+
ho = map(oo,rowp,colp) do oo, rows, cols
1316+
T = typeof(oo)
1317+
Tv = eltype(oo)
1318+
Ti = indextype(oo)
1319+
n_ghost_rows = ghost_length(rows)
1320+
n_own_cols = own_length(cols)
1321+
sparse_matrix(T,Ti[],Ti[],Tv[],n_ghost_rows,n_own_cols)
1322+
end
1323+
hh = map(oo,rowp,colp) do oo, rows, cols
1324+
T = typeof(oo)
1325+
Tv = eltype(oo)
1326+
Ti = indextype(oo)
1327+
n_ghost_rows = ghost_length(rows)
1328+
n_ghost_cols = ghost_length(cols)
1329+
sparse_matrix(T,Ti[],Ti[],Tv[],n_ghost_rows,n_ghost_cols)
1330+
end
1331+
psparse_from_split_blocks(oo,oh,ho,hh,rowp,colp;assembled)
1332+
end
1333+
12971334
function assemble(A::PSparseMatrix;kwargs...)
12981335
rows = map(remove_ghost,partition(axes(A,1)))
12991336
assemble(A,rows;kwargs...)

0 commit comments

Comments
 (0)