Permutation matrix for assembled matrix

If you assemble the matrix of a form, how do you get the permutation matrix or the ordering of the dofs?
I would like to see the structure of a saddle-point problem, which is assembled as a complete coupled system, but “unfortunately” the matrix is permutated in such a way that it is almost diagonal. Thank you in advance!

As a starting point see, e.g., dolfinx::fem::DofMap.

1 Like

Is there any way to access this in the Python interface?

Access the dofmap through your function space, i.e.:

V = dolfinx.fem.FunctionSpace(mesh, ("CG", 1))
print(V.dofmap)
<dolfinx.fem.dofmap.DofMap at 0x7fd8b8337550>

I tried that, but unfortunately I am not able to access the index_map in order to get the order of the DOFs. Is there any way to access it in Python?

You can quite easily get it:

In [4]: V.dofmap
Out[4]: <dolfinx.fem.dofmap.DofMap at 0x7f0fbf17ca30>

In [5]: V.dofmap.index_map
Out[5]: <dolfinx.cpp.common.IndexMap at 0x7f0fbdbefa30>

Ok, but I cannot really access the data in this object. How do I get the order of the DOFs in the dofmap as an array?

I think what you want is the dof map.list dolfinx.cpp.fem — DOLFINx 0.4.2.0 documentation which gives you a two dimensional structure where the row corresponds ith row (link) corresponds to get the dofs in the ith cell