One immediate optimisation is to take fem.form(a)
outside of the loop. This will be looking up the cache on your file system and potentially compiling a form each call. This is very expensive and not its intended use.
This also means you should refactor constant values (e.g. t
) into a dolfinx.fem.Constant
and update them. Then you don’t have to recompile the form every time step.
Trying to find more optimisations will likely involve splitting up your stiffness matrix into linear combinations of those with multiples of updating constants. You then won’t have to assemble the FE matrix each time step, just a linear combination of matrices which I believe is scalable.
You can then try to accommodate for these trivial matrix updates in the LU factorisation. If you can reuse the LU factorisation or, like with the matrix operators compose it of a linear combination, you should see a big performance leap.