# Unable to understand the syntax

**URL:** <https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680>\
**Category:** General\
**Created:** [November 5, 2022, 7:02am UTC](https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680 "2022-11-05T07:02:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aparna](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@aparna](https://fenicsproject.discourse.group/u/aparna)\
**Post date:** [November 5, 2022, 7:02am UTC](https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680/1 "2022-11-05T07:02:17Z")

</div>

```auto
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:

```auto
[[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

```auto
[2 6 4 3 7 5]

```

in fenics.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [November 5, 2022, 9:59am UTC](https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680/2 "2022-11-05T09:59:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aparna](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@aparna](https://fenicsproject.discourse.group/u/aparna)\
**Post date:** [November 5, 2022, 12:37pm UTC](https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680/3 "2022-11-05T12:37:51Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [November 5, 2022, 4:15pm UTC](https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680/4 "2022-11-05T16:15:04Z")

</div>

See [L.zeroEntries() VS loc\_L.set(0) - #2 by nate](https://fenicsproject.discourse.group/t/l-zeroentries-vs-loc-l-set-0/9614/2)

---

<div class="post-metadata">

**Author:** ![aparna](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@aparna](https://fenicsproject.discourse.group/u/aparna)\
**Post date:** [November 6, 2022, 7:29am UTC](https://fenicsproject.discourse.group/t/unable-to-understand-the-syntax/9680/5 "2022-11-06T07:29:23Z")

</div>

I am not able to understand
