D = 0.0016;
R = 0.0008;

xmin = -0.384;
xmax = 0.384;

ymin = 0;
ymax = 0.320;

zmin = -1;
zmax = 1;

lc = 0.1;

// Number of nodes in x, y and z directions
nx = 100;
ny = 100;
nz = 1;

Point(1) = {xmin, ymin, zmin, lc};
Point(2) = {xmax, ymin, zmin, lc};
Point(3) = {xmax, ymax, zmin, lc};
Point(4) = {xmin, ymax, zmin, lc};

Point(5) = {-0.224, 0.160, zmin, lc};

Point(6) = {-0.224+R, 0.160-R, -1, lc};
Point(7) = {-0.224+R, 0.160+R, -1, lc};
Point(8) = {-0.224-R, 0.160+R, -1, lc};
Point(9) = {-0.224-R, 0.160-R, -1, lc};

Point(10) = {-0.224-R, 0, -1, lc};
Point(11) = {-0.224+R, 0, -1, lc};
Point(12) = {0.384, 0.160-R, -1, lc};
Point(13) = {0.384, 0.160+R, -1, lc};
Point(14) = {-0.224+R, 0.320, -1, lc};
Point(15) = {-0.224-R, 0.320, -1, lc};
Point(16) = {-0.384, 0.160+R, -1, lc};
Point(17) = {-0.384, 0.160-R, -1, lc};

Circle(1) = {6, 5, 7};
Circle(2) = {7, 5, 8};
Circle(3) = {8, 5, 9};
Circle(4) = {9, 5, 6};

Line(5) = {1, 10};
Line(6) = {10, 11};
Line(7) = {11, 2};
Line(8) = {2, 12};
Line(9) = {12, 13};
Line(10) = {13, 3};
Line(11) = {3, 14};
Line(12) = {14, 15};
Line(13) = {15, 4};
Line(14) = {4, 16};
Line(15) = {16, 17};
Line(16) = {17, 1};

Line(17) = {9, 17};
Line(18) = {9, 10};
Line(19) = {6, 11};
Line(20) = {6, 12};
Line(21) = {7, 13};
Line(22) = {7, 14};
Line(23) = {8, 15};
Line(24) = {8, 16};

// Definition of line loop and surface
Line Loop(1) = {5,-18,17,16};
Plane Surface(1) = {1};

Line Loop(2) = {6,-19,-4,18};
Plane Surface(2) = {2};

Line Loop(3) = {7,8,-20,19};
Plane Surface(3) = {3};

Line Loop(4) = {20,9,-21,-1};
Plane Surface(4) = {4};

Line Loop(5) = {21,10,11,-22};
Plane Surface(5) = {5};

Line Loop(6) = {-2,22,12,-23};
Plane Surface(6) = {6};

Line Loop(7) = {-24,23,13,14};
Plane Surface(7) = {7};

Line Loop(8) = {-17,-3,24,15};
Plane Surface(8) = {8};

// Definition of number of nodes on lines
Transfinite Line{-5, 17, 24, 13} = 60 Using Progression 1.13;
Transfinite Line{6, 4, 2, 12} = 50 ;
Transfinite Line{7, 20, 21, -11} = 120 Using Progression 1.065;
Transfinite Line{16, 18, 19, -8} = 60 Using Progression 1.13;
Transfinite Line{15, 3, 1, 9} = 50;
Transfinite Line{-14, 23, 22, 10} = 60 Using Progression 1.13;


// Definition of the corners of the mesh and creation of a structured
//hexahedral mesh
Transfinite Surface{1} = {1,10,9,17};
Recombine Surface{1};

Transfinite Surface{2} = {10,11,6,9};
Recombine Surface{2};

Transfinite Surface{3} = {11,2,12,6};
Recombine Surface{3};

Transfinite Surface{4} = {6,12,13,7};
Recombine Surface{4};

Transfinite Surface{5} = {7,13,3,14};
Recombine Surface{5};

Transfinite Surface{6} = {8,7,14,15};
Recombine Surface{6};

Transfinite Surface{7} = {16,8,15,4};
Recombine Surface{7};

Transfinite Surface{8} = {17,9,8,16};
Recombine Surface{8};


// Extrusion in the third dimension
Extrude{0,0,zmax-zmin}{
Surface{1,2,3,4,5,6,7,8};
Layers{nz};Recombine;
}

// Definition of surfaces for boundary conditions
Physical Surface("inlet") = {177,199,45};
Physical Surface("outlet") = {125,103,81};
Physical Surface("top") = {173,147,129};
Physical Surface("bottom") = {33,55,77};
Physical Surface("cylinder") = {143,111,63,191};
Physical Surface("frontAndBack") = {5,4,3,90,134,112,107,85,6,156,133,151,2,8,1,178,37,59,68,46,200,165,41,7,155};

// Definition of a volume
Physical Volume("channel") = {1,2,3,4,5,6,7,8};

Mesh 3;
Save "new_cylinder.msh";









