How to mesh on a semi-circumference

More
3 years 7 months ago #3781 by Younghigh
Dear all,


I wonder how to mesh on a semi-circumference
[tex]x^2+y^2=0.5^2,\quad y\geq 0.[/tex]

In fact, I can code like
Code:
geo.AddCircle(c=(0,0), r=0.5, maxh=0.01, leftdomain=1, rightdomain=1)
to get a mesh on an entire circumference.

I can also code like
Code:
p1,p2,p3,p4,p5= [ geo.AppendPoint(x,y) for x,y in [(0.5,0), (0.5,0.5), (0,0.5), (-0.5,0.5), (-0.5,0)] ] geo.Append (["spline3", p1, p2, p3], maxh=0.01, leftdomain=1, rightdomain=1) geo.Append (["spline3", p5, p4, p3], maxh=0.01, leftdomain=1, rightdomain=1)
to get a mesh on the semi-circumference. However, this method seems little awkward and also has some restricts in combined meshes, which may cause the global mesh failure.

So, is there a simple method to mesh on the semi-circumference just like meshing on an entire circumference? Please help me. Thank you very much.

Best,

Di Yang
More
3 years 7 months ago #3783 by mneunteufel
Hi Di Yang,

with the CSG2D tools you can add, subtract, etc. primitives to form a semi-circumference without splines:
Code:
from ngsolve import * from netgen.geom2d import CSG2d, Circle, Rectangle geo = CSG2d() circle = Circle( center=(0,0), radius=0.5, mat="circle", bc="bnd" ) rect = Rectangle( pmin=(-2,-1), pmax=(2,0), bc="cut" ) geo.Add(circle - rect) mesh = Mesh(geo.GenerateMesh(maxh=0.3)) mesh.Curve(2) Draw(mesh)

Best
Michael
More
3 years 7 months ago #3784 by christopher
(which internally generates the exact same splines ;) )
Time to create page: 0.115 seconds