Mixing dolfinx_mpc and scifem packages

Hello everyone, after the announcement of dolfinx v0.10.0, I decided to retake the issue of Mixing dolfinx_mpc and scifem packages for a nonlinear problem in which I tried to solve an homogenisation problem, i.e., with periodic boundary conditions, and real spaces for global lagrange multipliers. However, although I thought at first that only a few functions would need to be modified (like combiningassemble_residual_mpc from dolfinx_mpc/problem.py with _assemble_residual of scifem/solvers.py), I have come to the conclusion that also the way matrices are assembled should be changed, since dolfinx_mpc uses nest assembly and scifem uses block assembly for real function spaces.

Would it be possible for someone to give me a hand? I feel that my knowledge of dolfinx is not deep enough to change the core functions. Thank you very much in advance.

I do not have time too cook up a full example that solves your whole problem. As you will see from the code within DOLFINx, scifem, DOLFINx_mpc, block and nest matrices are not that different with respect to how to do the assembly into them. I might have time to make an example in scifem using nest matrices, I’ll let you know.

Ok, thank you very much. In the meantime, i’ll take a look at the assembly and i’ll try it myself.

Have you gotten anywhere with this? I am currently trying it too.

Real function spaces are now part of the dolfinx core (since 0.11; Release notes — DOLFINx Python 0.11.0.post0) which means that it should work nicely with dolfinx_mpc 0.11 (Release v0.11.0 · jorgensd/dolfinx_mpc · GitHub, available on for instance conda forge).