Mesh connectivity in Fenicsx

There are alot of more detailed examples at: The FEniCSx tutorial — FEniCSx tutorial

domain.topology.index_map(dim) gives you a map of indices for entities of dimension dim. So say you have a 2D mesh, mesh.topology.index_map(2) will give you a map for all triangles (or quads) in the domain. You can access size_local (number of triangles owned by the process), size_global (total number of triangles) across all mpi ranks, num_ghosts (number of triangles on the process that is owned by another rank, typical at partition boundaries).

This is highly dependent on your function space. For first order Lagrange spaces, you can get a relationship between the dofs and the mesh vertices. However, for spaces such as higher order Lagrange, Nedelec
or RT elements, dofs are associated with edges/facets and not vertices. You can get more information about the layout from the FunctionSpace dofmap: dolfinx.fem — DOLFINx 0.8.0.0 documentation
which is documented in the C++ API DOLFINx: ElementDofLayout Class Reference
and relates to the indices in
dolfinx.fem — DOLFINx 0.8.0.0 documentation

See: Implementation — FEniCSx tutorial

This is highly dependent on what cell type (and order you are using).
You could use ufl.CellVolume(domain) and interpolate this expression into a DG-0 function similar to: Implementation — FEniCSx tutorial

As I’m not sure if you mean vertices or degrees of freedom here;

  1. Vertices: dolfinx.mesh — DOLFINx 0.8.0.0 documentation
  2. Could use 1. And then: dolfinx.fem — DOLFINx 0.8.0.0 documentation
5 Likes