DoF's of subspace in parallel

Hi,

I have a question regarding dolfinx and the parallel usage of the dofmap.
In legacy fenics, there was the option to use

V.sub(i).dofmap().dofs()

which gave the global DoF indices that are owned by the current process for the i-th subsapce of some function space V.

How can I get this information in dolfinx? I would have assumed that something along the lines of

np.unique(V.sub(i).dofmap.list)

could work, but the result is exactly the same as for

np.unique(V.dofmap.list)

so that the information is not relevant for the i-th subspace, but includes the information of the entire space.

Can someone with more experience in dolfinx show me how to get the desired result?

Thanks a lot in advance,
Sebastian

Parallelization in dolfinx heavily relies on the index_map. You’ll find that construct whenever arrays of data need to be distributed. Are you looking for something like this?

V0, V0_localdofs = V.sub(0).collapse() # V0 dofs in V local on this core
V_indexmap = V.dofmap.index_map
V0_globaldofs = np.setdiff1d( V_indexmap.local_to_global(np.array(V0_localdofs)), V_indexmap.ghosts ) # getting the global V0 dofs that live on this core

If not, then maybe you could write a short MWE that someone can edit for you.
If you’re interested, this paper may be useful to you: DOLFINx: The next generation FEniCS problem solving environment

1 Like

Thanks a lot, this is what I wanted. For context: I am using this information to create PETSc.IS objects so that I can suitably define the fields for the fiedslplit preconditioner. If there is any built-in way with dolfinx to do so, I would be happy to know.

Ah, right. I took that code snippet from an earlier post of mine that eventually was about PETSc.IS. For reference:

1 Like

Have you considered FEniCS PCTools: Rafinex-external-RIFLE / FEniCSx-pctools · GitLab by @jackhale ?

1 Like

No, not yet, but thanks for the hint - I will give it a try.