Forum Message

 

 

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.

In 2D geometry, over one domain, how to merge two meshes sharing a refined line

More
2 years 11 months ago #3778 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.
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
More
2 years 11 months ago #3779 by hvwahl
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:
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
More
2 years 11 months ago #3780 by Younghigh
Thank you very much. This helps me solve the problem.
Time to create page: 0.146 seconds