# Component-wise assembly of a mixed element problem: application for the advective Cahn-Hilliard problem

I am looking for a way to speed up the computation of the advective Cahn-Hilliard problem with a time-dependent velocity field \beta.

\begin{aligned} \frac{\partial \phi}{\partial t} + \mathbf{\beta} \cdot \nabla \phi - \nabla^2 \mu = 0 \\ \mu - \left( \phi^3 - \phi \right) + \nabla^2 \phi = 0 \end{aligned}

Backward Euler time discretization with constant time increment \tau and linear splitting of the double-well potential yields the following linear problem at each time step:

$$\left[ \begin{array}{cc} \mathbf{I} + \tau \mathbf{A}^{\text{adv}} & \tau \mathbf{A}^{\text{diff}} \\ - 2 \mathbf{I} - \mathbf{A}^{\text{diff}} & \mathbf{I} \\ \end{array} \right] \left[ \begin{array}{c} \phi^{(n+1)} \\ \mu^{(n+1)} \end{array} \right] = \left[ \begin{array}{c} \phi^{(n)} \\ \left( \phi^{(n)} \right)^3 - 3 \phi^{(n)} \end{array} \right]$$
with \mathbf{A}^{\text{adv}} and \mathbf{A}^{\text{diff}} the advection operator and the diffusion operator respectively.

I would like to only assemble the top left component of the matrix at each time step to speed up the process, as only the advection operator needs to be updated.
The other components only need to be assembled once.

Does someone know a way to do that ?

So far, I’ve been using a mixed element functionspace like seen in this demo.

Maybe there is a way to do this with a nested matrix but I haven’t found any relevant information so far.

Also, if you have any preconditionner recommendations for this specific linear problem, please let me know.

Prepare a form that corresponds to the other 3 blocks (and zero on the top left), and assemble it in a matrix.
Prepare a form that corresponds to the top-left block (and zero on the other blocks). At every iteration, assemble it in a matrix, and then sum it with the other matrix you precomputed.