# Numerically Approximate $[n\cdot\nabla u_h],$ without using Matlab function

Suppose that $\Omega\subset\mathbb{R}^2$ and we define the triangulation $\mathcal{T}_h$ where, $$\mathcal{T}_h=\bigcup_{i=1}^nK_i$$, with $K_i$ are triangles.

We have the explicit a posteriori estimator for elliptic problems, $$\eta_K(u_h)=h_K\|f+\Delta u_h\|_{L_{2}(K)}+\frac{1}{2}h_K^{1/2}\|[n\cdot\nabla u_h]\|_{L_{2}(\partial K\backslash\partial\Omega)}$$ Here $[n\cdot\nabla u_h]$ denotes the jump in the normal derivative of $u_h$ on the interior edges of the element $K.$

$u_h$ is the finite element solution.

I want to numerically approximate $[n\cdot\nabla u_h],$ without using Matlab function pdejmps

• Why? And how are you computing $u_h$? – Christian Clason Nov 15 '16 at 15:58
• $u_h$ is linear. Suppose that I have the value of $u_h,$ how can I calculate $[n\cdot\nabla u_h]?$ – math_lover Nov 15 '16 at 16:04
• I meant, why don't you want to use pdejmps? What kind of FE infrastructure (mesh, connectivity, assembly etc.) do you have in place? – Christian Clason Nov 15 '16 at 16:10
• Why would you need to do this without using a particular MATLAB function, unless this were a homework, test, or job interview problem, in which case why didn't you tell us so? – Mark L. Stone Nov 16 '16 at 5:52
• @MarkL.Stone Because I work in python and I want to know how is calculated! – math_lover Nov 16 '16 at 7:42

Since you mention that your elements are linear, the gradient of $u_h$ on each cell is constant. As a consequence, if you have an edge $e$ between cells $K$ and $K'$, with $\vec n$ being the normal to the edge pointing from $K$ to $K'$, then $$[\vec n \cdot \nabla u_h] = \vec n \cdot \left(\nabla u_h|_{K'} - \nabla u_h|_K\right).$$ Furthermore, $$\|[\vec n \cdot \nabla u_h]\|_e^2 = \left|\vec n \cdot \left(\nabla u_h|_{K'} - \nabla u_h|_K\right)\right|^2 h_e,$$ where $h_e$ is the length of edge $e$. Equivalent formulas are true for faces in 3d.
If you have higher order elements, then the situation is not as trivial. Rather, you need to typically compute the integral via quadrature, which requires evaluating the jump term at the quadrature points along the edge. To do this, you need to evaluate both $\nabla u_h|_K$ and $\nabla u_h|_{K'}$ at the quadrature points along the edge.