2D Geometry with partly shared edge

More
4 years 7 months ago #2518 by creativeworker
Hello,

we would like to build a 2D Geometry (for example two nested rectangles) that represent one half of a symmetric problem, so the inner rectangle is completely shifted to the edge of the sourounding rectangle. At that moment we cannot mesh the geometry.
How could we implement this?
Code:
from netgen.geom2d import * from ngsolve import * geo = SplineGeometry() geo.AddRectangle ( (0,0), (2,2), bcs=["b","r","t","l"], leftdomain=1) geo.AddRectangle ( (0,0.5), (1,1.5), bcs=["b2","r2","t2","l2"], leftdomain=2, rightdomain=1) geo.SetMaterial (1, "outer") geo.SetMaterial (2, "inner") mesh = Mesh(geo.GenerateMesh(maxh=0.1))
More
4 years 7 months ago #2523 by mneunteufel
Hi creativeworker,

to construct such a mesh you need to specify the points and lines by hand
Code:
from netgen.geom2d import * from ngsolve import * geo = SplineGeometry() pnts = [ (0,0), (2,0), (2,2), (0,2), (0,1.5), (0,0.5), (1,0.5), (1,1.5)] pind = [ geo.AppendPoint(*pnt) for pnt in pnts ] geo.Append(['line',pind[0],pind[1]],leftdomain=1,rightdomain=0,bc="b") geo.Append(['line',pind[1],pind[2]],leftdomain=1,rightdomain=0,bc="r") geo.Append(['line',pind[2],pind[3]],leftdomain=1,rightdomain=0,bc="t") geo.Append(['line',pind[3],pind[4]],leftdomain=1,rightdomain=0,bc="l") geo.Append(['line',pind[4],pind[5]],leftdomain=2,rightdomain=0,bc="l") geo.Append(['line',pind[5],pind[0]],leftdomain=1,rightdomain=0,bc="l") geo.Append(['line',pind[5],pind[6]],leftdomain=2,rightdomain=1,bc="b2") geo.Append(['line',pind[6],pind[7]],leftdomain=2,rightdomain=1,bc="r2") geo.Append(['line',pind[7],pind[4]],leftdomain=2,rightdomain=1,bc="t2") geo.SetMaterial (1, "outer") geo.SetMaterial (2, "inner") mesh = Mesh(geo.GenerateMesh(maxh=0.1))

Best,
Michael
The following user(s) said Thank You: creativeworker
Time to create page: 0.107 seconds