## We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

#### Notice

The forum is in read only mode.

# Normal derivative for surface integral for H1 space

1 year 2 months ago - 1 year 2 months ago #4653 by pmaurerl
Hi,

I'd like to consider a coupling term between p1 (existing on region 1) and p2 (existing on region 2) on the interface of the region 1 and 2 of the form int(p1_ grad(p2) * n2 ds , where p1_ is the test function and n2 the normal vector on the interface of region 2.

However, when using the trace-operator, the integral vanishes. I think, that's because due to the trace-operator the tangential derivative is computed on the surface and thus the product with the normal vector is zero.

Here a minimal working example of how I am trying to achieve that:

import netgen.gui
%gui tk
from netgen.geom2d import *
from ngsolve import *

geo = SplineGeometry()
geo.AddRectangle((0,0), (2,2),
bcs=["b","r","t","l"],
leftdomain=1)
geo.AddRectangle((1,0.9), (1.3,1.4),
bcs=["b2","r2","t2","l2"],
leftdomain=2, rightdomain=1)
geo.SetMaterial (1, "outer")
geo.SetMaterial (2, "inner")
mesh = Mesh(geo.GenerateMesh(maxh=0.25))
n = specialcf.normal(mesh.dim)

#Draw(mesh)

fes1 = H1(mesh, definedon="inner")
fes2 = H1(mesh, definedon="outer")

fes = fes1 * fes2
(p1_, p2_), (p1, p2) = fes.TnT()

K = BilinearForm(fes)
K += p1_.Trace() * 1 * grad(p2).Trace() * n * ds(definedon=mesh.Boundaries("b2|r2"))
K.Assemble()

# visualize matrix etries
import matplotlib.pyplot as plt
import scipy.sparse as sp
A = sp.csr_matrix(K.mat.CSR())
plt.rcParams = (4,4)
plt.spy(A)
plt.show()

What is the correct way to define the surface integral?

Best regards,
Paul
Last edit: 1 year 2 months ago by pmaurerl.
Time to create page: 0.136 seconds