I would write for your second term intalledges(Th)((nTonEdge-1)*real(mean(w1)*N.x+mean(w2)*N.y<0.)*abs(N.x*mean(v1old)+N.y*mean(v2old))*(-jump(v1)*vv1-jump(v2)*vv2))
Thank sir for your replies. But why you are ignoring jump(vv1) and jump(vv2) sir?. Does it has any reason??. In weak formulation in continuous case, theta=0 on boundary of the domain (given). But in discontinuous case, jump(theta)=theta^int-theta^ext. It this may be theta^ext=0 . So, theta^int only there it the bilinear form.
One more that i observe you have not written boundary edges term. But why?. If i am not wrong it is full boundary sir. For nTonEdge=1, term that you wrote becomes zero sir. So, no contribution of boundary are there.
But why you are ignoring jump(vv1) and jump(vv2) sir?.
There is no jump(theta) appearing in your formulation.
theta_int=theta
theta=0 on boundary of the domain (given).
Since theta is given and vanishes on the boundary, it follows that the boundary term vanishes in your formulation. Thus there is nothing to discretize.
One more that i observe you have not written boundary edges term.
You said that theta vanishes on the boundary \partial\Omega. It follows that there is no boundary term.
If theta does not vanish on the boundary, you can add boundary terms by writing another intalledges with factor 2-nTonEdge.
The most simple is +int1d(Th)(real(v1old*N.x+v2old*N.y<0.)*abs(N.x*v1old+N.y*v2old)*(v1*vv1+v2*vv2))
Note the change of sign, because jump(v)=v_ext-v_int, not the opposite.
Here all quantities are evaluated on the interior side of the boundary.
But it depends on the interpretation of your variational formulation for boundary terms.
– If you want that on the boundary \{v\}=v_{int} then the previous formula is good.
– If you want that on the boundary v_{ext}=0, \{v\}=(v_{int}+v_{ext})/2=v_{int}/2 then you should use the intalledges formula.
You must not divide by nTonEdge (or equivalently divide by 2)
because your variational formulation contains two contributions at each internal edge, one from each triangle on each side.
You divide by 2 when you want a single contribution for each edge (or the average of the two contributions from each side if these contributions differ).