Given a consistent mass bilinear form M=rho*inner(du, v)*dx
, create the diagonal part of the lumped matrix
M_lumped = assemble(action(M, Constant(1.0)))
where in the 2d/3d cases, Constant(1.0)
is to be replaced by Constant([1.0, 1.0])
, etc...
Given your total force vector F = F_ext - F_int
, the nodal acceleration vector can be computed by
a.set_local(F.array() / M_lumped.array())
a.apply("insert")
This code should also work in parallel. You can try
mpirun -np 2 python script.py