What is the right way to create 3D meshes for FEniCS with Gmsh?

Hello!

I have some experience with FEniCS in 2D and now I’ve got a 3D problem. I was recommended to generate a mesh in Gmsh and convert it for dolfin by meshio.

I tried to follow this example but it failed (I guess the meshio interface has been changed since then, meshio._mesh.Mesh.cells returns a list while a dict is expected in the example).

I’ve described the domain geometry in a .geo file:

SetFactory("OpenCASCADE");

R = DefineNumber[0.0005, Min 0, Step 0.0001, Name "Parameters/Omega radius"];
Z = DefineNumber[0.0005, Min 0, Step 0.0001, Name "Parameters/Omega height"];
R_small = DefineNumber[0.0002 , Min 0, Step 0.00001, Name "Parameters/Laser beam radius"];
d = DefineNumber[0.0003 , Min 0, Step 0.00001, Name "Parameters/Distance"];


Cylinder(10) = {0, 0, 0, 0, 0, Z, R_small, 0.5*Pi};
Cylinder(20) = {-d, 0, 0, 0, 0, Z, R_small, 0.5*Pi};
	Rotate {{0, 0, 1}, {-d, 0, 0}, Pi/2} {
	  Volume{20}; 
	}
Box(30) = {-0, -0, 0, -d, R_small, Z};


Cylinder(11) = {0, 0, 0, 0, 0, Z, R, 0.5*Pi};
Cylinder(21) = {-d, 0, 0, 0, 0, Z, R, 0.5*Pi};
	Rotate {{0, 0, 1}, {-d, 0, 0}, Pi/2} {
	  Volume{21}; 
	}
Box(31) = {-0, -0, 0, -d, R, Z};

.

Now I would like to:

  1. Number (or tag) the boundary surfaces.
  2. Pass the generated mesh with the boundary markers to dolfin.

I would appreciate a minimal working example for maybe a very simple geometry just to get started.

See for instance: Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio - #174 by dokken