Building a mixed element space with a flat dofmap

Hello,

is it possible to change the way the dofmap is established while a mixed element space is built? To be more precise, in the following MWE

from dolfinx.mesh import create_unit_interval
from basix.ufl import element, mixed_element
from dolfinx.fem import functionspace
from mpi4py import MPI

msh = create_unit_interval(MPI.COMM_WORLD, 2)
cg1_elem = element("Lagrange", msh.basix_cell(), 1)
mix_elem = mixed_element(2 * [cg1_elem])
mix_elem_space = functionspace(msh, mix_elem)
v_space, v_dofmap = mix_elem_space.sub(0).collapse()
w_space, w_dofmap = mix_elem_space.sub(1).collapse()

v_dofmap = [0, 1, 4] and w_dofmap = [2, 3, 5], i. e. the dofs are interweaved. However, what I would like to achieve is a flat dofmap, i.e. v_dofmap = [0, 1, 2] and w_dofmap= [3, 4, 5].

Thank you for your help.

Best regards

domi

this is the exact reason for using the blocked assemblers in conjuncture with ufl.MixedFunctionSpace.
See for instance Stokes equations using Taylor-Hood elements — DOLFINx 0.9.0 documentation
for various illustrations.

Heads up - this api will be greatly simplified in the next release; see

for details