issueatlas · · Reply permalink
youre not doing anything wrong here. the block size comes from the dofmap (check V.dofmap.bs), which dolfinx derives from the basix element. a plain vector lagrange element is built as a blocked element, so bs = gdim and you get a baij matrix. enriched_element builds a generic combined element that doesnt advertise any block structure, basix just reports block size 1, so the dofmap and the matrix end up unblocked. known limitation, not a bug in your code.
and yes, it does matter for gamg. that dofs per grid point bit from the petsc docs is exactly this: gamg reads the matrix block size during setup. with bs = 1 it treats every dof as scalar, which usually still converges but the multigrid hierarchy is less effective on the velocity block.
pragmatic workaround: every node in the mini velocity space genuinely carries gdim dofs (vertices from the p1 part, cell interiors from the bubble), so you can just tell petsc yourself, e.g. problem.A.setBlockSize(gdim) before the solve. same idea for the (0,0) block in your nested matrix.
Source: https://fenicsproject.discourse.group/t/incorrect-petsc-mat-block-size-when-using-enriched-element/19805