diff --git a/src/Algebra.jl b/src/Algebra.jl index e8fedd0..d13406b 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 9e985bc..bcacf35 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")