# Correct usage of gmsh for 3D extruded geometry

Hi there, I’m trying to define a cylinder using the extrude command on gmsh. I’m not sure if I’m defining things correctly. This is the gmsh .txt:

``````z0=0.1;
L=20.0;
f=0.0;
g=9.81;
om1=f/2+Sqrt(f^2/4+2*g*z0/L^2);
T_final=2*Pi/om1;

Point(1) = {0 , 0 , 0 , 1};
Point(2) = {L , 0 , 0 , 1};
Point(3) = {0 , L , 0 , 1};
Point(4) = {-L , 0 , 0 , 1};
Point(5) = {0 , -L , 0 , 1};

Circle(1) = {2 , 1. , 3};
Circle(2) = {3. , 1. , 4};
Circle(3) = {4. , 1. , 5};
Circle(4) = {5. , 1. , 2};

Line Loop(1) = {2,3,4,1};
Plane Surface(1) = {1};

Extrude {0,0,T_final} {Surface{1}; Layers{3};}

Physical Volume(1) = {1};
``````

Then I run the gmsh program and 3D mesh it, after that, export the .msh file (cyl_gmsh5.msh) and then transform to .xdmf using:

``````import meshio
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
out_mesh = meshio.Mesh(points=mesh.points, cells={
cell_type: cells}, cell_data={"name_to_read": [cell_data]})
if prune_z:
out_mesh.prune_z_0()
return out_mesh
tetra_mesh = create_mesh(msh, "tetra")
meshio.write("cyl_gmsh5.xdmf", tetra_mesh)
``````

I get no error message doing this but I feel I’m missing something, maybe in the physical objects of the gmsh .txt.
Is this example ok?

I’m not sure what you are asking for here. I would suggest you inspect your resulting mesh (`cyl_gmsh5.xdmf`) in Paraview and check if it is like what you expect.

I found out that it’s working fine, thanks!