The geometry

It seems simple, and like there should be a built-in feature. I couldn’t find any formula when I googled, so I derived it myself and post it in hopes that whoever is reading it managed to find it. Future me will probably consult this page.

We want the ratio between the first division and it’s arc-length to be same as the last division and it’s arc-length. The arc-lengths are L1=2πR1θ and L2=2πR2θ, so their ratio is the same is as the ratio between the radii. We want to find a relationship between h1 and h2 that will yield the same ratio. h1=a and h2=arN

After forgetting everything I learned in middle school and looking it up on wikipedia, the formula for the total distance is

R2R1=a1rN1r

GMSH will solve for the a given an N. We need to provide the r that satisifies Findrs.t.aarN1=L2L1 which comes out to r=(R2R1)1/(N1)

gmsh Snippet

Here is the line where I use this in formula in a gmsh script:

// The radial edges
Transfinite Line {7, -8} = 18/Mesh.CharacteristicLengthFactor
    Using Progression (2.5/0.2)^(Mesh.CharacteristicLengthFactor/(17.0-1.0));
// The arc edges
Transfinite Line {1, 6} = 12/Mesh.CharacteristicLengthFactor Using Progression 1.0;
// Set the mode
Transfinite Surface {5} Alternate;

7 and 8 are the line segments with define the radially oriented sides, and segments 1 and 6 are the arcs. The arcs use a uniform progression, which means the meshed segments of 1 and 6 will have the different lengths discussed above. The section was defined to go from R1=0.2 to R2=2.5. The base case has 17 elements along the radius and 12 elements around the arc. The -8 is there to flip the line so that the progression goes in the same direction as 7; this needs to be verified by looking at the GUI.

This code will also automatically scale the number of elements based on the size factor. This is useful when scaling the mesh from the command line. Here’s the little snippet where a python script generates a new mesh for a convergence study:

os.system("gmsh ../quarter_plane.geo -2 -clscale {0} -o ../gen_{0}.msh ".format(clscale))
os.system("dolfin-convert ../gen_{0}.msh ../gen_{0}.xml".format(clscale))