Skip to content

Commit

Permalink
Merge pull request #939 from gridap/expanding-block-assembly
Browse files Browse the repository at this point in the history
Block assembly works with AbstractBlockArrays
  • Loading branch information
JordiManyer authored Aug 30, 2023
2 parents 27a04ea + 22875be commit 578f5b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Block assembly now generalised to work with `AbstractBlockArrays`, to include changes in GridapDistributed. Since PR [939](https://github.com/gridap/Gridap.jl/pull/939).

## [0.17.19] - 2023-08-23

### Fixed

- Reimplemented `DomainStyle` for `CellQuadrature` to fix breaking low-level Poisson tutorial. Since PR [#937](https://github.com/gridap/Gridap.jl/pull/937).

## [0.17.18] - 2023-08-15
## [0.17.18] - 2023-08-15

### Added

Expand Down
19 changes: 11 additions & 8 deletions src/MultiField/BlockSparseMatrixAssemblers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ end
function FESpaces.SparseMatrixAssembler(mat,
vec,
trial::MultiFieldFESpace{<:BlockMultiFieldStyle},
test::MultiFieldFESpace{<:BlockMultiFieldStyle},
test ::MultiFieldFESpace{<:BlockMultiFieldStyle},
strategy::AssemblyStrategy=DefaultAssemblyStrategy())
return BlockSparseMatrixAssembler(trial,test,SparseMatrixBuilder(mat),ArrayBuilder(vec),strategy)
end
Expand Down Expand Up @@ -272,22 +272,25 @@ end
# In place assembly modifications (for dispatching)
# We convert from BlockArray to ArrayBlock to be able to expland the blocks.
# After assembly we convert back to BlockArray automatically.
function FESpaces.assemble_vector_add!(b::BlockVector,a::BlockSparseMatrixAssembler,vecdata)
b1 = ArrayBlock(b.blocks,fill(true,size(b.blocks)))
function FESpaces.assemble_vector_add!(b::AbstractBlockVector,a::BlockSparseMatrixAssembler,vecdata)
b1 = ArrayBlock(blocks(b),fill(true,blocksize(b)))
b2 = expand_blocks(a,b1)
FESpaces.assemble_vector_add!(b2,a,vecdata)
end

function FESpaces.assemble_matrix_add!(mat::BlockMatrix,a::BlockSparseMatrixAssembler,matdata)
m1 = ArrayBlock(mat.blocks,fill(true,size(mat.blocks)))
function FESpaces.assemble_matrix_add!(mat::AbstractBlockMatrix,a::BlockSparseMatrixAssembler,matdata)
m1 = ArrayBlock(blocks(mat),fill(true,blocksize(mat)))
m2 = expand_blocks(a,m1)
FESpaces.assemble_matrix_add!(m2,a,matdata)
end

function FESpaces.assemble_matrix_and_vector_add!(A::BlockMatrix,b::BlockVector,a::BlockSparseMatrixAssembler,data)
m1 = ArrayBlock(A.blocks,fill(true,size(A.blocks)))
function FESpaces.assemble_matrix_and_vector_add!(A::AbstractBlockMatrix,
b::AbstractBlockVector,
a::BlockSparseMatrixAssembler,
data)
m1 = ArrayBlock(blocks(A),fill(true,blocksize(A)))
m2 = expand_blocks(a,m1)
b1 = ArrayBlock(b.blocks,fill(true,size(b.blocks)))
b1 = ArrayBlock(blocks(b),fill(true,blocksize(b)))
b2 = expand_blocks(a,b1)
FESpaces.assemble_matrix_and_vector_add!(m2,b2,a,data)
end

0 comments on commit 578f5b7

Please sign in to comment.