From e4a572ff34eefb53dd7ad02a74689916d18d3aaf Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Fri, 29 Dec 2023 10:59:18 +1100 Subject: [PATCH 1/2] Bugfix: Incorrect block assembly when permuting variables --- src/MultiField/BlockSparseMatrixAssemblers.jl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/MultiField/BlockSparseMatrixAssemblers.jl b/src/MultiField/BlockSparseMatrixAssemblers.jl index b4a336d74..b8a6e2ae2 100644 --- a/src/MultiField/BlockSparseMatrixAssemblers.jl +++ b/src/MultiField/BlockSparseMatrixAssemblers.jl @@ -36,17 +36,20 @@ function FESpaces.get_vector_builder(a::BlockSparseMatrixAssembler{NB,NV}) where return expand_blocks(a,builders) end -expand_blocks(::BlockSparseMatrixAssembler{NB,NB},blocks::MatrixBlock) where NB = blocks -expand_blocks(::BlockSparseMatrixAssembler{NB,NB},blocks::VectorBlock) where NB = blocks - -function expand_blocks(a::BlockSparseMatrixAssembler{NB,NV},blocks::MatrixBlock) where {NB,NV} +function expand_blocks(a::BlockSparseMatrixAssembler{NB,NV,SB,P},blocks::MatrixBlock) where {NB,NV,SB,P} + if (NB == NV) && all(x -> x[1] == x[2], enumerate(P)) + return blocks + end block_map = get_block_map(a) - ArrayBlockView(blocks,block_map) + return ArrayBlockView(blocks,block_map) end -function expand_blocks(a::BlockSparseMatrixAssembler{NB,NV},blocks::VectorBlock) where {NB,NV} +function expand_blocks(a::BlockSparseMatrixAssembler{NB,NV,SB,P},blocks::VectorBlock) where {NB,NV,SB,P} + if (NB == NV) && all(x -> x[1] == x[2], enumerate(P)) + return blocks + end block_map = map(idx -> CartesianIndex(idx[1]), diag(get_block_map(a))) - ArrayBlockView(blocks,block_map) + return ArrayBlockView(blocks,block_map) end function get_block_ranges(NB::Integer,SB,P) From 0a77dd05a9625cde5e2d0edaf5c3d6277d096028 Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Thu, 11 Jan 2024 15:48:44 +1100 Subject: [PATCH 2/2] Updated NEWS --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index cb1ae62f9..e17247191 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed issue where `FineToCoarseField` would not work for vector-valued fields. Since PR[#970](https://github.com/gridap/Gridap.jl/pull/970). +- Fixed issue where `BlockSparseMatrixAssembler` would not work correctly when permuting variables. Since PR[#971](https://github.com/gridap/Gridap.jl/pull/971). ## [0.17.21] - 2023-12-04