From 0bcc8d9a836430fdad78725f75f93870e2578ecd Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Tue, 17 Oct 2023 17:54:35 +1100 Subject: [PATCH] Added allocate_col_vector --- src/Algebra.jl | 29 +++++++++++++++++++++++++++++ src/GridapDistributed.jl | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/Algebra.jl b/src/Algebra.jl index e8fedd02..d13406ba 100644 --- a/src/Algebra.jl +++ b/src/Algebra.jl @@ -9,6 +9,35 @@ function Algebra.allocate_vector(::Type{<:BlockPVector{V}},ids::BlockPRange) whe BlockPVector{V}(undef,ids) end +# Row/Col vector allocations for serial +function allocate_row_vector(A::AbstractMatrix{T}) where T + return zeros(T,size(A,1)) +end + +function allocate_col_vector(A::AbstractMatrix{T}) where T + return zeros(T,size(A,2)) +end + +# Row/Col vector allocations for parallel +function allocate_row_vector(A::PSparseMatrix) + T = eltype(A) + return pfill(zero(T),partition(axes(A,1))) +end + +function allocate_col_vector(A::PSparseMatrix) + T = eltype(A) + return pfill(zero(T),partition(axes(A,2))) +end + +# Row/Col vector allocations for blocks +function allocate_row_vector(A::AbstractBlockMatrix) + return mortar(map(Aii->allocate_row_vector(Aii),blocks(A)[:,1])) +end + +function allocate_col_vector(A::AbstractBlockMatrix) + return mortar(map(Aii->allocate_col_vector(Aii),blocks(A)[1,:])) +end + # This might go to Gridap in the future. We keep it here for the moment. function change_axes(a::Algebra.ArrayCounter,axes) @notimplemented diff --git a/src/GridapDistributed.jl b/src/GridapDistributed.jl index 9e985bc8..bcacf35d 100644 --- a/src/GridapDistributed.jl +++ b/src/GridapDistributed.jl @@ -40,6 +40,8 @@ export get_face_gids export local_views, get_parts export with_ghost, no_ghost +export allocate_col_vector, allocate_row_vector + include("BlockPartitionedArrays.jl") include("Algebra.jl")