Hello,
I would like to generate a two-dimensional ring mesh with perfect radial symmetry. I manage to generate a ring mesh it with the following code
import argparse
import gmsh
import warnings
parser = argparse.ArgumentParser()
parser.add_argument("resolution")
args = parser.parse_args()
warnings.filterwarnings("ignore")
gmsh.initialize()
gmsh.model.add("my model")
c_r = [0, 0, 0]
c_R = [0, 0, 0]
r = 1
R = 2
resolution = (float)(args.resolution)
disk_r = gmsh.model.occ.addDisk( c_r[0], c_r[1], c_r[2], r, r )
disk_R = gmsh.model.occ.addDisk( c_R[0], c_R[1], c_R[2], R, R )
ring = gmsh.model.occ.cut( [(2, disk_R)], [(2, disk_r)] )
gmsh.model.occ.synchronize()
surfaces = gmsh.model.occ.getEntities(dim=2)
assert surfaces == ring[0]
disk_subdomain_id = 0
gmsh.model.addPhysicalGroup( surfaces[0][0], [surfaces[0][1]], disk_subdomain_id )
gmsh.model.setPhysicalName( surfaces[0][0], disk_subdomain_id, "disk" )
lines = gmsh.model.occ.getEntities(dim=1)
#these are the subdomain_ids with which the components will be read in read_2dmesh_ring.py
circle_r_subdomain_id = 1
circle_R_subdomain_id = 2
gmsh.model.addPhysicalGroup( lines[0][0], [lines[0][1]], circle_r_subdomain_id )
gmsh.model.setPhysicalName( lines[0][0], disk_subdomain_id, "circle_r" )
gmsh.model.addPhysicalGroup( lines[1][0], [lines[1][1]], circle_R_subdomain_id )
gmsh.model.setPhysicalName( lines[1][0], disk_subdomain_id, "circle_R" )
#set the resolution
distance = gmsh.model.mesh.field.add("Distance")
gmsh.model.mesh.field.setNumbers(distance, "FacesList", [surfaces[0][0]])
threshold = gmsh.model.mesh.field.add("Threshold")
gmsh.model.mesh.field.setNumber(threshold, "IField", distance)
gmsh.model.mesh.field.setNumber(threshold, "LcMin", resolution)
gmsh.model.mesh.field.setNumber(threshold, "LcMax", resolution)
gmsh.model.mesh.field.setNumber(threshold, "DistMin", 0.5 * r)
gmsh.model.mesh.field.setNumber(threshold, "DistMax", r)
circle_r_dist = gmsh.model.mesh.field.add("Distance")
circle_r_threshold = gmsh.model.mesh.field.add( "Threshold" )
gmsh.model.mesh.field.setNumber( circle_r_threshold, "IField", circle_r_dist )
gmsh.model.mesh.field.setNumber( circle_r_threshold, "LcMin", resolution )
gmsh.model.mesh.field.setNumber( circle_r_threshold, "LcMax", resolution )
gmsh.model.mesh.field.setNumber( circle_r_threshold, "DistMin", 0.1 )
gmsh.model.mesh.field.setNumber( circle_r_threshold, "DistMax", 0.5 )
minimum = gmsh.model.mesh.field.add("Min")
gmsh.model.mesh.field.setNumbers( minimum, "FieldsList", [threshold, circle_r_threshold] )
gmsh.model.mesh.field.setAsBackgroundMesh(minimum)
gmsh.model.occ.synchronize()
gmsh.model.mesh.generate(2)
gmsh.write("solution/mesh.msh")
which runs ok:
$ python3 generate_2dmesh_ring.py 0.1
Info : Meshing 1D...
Info : [ 0%] Meshing curve 1 (Ellipse)
Info : [ 60%] Meshing curve 2 (Ellipse)
Info : Done meshing 1D (Wall 0.00238325s, CPU 0.002387s)
Info : Meshing 2D...
Info : Meshing surface 2 (Plane, Frontal-Delaunay)
Info : Done meshing 2D (Wall 0.0338327s, CPU 0.033824s)
Info : 1229 nodes 2460 elements
Info : Writing 'solution/mesh.msh'...
Info : Done writing 'solution/mesh.msh'
However, as you can see from the image attached, the mesh is not radially symmetric: there are some ‘impurities,’ which break the radial symmetry (in red)
How may I modify the code above so as to obtain a mesh radially symmetric ?
FYI, no internet search provided an answer to this. AI tools suggested a method based on transfinite Surfaces which did not work.
I also tried to define a perfectly symmetric disk by approximating as a polygon: a hexagon is perfectly symmetric, but polygons with larger number of sides, even if multiples of three, are not.
Thank you