Skip to content

Commit

Permalink
Added allocate_col_vector
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Oct 17, 2023
1 parent 3c2245c commit 0bcc8d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/GridapDistributed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0bcc8d9

Please sign in to comment.