Unable to understand the syntax

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()))

output:

[[0. 0.]
 [1. 0.]
 [1. 1.]
 [0. 0.]
 [1. 0.]
 [1. 1.]]
[2 6 4 3 7 5]
[[0. 0.]
 [0. 1.]
 [1. 1.]
 [0. 0.]
 [0. 1.]
 [1. 1.]]
[2 0 4 3 1 5]

i am not able to understand the ouput and what is the meaning of

[2 6 4 3 7 5]

in fenics.

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.

1 Like

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)

PLease explain explicitly.

See L.zeroEntries() VS loc_L.set(0) - #2 by nate

I am not able to understand