Efficiently solving Poisson eqn repeatedly

There are several things in your code that is not efficient,
1.

You do not need to recompile the form if f is in the same function space. You can simply create your form outside the loop and update f through interpolation.

This should not be required, as the form should be constant in time, and the coefficients in f will be automatically updated during the solve stage.

2 Likes