Hey there.
I am trying to generate a semicircular mesh with GMSH. The code to generate this semicircular mesh (.py) is shown:
import gmsh
from math import pi, cos, sin
gmsh.initialize()
gdim = 2
R = 0.1
m0 = 0.0025
p_center = gmsh.model.geo.addPoint(0, 0, 0, m0)
num_points = 100 # Points in the circumference
angle_increment = pi / (num_points - 1)
points = [p_center]
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]))
lines.append(gmsh.model.geo.addLine(points[-1], points[0]))
semicircle_loop = gmsh.model.geo.addCurveLoop(lines)
surface = gmsh.model.geo.addPlaneSurface([semicircle_loop])
domain_id = 1
gmsh.model.addPhysicalGroup(gdim, [surface], domain_id)
gmsh.model.setPhysicalName(gdim, domain_id, "domain")
gmsh.model.addPhysicalGroup(gdim - 1, [semicircle_loop], domain_id)
gmsh.model.setPhysicalName(gdim - 1, domain_id, "surface")
gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(gdim)
gmsh.write("malla_semircircular.msh")
gmsh.fltk.run()
gmsh.finalize()
When I try to use this mesh in a specific simulation, I get:
No physical group found for the domain.
Define the domain physical group.
- if dim=2, the domain is a surface
- if dim=3, the domain is a volume
Which, I believe, has to do with the fact that I have not defined a Physical Surface. I just don’t see how I should implement this Physical Surface.
Thanks in advance.