- Thank you received: 0
In 2D geometry, over one domain, how to merge two meshes sharing a refined line
3 years 7 months ago #3778
by Younghigh
In 2D geometry, over one domain, how to merge two meshes sharing a refined line was created by Younghigh
Dear all,
I tried to create one square mesh including a refined line (0,0.5)->(0.5,1). Note that this is one domain, and we do not want to create two domains.
Now two independent meshes were generated, but I have no idea how to merge the two meshes sharing the line (0,0.5)->(0.5,1). Please help me. Thank you.
Best,
Di Yang
I tried to create one square mesh including a refined line (0,0.5)->(0.5,1). Note that this is one domain, and we do not want to create two domains.
Now two independent meshes were generated, but I have no idea how to merge the two meshes sharing the line (0,0.5)->(0.5,1). Please help me. Thank you.
Code:
geo1 = SplineGeometry()
p1,p2,p3,p4,p5 = [ geo1.AppendPoint(x,y) for x,y in [ (0,0.5), (0,0), (1,0), (1,1), (0.5,1)] ]
geo1.Append (["line", p1, p2])
geo1.Append (["line", p2, p3])
geo1.Append (["line", p3, p4])
geo1.Append (["line", p4, p5])
geo1.Append (["line", p5, p1], maxh=0.01)
mesh1 = Mesh(geo1.GenerateMesh(maxh=0.1))
geo2 = SplineGeometry()
p1,p2,p3 = [ geo2.AppendPoint(x,y) for x,y in [ (0,1), (0,0.5), (0.5,1)] ]
geo2.Append (["line", p1, p2])
geo2.Append (["line", p2, p3], maxh=0.02)
geo2.Append (["line", p3, p1],)
mesh2 = Mesh(geo2.GenerateMesh(maxh=0.1))
Best,
Di Yang
3 years 7 months ago #3779
by hvwahl
Replied by hvwahl on topic In 2D geometry, over one domain, how to merge two meshes sharing a refined line
Hi Di Yang,
it's best to generate the mesh in one go and tell the interior line, that you have the bulk domain on both sides:
Best wishes,
Henry
it's best to generate the mesh in one go and tell the interior line, that you have the bulk domain on both sides:
Code:
from netgen.geom2d import SplineGeometry
from ngsolve import Mesh
geo = SplineGeometry()
p1, p2, p3, p4, p5, p6 = [geo.AppendPoint(x, y) for x, y in [
(0, 0.5), (0, 0), (1, 0), (1, 1), (0.5, 1), (0, 1)]]
geo.Append(["line", p1, p2])
geo.Append(["line", p2, p3])
geo.Append(["line", p3, p4])
geo.Append(["line", p4, p5])
geo.Append(["line", p5, p1], leftdomain=1, rightdomain=1, maxh=0.01)
geo.Append(["line", p5, p6])
geo.Append(["line", p6, p1])
mesh = Mesh(geo.GenerateMesh(maxh=0.1))
Best wishes,
Henry
Time to create page: 0.119 seconds