GMSH issue - Refinement

Hey there,

I created this semicircular mesh with a desired radius and element size in GMSH, as shown:

import gmsh
from math import pi, cos, sin

gmsh.initialize()
gdim = 2

R = 0.01  
m0 = 0.00005  

num_points = 300 
angle_increment = pi / (num_points - 1)  

points = []
for i in range(num_points):
    angle = i * angle_increment
    x = R * cos(angle)
    y = R * sin(angle)
    points.append(gmsh.model.geo.addPoint(x, y, 0, m0))

lines = []
for i in range(len(points) - 1):
    lines.append(gmsh.model.geo.addLine(points[i], points[i + 1]))

p_center = gmsh.model.geo.addPoint(0, 0, 0, m0)

lines.append(gmsh.model.geo.addLine(points[-1], p_center))

lines.append(gmsh.model.geo.addLine(p_center, points[0]))

semicircle_loop = gmsh.model.geo.addCurveLoop(lines)

surface = gmsh.model.geo.addPlaneSurface([semicircle_loop])

gmsh.model.geo.synchronize()

domain_id = 1
gmsh.model.addPhysicalGroup(gdim, [surface], domain_id)
gmsh.model.setPhysicalName(gdim, domain_id, "domain")

boundary_id = 2
gmsh.model.addPhysicalGroup(gdim - 1, lines, boundary_id)
gmsh.model.setPhysicalName(gdim - 1, boundary_id, "boundary")

gmsh.model.mesh.generate(gdim)
gmsh.write("malla_semicircular.msh")
gmsh.fltk.run()
gmsh.finalize()

As mentioned, this is a semicircular mesh. I was wondering how to refine the mesh near the origin, (0,0). I want the mesh to have more elements and nodes in this area than far away from this area. I’ve tried several stuff but I always run into the Curve Loop error, and I can’t solve it.

Thanks in advance.

This question is about gmsh without any interaction with dolfin/dolfinx, and thus must be asked at the gmsh support channel Issues · gmsh / gmsh · GitLab