I would like to use a lumped mass matrix as part of a time dependant problem. There is a solution (https://fenicsproject.org/qa/4284/mass-matrix-lumping/) that gives some ideas but I don’t see how to apply this to define my variational form.
Consider this (I know very silly) example of a L2 projection using mass lumping.
from fenics import * mesh = UnitIntervalMesh(5) P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 1) V = FunctionSpace(mesh, P1) u = TestFunction(V) v = TrialFunction(V) u_old = interpolate(Constant(2.0), V) mass_form = v*u*dx() mass_action_form = action(mass_form, Constant(1)) M_lumped = assemble(mass_form) M_lumped.zero() M_lumped.set_diagonal(assemble(mass_action_form)) # TODO what to put here? F = M_lumped * (u - u_old) u = Function(V) solve(F==0, u) print(u.vector().get_local())
Is there a way to use M_lumped here or do I need to do something else?
Thanks in advance for any help