Size of Cells/Facets/Edges

I am used to Dolfin, where there exist objects like Cell(mesh, cell), Face(mesh, face), or Edge(mesh, edge), and you can call their volume/area/length with Cell(mesh, cell).volume() for example.

Is there something similar in Dolfinx? How can one compute these quantities? the function dolfinx.cpp.mesh.volume_entities() is not in Dolfinx 0.7.0 anymore

1 Like

There are a number of mesh utlity functions. The closest to what you had in the past is likely this: https://github.com/FEniCS/dolfinx/blob/main/cpp/dolfinx/mesh/utils.h#L219.

However, going forward, DOLFINx supports arbitrary order cells with arbitrary mappings from a reference cell. This makes a catch all volume computation difficult to write in the C++ layer without defining an FE formulation. In a problem’s script, however, this can be achieved by assembling the vector, e.g.,

V = dolfinx.fem.FunctionSpace(mesh, ("DG", 0))
h = dolfinx.fem.assemble(dolfinx.fem.form(dolfinx.fem.Constant(mesh, 1.0) * ufl.dx))

being sure to carefully chose quadrature degree.

The h function is wrapped within the mesh object: dolfinx.mesh — DOLFINx 0.7.0 documentation

But as @nate states, one needs assembly to compute area/volume of curved geometries, as the jacobian is non-constant.