 # How to compute the number of dof from a generated mesh?

Hi,

Please could you tell me a simple way to compute the total number of dof ?

Here is my minimal code

``````#Geometry
L, H = 1, 1
approx_cell_size = 0.05
#Mesh 1 : triangular elements, linear interpolation
approx_number_of_elements_on_edge = L/approx_cell_size
geom = Rectangle(Point(0., 0.), Point(L, H))
mesh = generate_mesh(geom, approx_number_of_elements_on_edge)

#Mesh 2 : triangular elements (crossed), linear interpolation
#mesh = RectangleMesh(Point(0., 0.), Point(L, H), L/approx_cell_size, H/approx_cell_size, "crossed")

minimal_cell_size = mesh.hmin()
ndim = mesh.topology().dim()
plt.figure(figsize=(5, 5))
plot(mesh)
number_of_cells = mesh.num_cells()
print("Total number of cells %.0f, Minimal cell size %.2f, %.0f dof "%(number_of_cells, minimal_cell_size, ? ))
``````

If you are thinking of the “dofs” as the vertices of the mesh, you can use `mesh.num_vertices()`, as shown in the next snippet:

``````
number_of_cells = mesh.num_cells()
number_of_vertices = mesh.num_vertices()
print("Total number of cells %.0f, Minimal cell size %.2f, %.0f dof "%(number_of_cells, minimal_cell_size,  number_of_vertices))
``````

However, if you are actually interested in the degrees of freedom (dofs), you need to create the function space you are interested in, i.e.:

``````V = FunctionSpace(mesh, "CG", 1)
V2 = FunctionSpace(mesh, "CG", 2)
print(V.dim(), V2.dim())
``````

Thank you very much.

By the way, do you have any information about the official website of FEniCS ? I face problems when i try to open fenicsproject.org… It is not working

The link you have posted above works fine for me, and the documentation can be found at: https://fenicsproject.org/olddocs/dolfin/latest/python/