Skip to content

Commit a98598e

Browse files
authored
Merge pull request #139 from gridap/allocate-vectors
allocate_in_range/domain for distributed types
2 parents b1cdfb6 + f70e642 commit a98598e

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ 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+
## Unreleased
9+
10+
### Added
11+
12+
- Added missing methods `allocate_in_range` and `allocate_in_domain` for distributed types. Since PR [#139](https://github.com/gridap/GridapDistributed.jl/pull/139).
13+
814
## [0.3.4] - 2023-11-24
915

1016
### Added

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
1717
[compat]
1818
BlockArrays = "0.16.38"
1919
FillArrays = "0.8.4,1"
20-
Gridap = "0.17.18"
20+
Gridap = "0.17.21"
21+
LinearAlgebra = "1.3"
2122
MPI = "0.16, 0.17, 0.18, 0.19, 0.20"
2223
PartitionedArrays = "0.3.3"
24+
SparseArrays = "1.3"
2325
SparseMatricesCSR = "0.6.6"
2426
WriteVTK = "1.12.0"
2527
julia = "1.3"
26-
SparseArrays = "1.3"
27-
LinearAlgebra = "1.3"
2828

2929
[extras]
3030
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"

src/Algebra.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ function Algebra.allocate_vector(::Type{<:BlockPVector{V}},ids::BlockPRange) whe
99
BlockPVector{V}(undef,ids)
1010
end
1111

12+
function Algebra.allocate_in_range(matrix::PSparseMatrix)
13+
V = Vector{eltype(matrix)}
14+
allocate_in_range(PVector{V},matrix)
15+
end
16+
17+
function Algebra.allocate_in_domain(matrix::PSparseMatrix)
18+
V = Vector{eltype(matrix)}
19+
allocate_in_domain(PVector{V},matrix)
20+
end
21+
22+
function Algebra.allocate_in_range(matrix::BlockPMatrix)
23+
V = Vector{eltype(matrix)}
24+
allocate_in_range(BlockPVector{V},matrix)
25+
end
26+
27+
function Algebra.allocate_in_domain(matrix::BlockPMatrix)
28+
V = Vector{eltype(matrix)}
29+
allocate_in_domain(BlockPVector{V},matrix)
30+
end
31+
1232
# This might go to Gridap in the future. We keep it here for the moment.
1333
function change_axes(a::Algebra.ArrayCounter,axes)
1434
@notimplemented

test/BlockSparseMatrixAssemblersTests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module BlockSparseMatrixAssemblersTests
33
using Test, LinearAlgebra, BlockArrays, SparseArrays
44

55
using Gridap
6-
using Gridap.FESpaces, Gridap.ReferenceFEs, Gridap.MultiField
6+
using Gridap.FESpaces, Gridap.ReferenceFEs, Gridap.MultiField, Gridap.Algebra
77

88
using GridapDistributed
99
using PartitionedArrays
@@ -22,12 +22,12 @@ function is_same_vector(x::BlockPVector,y::PVector,Ub,U)
2222
end
2323

2424
function is_same_matrix(Ab::BlockPMatrix,A::PSparseMatrix,Xb,X)
25-
yb = mortar(map(Aii->pfill(0.0,partition(axes(Aii,1))),diag(blocks(Ab))));
26-
xb = mortar(map(Aii->pfill(1.0,partition(axes(Aii,2))),diag(blocks(Ab))));
25+
yb = allocate_in_range(Ab)
26+
xb = allocate_in_domain(Ab); fill!(xb,1.0)
2727
mul!(yb,Ab,xb)
2828

29-
y = pfill(0.0,partition(axes(A,1)))
30-
x = pfill(1.0,partition(axes(A,2)))
29+
y = allocate_in_range(A)
30+
x = allocate_in_domain(A); fill!(x,1.0)
3131
mul!(y,A,x)
3232

3333
return is_same_vector(yb,y,Xb,X)

0 commit comments

Comments
 (0)