There are multiple things you should do to improve your code.
First,
You should use _fm.rename("fm","")
after projection to make time dependent visualization work.
Secondly, one should avoid calling
and
Inside loops, as these calls does not cache expensive calls to matrix creation, solver creation, and in the case of projection a reassembly of a time independent matrix (and subsequent LU factorization).
You should instead use
LUSolver
for projections, and
NonlinearVariationalSolver
for nonlinear problems.
In general, if you are new to Dolfin, it is recommended to use Dolfinx, see: