Integrate the jump of flux on the edges element-wisely

Hi,

I am trying to apply explicit residual estimation for adaptive meshing. The equation I am solving for is

-div a grad u = f

For each element, I need to calculate half the summation of

(length of e) * ||-a * (jump of the normal derivative of u_h on e)||_{L^2(e)}

for each edge (denoted as e) of the element.

I set graduh_x and graduh_y by

V2 = L2(mesh, order = deg-1)

graduh_x = GridFunction(V2)
graduh_y = GridFunction(V2) 

graduh_x.Set(uh.Deriv()[0])
graduh_y.Set(uh.Deriv()[1])

I then set h_edge by

F = specialcf.JacobianMatrix(2)
tau = specialcf.tangential(2)
h_edge = Norm(F*tau)

I tried

eta_edge = 0.5* Integrate(-h_edge*d*((graduh_x-graduh_x.Other())*n[0]+(graduh_y-graduh_y.Other())*n[1]), mesh, VOL, skeleton=True, element_wise=True)

as well as (according to a forum page)

eta_edge = 0.5* Integrate(-h_edge*d*(graduh_x*n[0]+graduh_y*n[1])*dx(element_boundary=True), mesh, VOL, element_wise=True)

However, neither works.
Does anyone have an idea how to formulate this eta_edge? Thanks in advance.

Seems that I cannot delete the post, but the problem has been solved. :slight_smile: