from dolfin import *
import numpy as np
mesh = UnitSquareMesh(1,1)
V = VectorFunctionSpace(mesh, "CG", 1)
u = Function(V)
u.interpolate(Expression(("3*x[0]", "2*x[1]"), degree=1))
element = V.element()
dofmap = V.dofmap()
for cell in cells(mesh):
print(element.tabulate_dof_coordinates(cell))
print(dofmap.cell_dofs(cell.index()))

The function u has 8 dofs, 2 at each vertex of the mesh.
As you can see by the cell dof coordinates (each cell has 6 dofs), they are ordered as (dof_(0,x), dof_(1,x), dof_(2,x), dof_(0,y), dof_(1,y), dof_(2,y)) where the first index corresponds to the local ordering of the vertex of the cell.

the dofmap.cell_dofs(i) tells you the position of your degree of freedom in u.vector()[:], i.e. the position of the degree of freedom local to the process.

sir, I read these syntax on Discourse but i didn’t understand the meaning of the syntax given below:

with u_b.vector.localForm() as loc: what is the usuage of this command.

u_bc = dolfinx.Function(V)
with u_bc.vector.localForm() as loc:
loc.setValues(bc_dofs, np.full(len(bc_dofs), 0))
bc = dolfinx.DirichletBC(u_bc, bc_dofs)