How to get the dimension of my Functional space

Hello,

I am trying to run the following code:

domain = mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0, 0]), np.array([1, 1])],[nx, ny], mesh.CellType.triangle)
W = fem.FunctionSpace(domain, ("CG", 1))
n = FacetNormal(domain)
print(W.dim())

the last command should give me the number of degrees of freedom, but instead I get the following error:

AttributeError: 'FunctionSpaceBase' object has no attribute 'dim'

I have installed Fenicsx with conda.

Thanks for the help,

Michele.

Vh.dofmap.index_map.size_global (or Vh.dofmap.index_map.size_global * Vh.dofmap.bs if the unknown was a vector or tensor).

Please keep in mind for future posts that the best way to get help in this forum is to provide a minimal reproducible example, including imports (e.g., from dolfinx import fem, mesh in your case).

Thanks for the answer. Sure, next time I will be more precise.