Combining mpc periodic constraint with realspace

Dear all,

I have an issue where I use MPC to ensure periodic boundary constraints on a square domain, and the solution must have zero mean over the domain. I would like to combine the linear solver of MPC with a real_function_space, but I cannot find the equivalent of the dolfinx.fem.petsc.assemble_matrix_block function in MPC.

I worked around the issue by using the MPC solver and adding a null space. At the end, I subtracted the mean of the function. However, I cannot do this now because I have a problem where the linear form depends directly on the test function and not on its gradient. Therefore, I want to ensure that the test function is chosen in a zero-mean space from the beginning.

Is there a way to do this?

Thanks in advance!

You could try to use the assemble_nest functionality highlighted in: dolfinx_mpc/python/demos/demo_stokes_nest.py at main · jorgensd/dolfinx_mpc · GitHub

or you could try to use my newly developed periodic mesh: Periodic conditions for vector valued spaces - #9 by dokken (given that your mesh is actually periodic).