rkenko
1
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, ? ))
dokken
2
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())
rkenko
3
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
dokken
4
The link you have posted above works fine for me, and the documentation can be found at: https://fenicsproject.org/olddocs/dolfin/latest/python/