0

I am trying to generate a quad mesh grid for an annular disc geometry. I was able to generate this mesh for a rectangular shape using gmsh:

import gmsh
import sys

gmsh.initialize()

gmsh.model.add("t1")

lc = 1e-2
p1 = gmsh.model.geo.addPoint(0, 0, 0, lc, 1)
p2 = gmsh.model.geo.addPoint(0.02, 0, 0, lc, 2)
p3 = gmsh.model.geo.addPoint(0.02, 0.02, 0, lc, 3)
p4 = gmsh.model.geo.addPoint(0, 0.02, 0, lc, 4)

gmsh.model.geo.addLine(p1, p2, 1)
gmsh.model.geo.addLine(p2, p3, 2)
gmsh.model.geo.addLine(p3, p4, 3)
gmsh.model.geo.addLine(p4, p1, 4)
gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 1)

gmsh.model.geo.addPlaneSurface([1], 1)

# the number of synchronization points.
gmsh.model.geo.synchronize()

gmsh.option.setNumber("Mesh.MeshSizeMin", 0.001)
gmsh.option.setNumber("Mesh.MeshSizeMax", 0.003)
gmsh.model.mesh.setAlgorithm(2,1,8)
gmsh.model.mesh.generate(2)
gmsh.model.mesh.recombine()

# ... and save it to disk
gmsh.write("rect.stl")

if '-nopopup' not in sys.argv:
    gmsh.fltk.run()

gmsh.finalize()

which results in this mesh: Quad mesh for rectangular shape

I want to generate a quad mesh grid like this:

Quad mesh for disc

Here is the code for generating the mesh for the disc (I have included a quarter of the disc for simplification):

import gmsh
import sys

# Before using any functions in the Python API, Gmsh must be initialized:
gmsh.initialize()

gmsh.model.add("t1")

lc = 1e-2
p1 = gmsh.model.geo.addPoint(0, 0, 0, lc, 1)
p2 = gmsh.model.geo.addPoint(0.02, 0, 0, lc, 3)
p3 = gmsh.model.geo.addPoint(0, 0.02, 0, lc, 2)
p4 = gmsh.model.geo.addPoint(0, 0.01, 0, lc, 5)
p5 = gmsh.model.geo.addPoint(0.01, 0, 0, lc, 4)
p6 = gmsh.model.geo.addPoint(-0.02, 0, 0, lc, 6)
p7 = gmsh.model.geo.addPoint(-0.01, 0, 0, lc, 7)
p8 = gmsh.model.geo.addPoint(0, -0.02, 0, lc, 8)
p9 = gmsh.model.geo.addPoint(0, -0.01, 0, lc, 9)
# 
gmsh.model.geo.addCircleArc(p2, p1, p3, 1)
gmsh.model.geo.addLine(p3, p4, 2)
gmsh.model.geo.addCircleArc(p4, p1, p5, 3)
gmsh.model.geo.addLine(p5, p2, 4)
gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 1)

gmsh.model.geo.addPlaneSurface([1], 1)

# the number of synchronization points.
gmsh.model.geo.synchronize()

gmsh.option.setNumber("Mesh.MeshSizeMin", 0.001)
gmsh.option.setNumber("Mesh.MeshSizeMax", 0.003)
gmsh.model.mesh.setAlgorithm(2,1,8)
gmsh.model.mesh.generate(2)
gmsh.model.mesh.recombine()

# ... and save it to disk
gmsh.write("disc.stl")

if '-nopopup' not in sys.argv:
    gmsh.fltk.run()

gmsh.finalize()

which results in an irregular mesh: Quad mesh for disc

How do I accomplish the same mesh grid in picture 2?

H.H
  • 188
  • 1
  • 13

1 Answers1

0

Gmsh calls these transfinite surfaces, see doc. It has a well commented example, but here's for your case. Add:

Transfinite Curve{1} = numpts;
Transfinite Curve{3} = numpts;

with numpts the number of points you want on the arcs. Likewise, set

Transfinite Curve{2} = numpts;
Transfinite Curve{4} = numpts;

or

Transfinite Curve{2} = numpts Using Progression 1.2;
Transfinite Curve{-1,4} = numpts Using Progression 1.2;

if you want geometric progression on the straight boundary pieces. The 4th curve is walked in reverse or the sizes will not match. You can probably change 1.2 to any other geometric rate. Then, you define the surface as transfinite:

Transfinite Surface{1} = {1, 2, 3, 4};

and use Recombine to request quadrilaterals:

Recombine Surface{1};
Sardine
  • 153
  • 5