Hi,
If you have a system of N equations, you can do:
V = ...
W = MixedFunctionSpace([V]*N)
psi = TrialFunctions(W) # solution
v = TestFunctions(W)
a_lumped = 0
for i in range(0, N):
a_lumped += psi[i]*v[i]*dx(mesh)
# Class for mass matrix lumping
class LumpingClass(Expression):
def eval(self, values, x):
for i in range(0, N):
values[i] = 1.0
def value_shape(self):
return (N,)
const = LumpingClass()
mass_action_form = action(a_lumped, const)
M_lumped = assemble(a_lumped)
M_lumped.zero()
M_lumped.set_diagonal(assemble(mass_action_form)) # M_lumped is now lumped