I want to assemble a weighted mass matrix,
wkform = inner(rho*test, trial)*dx
M = assemble(wkform)
then extract the diagonal part of M. Since M can be large, I'd like to avoid useless computations, and assemble M in a way that makes it directly diagonal (i.e, only when test and trial are the same).
What would be a way to do that?