Dear Hemanta,
Your matrix is singular if g1,g2,t1,t2
are in a fespace over the whole mesh Lh (I don’t have this information from your post), because the value of g1,g2
is not determined inside the domain. A way to cure this is to add a small term
+int2d(Lh)(1.e-8*(g1*t1+g2*t2))
making the problem well-posed inside the domain, without perturbing your boundary formulation.
Otherwise a more clear formulation is to take g1,g2,t1,t2
defined only on the boundary \Gamma. An example doing this is here
as stokes_lagrange.edp
There the matrix is built by blocks. Probably you can do also by using a composite space.