It appears to me that preallocation of blocked PETSc matrices may be computed incorrectly in libMesh under certain circumstances. Consider the following 9-node mesh:
| | |
| | |
with two first order Lagrange variables on it. Assume that _dof_coupling is "diagonal" (i.e., the variables are not coupled to one another - a real use case in Moose, at least in moose_test).
Then the "unblocked" n_nz would be (since there are 2 identical dofs per node):
The nodes, identified with the matrix blocks, have a similar connectivity, although there are half as many of them:
This blocked preallocation is transformed, however, into the following blocked version b_n_nz:
which is incorrect.
This subsequently leads to extra mallocs during matrix assembly. It seems to me that correct preallocation will only result for "full coupling" -- _dof_coupling of all ones.