How to apply Neuman boundary condition to Finite-Element-Method problems? I have a 2D rectangular domain. The governing equation on this domain is Laplace equation:
$\nabla^2 f = 0$ 
In the left edge there is Neumann boundary conditon :
$\frac{\partial f}{\partial n} = -a$ 
n is the normal vector to the domain's boundary(here on the left edge it's equal to the negative direction of x axis) and 'a' is a given date and it's a constant.
There is a Dirichlet boundary condition at the bottom edge and there is no boundary condition on right and top edge.
My problem is how to apply that Neumann boundary condition. I'm using finite element method (with first order triangulation)
As you may know, in finite element method first we make stiffness matrix (or global coefficient matrix from local coefficient matrix). Then we apply our governing equation(here the Laplace equation).
 A: If a=0, i.e., the Neumann data is homogeneous, you don't need to do anything. Just construct the stiffness matrix including the nodes at the Neumann boundary, and solve the equation (do whatever you do to the Dirichlet part, as there can be many ways to implement it). The Neumann b.c. is imposed by the variational formulation automatically, which is the reason to call this b.c. a natural b.c.
Otherwise, you have to change the right hand side, so that it includes a boundary integral term in the variational formulation.
Have a look at
Susanne Brenner and Ridgway Scott. The mathematical theory of finite element methods.
A: You need to modify right-hand vector b of an equation Kx = b, where K is your stiffness matrix.
Here's how to do it, depending on which edge is on von Neumann boundary:


*

*edge 1-2 (i.e. connecting local nodes 1 and 2), 
l = sqrt(x21*x21 + y21*y21);
b[node1] += a * l / 2.0f;
b[node2] += a * l / 2.0f;
b[node3] += 0;


*edge 1-3,
l = sqrt(x13*x13 + y13*y13);
b[node1] += a * l / 2.0f;
b[node2] += 0;
b[node3] += a * l / 2.0f;


*edge 2-3,
l = sqrt(x32*x32 + y32*y32);
b[node1] += 0;
b[node2] += a * l / 2.0f;
b[node3] += a * l / 2.0f;

