# Control at the boundary

Dear Friends

I want to compute a gradient at the boundary but I dont know how. because the comment On() is used just for boundary condition while solving an equation. I already wrote the equation befor but there was no answer:

where a is constant and U is a boundary value, all are known values (u,a,U are known). when I define all variables in 2D FE space with P2 and define this Gradient on all domain it gives me zero at all points. when I define a boundary FE space by empty mesh and define all these on that space it gives me zero as well. but when I write as follow :int1d(th,inlet)( -((du/dx).Nx+(du/dy).Ny)+a*U) it gives me a real value. now I need a series of data for each node at inlet boundary because this gradient is used as the descent direction for each node to update my boundary condition.

I have been confused for several weeks you are close to the solution.

define a varf (linear form) here

`````` varf vf(unused,v) = int1d(th,inlet)( (-((du/dx).Nx+(du/dy).Ny)+a*U))*v) ;

Vh d; d[]= vf(0,Vh); // to compute your descend vector.
plot(d,wait=1); // to see
``````

remark, you do the classical mistake here vf is the derivative form (differential) and d is the gradient vector.

1 Like

Thanks very much for your response. it worked. 