I have a finite element scheme with triangulation. Say $u_h$ is the approximations found by the scheme and $u$ is the exact values at the nodes$-$which are here the vertices of the triangles.
I am trying to analyze the $H_1$ error of this approximation. Now for one dimension the part of it which is the seminorm would be $$|u-u_h|_{H_1}^2=\sum_{i=0}^{n-1}\int_{x_i}^{x_{i+1}}\left[u'(x)-\frac{u_{i+1}-u_i}{h}\right]^2dx$$
But I am dealing with a problem that is two dimensional. What would then be the corresponding seminorm formula? What I have thought so far is $$\sum_{T\in\tau_h}\int_T\|\nabla (u-u_h)\|_{L^2}^2$$ where $T$ is a triangle in the triangulation $\tau_h$. To this end, I thought that $$\|\nabla (u-u_h)\|_{L^2}^2=\left(\partial_x u-\frac{u_{i+1}-u_i}{|x_{i+1}-x_i|}\right)^2+\left(\partial_y u-\frac{u_{i+1}-u_i}{|y_{i+1}-y_i|}\right)^2$$
Is it correct? One of the potential bugs that is apparent to me is that it could very well be that two $x$ coordinates or two $y$ coordinates will be the same resulting in a zero in the denominator. In a program routine that I wrote, I just skipped these cases, that is when it comes across this type of situation, it just skips that triangle.
In one triangle, the above expression will be evaluated three times for the three vertices.
What I am trying to verify is that, every time I do a mesh refinement, this $H_1$-seminorm should halve (as per Cea's lemma). But I am not getting it.
One other question is when calculating norms as such, do we sum over all the elements (triangles here) as given here, or do we take the mean of all those individual norms over each element?