How can one retrieve the local (elementwise) matrices corresponding to a bilinear form? I have tried to use a DG0 function and assemble the form but can't get it right. I know the following code does the trick but I'm asking if there are alternative ways as this isn't really efficient for large number of cells.
u = TrialFunction(V)
v = TestFunction(V)
cell_domains = CellFunction('size_t',mesh)
elnum = 10 % example
for c in cells(mesh):
cell_domains[c] = c.index()
ml = assemble(inner(u,v)*dx(elnum), cell_domains = cell_domains)
Using a DG0 function is a nice trick for case of a linear form but it doesn't seem to work in this case as I don't think DOLFIN supports the assemby of multilinear forms.