# meshes for multiple subdomains

How to generate meshes for multiple subdomains so that its normal vector points from one area to another? Can the processing methods in the tutorial solve this problem?

The example in the tutorial ：
geometry = SplineGeometry()

pnts = [ (0,0), (1,0), (1,1), (0,1), (2,0), (2,1)]
pnums = [geometry.AppendPoint(*p) for p in pnts]
lines = [ (pnums[0],pnums[1],1,1,0), (pnums[1],pnums[2],2,1,2),
(pnums[2],pnums[3],3,1,0), (pnums[3],pnums[0],4,1,0), (pnums[1], pnums[4],5,2,0),
(pnums[4],pnums[5],6,2,0), (pnums[5],pnums[2],7,2,0)]
for p1,p2,bc,left,right in lines:
geometry.Append( [“line”, p1, p2], bc=bc, leftdomain=left, rightdomain=right)
return
mesh = Mesh(twoDomain().GenerateMesh (maxh=0.1))
Draw(mesh)

You can use leftdomain and rightdomain arguments for this, see here:
https://ngsolve.org/docu/latest/i-tutorials/unit-4.1-geom2d/geom2d.html

normal always points into rightdomain

Best

Thanks for your careful reply. However, I still think the interface problem is difficult to deal with. Will you present some examples of handling interface problem in tutorials? if so, it will bring a lot of help to beginners like me.

best.

The solution you provided does not seem to be able to handle the following subdomains

def twoDomain():
geo = SplineGeometry()
p2=(0,2),
bc=“rectangle”,
leftdomain=1,
rightdomain=0)

p2=(0,2),
bc=“rectangle”,
leftdomain=2,
rightdomain=0)

geo.SetMaterial (1, “outer”)
geo.SetMaterial (2, “inner”)
return geo

ngmesh = Mesh(twoDomain().GenerateMesh(maxh=0.1))
Draw(ngmesh)

Best

first your rectangles have 0 width, second if you want to have multiple domains for now you need to define the splines of the geometry manually. See for example here:

def twoDomain():
geo = SplineGeometry()
p2=(1,2),
bc=“rectangle”,
leftdomain=1,
rightdomain=0)