# Direct definition of Dirichlet boundary condtions at the degrees of freedom

I am constructing a Hybrid code using Dolfin.

I set up a Navier-Stokes solver where I prescribe only Dirichlet boundary conditions on the velocities. This works fine.

The problem is that now I define the boundary conditions for the velocity in the following way:

g = Expression(

bc = DirichletBC(V, g, boundaryDomains,3)

where V is a function space associated to my mesh and boundaryDomains is a meshFunction that specifies my boundary.

My question is the following.

If I do not have a g as an expression, that is, if I only have a list of coordinates of the degrees of freedom at the boundary or a list of the index of the degrees of freedom at the boundary and the associated value of the Dirichlet boundary condtion, how can I define the boundary conditions?

Somewhere Dolfin needs to construct such a list of indices of DOF and associated value of the boundary condition. Something like the function:

bc.get_

My problem would be solved if in the assemble process bc.get_

Is this possible and could you give me some short indications on how to accomplish this? Or is there another solution?

Thank you!

## Question information

- Language:
- English Edit question

- Status:
- Solved

- For:
- DOLFIN Edit question

- Assignee:
- No assignee Edit question

- Solved by:
- Artur Palha

- Solved:
- 2013-03-17

- Last query:
- 2013-03-17

- Last reply:
- 2013-03-17

## This question was reopened

Praveen C (cpraveen) said : | #1 |

In

bc = DirichletBC(V, g, boundaryDomains,3)

"g" can be a finite element function. So you can create

g = Function(V)

and fill in the boundary values of g.

Artur Palha (artur-palha) said : | #2 |

Thank you for your answer Praveen.

The problem is that I tried to do that but I was unable to assign the values of g at the nodes.

I did something like this:

g = Function(V)

gVector = g.Vector()

and then I assigned values to gVector. I can assign the values, the problem is that the numbering in Vector is not that same as the one for the vertices. I cannot figure out the numbering.

That is, gVector.array()[0] is not the value associated to vertex 0.