D = 1;
R = 0.5;

xmin = 0;
xmax = 19.5;

ymin = 0;
ymax = 12;

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) = {4, 4, zmin, lc};
*/
Point(5) = {4.5, 6.5, -1, lc};
Point(6) = {5.5, 6.5, -1, lc};

Point(7) = {5.5, 6.03, -1, lc};
Point(8) = {9.5, 6.03, -1, lc};

Point(9) = {9.5, 5.97, -1, lc};
Point(10) = {5.5, 5.97, -1, lc};

Point(11) = {5.5, 5.5, -1, lc};
Point(12) = {4.5, 5.5, -1, lc};

Point(13) = {4.5, 0, -1, lc};
Point(14) = {5.5, 0, -1, lc};
Point(15) = {9.5, 0, -1, lc};

Point(16) = {19.5, 5.5, -1, lc};
Point(17) = {19.5, 5.97, -1, lc};
Point(18) = {19.5, 6.03, -1, lc};
Point(19) = {19.5, 6.5, -1, lc};

Point(20) = {9.5, 12, -1, lc};
Point(21) = {5.5, 12, -1, lc};
Point(22) = {4.5, 12, -1, lc};

Point(23) = {0, 6.5, -1, lc};
Point(24) = {0, 5.5, -1, lc};

Point(25) = {9.5, 5.5, -1, lc};
Point(26) = {9.5, 6.5, -1, lc};


Line(1) = {1, 13};
Line(2) = {13, 14};
Line(3) = {14, 15};
Line(4) = {15, 2};

Line(5) = {5, 6};
Line(6) = {6, 7};
Line(7) = {7, 8};
Line(8) = {8, 9};
Line(9) = {9, 10};
Line(10) = {10, 7};
Line(11) = {10, 11};
Line(12) = {11, 12};
Line(13) = {12, 5};

Line(14) = {12, 13};
Line(15) = {14, 11};
Line(16) = {15, 25};
Line(17) = {20, 26};
Line(18) = {26, 8};
Line(19) = {9, 25};
Line(20) = {21, 6};
Line(21) = {22, 5};
Line(22) = {23, 5};
Line(23) = {24, 12};
Line(24) = {11, 25};
Line(25) = {6, 26};
Line(26) = {16, 25};
Line(27) = {9, 17};
Line(28) = {8, 18};
Line(29) = {26, 19};

Line(30) = {2, 16};
Line(31) = {16, 17};
Line(32) = {17, 18};
Line(33) = {18, 19};
Line(34) = {19, 3};

Line(35) = {3, 20};
Line(36) = {20, 21};
Line(37) = {21, 22};
Line(38) = {22, 4};

Line(39) = {4, 23};
Line(40) = {23, 24};
Line(41) = {24, 1};


// Definition of line loop and surface
Line Loop(1) = {1, -14, -23, 41};
Plane Surface(1) = {1};

Line Loop(2) = {2, 15, 12, 14};
Plane Surface(2) = {2};

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

Line Loop(4) = {4, 30, 26, -16};
Plane Surface(4) = {4};

Line Loop(5) = {-26, 31, -27, 19};
Plane Surface(5) = {5};

Line Loop(6) = {27, 32, -28, 8};
Plane Surface(6) = {6};

Line Loop(7) = {28, 33, -29, 18};
Plane Surface(7) = {7};

Line Loop(8) = {29, 34, 35, 17};
Plane Surface(8) = {8};

Line Loop(9) = {25, -17, 36, 20};
Plane Surface(9) = {9};

Line Loop(10) = {7, -18, -25, 6};
Plane Surface(10) = {10};

Line Loop(11) = {24, -19, 9, 11};
Plane Surface(11) = {11};

Line Loop(12) = {23, 13, -22, 40};
Plane Surface(12) = {12};

Line Loop(13) = {22, -21, 38, 39};
Plane Surface(13) = {13};

Line Loop(14) = {5, -20, 37, 21};
Plane Surface(14) = {14};

Line Loop(15) = {-9, -8, -7, -10};
Plane Surface(15) = {15};



// Definition of number of nodes on lines
Transfinite Line{1, 23, 22, 38} = 60 Using Progression 1.13;
Transfinite Line{2, 12, 5, 37} = 50 ;
Transfinite Line{3, 24, 9, 7, 25, 36} = 120 Using Progression 1.065;
Transfinite Line{4, 26, 27, 28, 29, 35} = 60 Using Progression 1.13;
Transfinite Line{41, 14, 15, 16, 30} = 50;
Transfinite Line{40, 13, 10, 6, 11, 8, 19, 18, 31, 32, 33} = 60 Using Progression 1.13;
Transfinite Line{39, 21, 20, 17, 34} = 50;

// Definition of the corners of the mesh and creation of a structured
//hexahedral mesh
Transfinite Surface{1} = {1, 13, 12, 24};
Recombine Surface{1};

Transfinite Surface{2} = {13, 14, 11, 12};
Recombine Surface{2};

Transfinite Surface{3} = {14, 15, 25, 11};
Recombine Surface{3};

Transfinite Surface{4} = {15, 2, 16, 25};
Recombine Surface{4};

Transfinite Surface{5} = {25, 16, 17, 9};
Recombine Surface{5};

Transfinite Surface{6} = {9, 17, 18, 8};
Recombine Surface{6};

Transfinite Surface{7} = {8, 18, 19, 26};
Recombine Surface{7};

Transfinite Surface{8} = {26, 19, 3, 20};
Recombine Surface{8};

Transfinite Surface{9} = {6, 26, 20, 21};
Recombine Surface{9};

Transfinite Surface{10} = {7, 8, 26, 6};
Recombine Surface{10};

Transfinite Surface{11} = {11, 25, 9, 10};
Recombine Surface{11};

Transfinite Surface{12} = {24, 12, -5, 23};
Recombine Surface{12};

Transfinite Surface{13} = {23, 5, 22, 4};
Recombine Surface{13};

Transfinite Surface{14} = {5, 6, 21, 22};
Recombine Surface{14};

Transfinite Surface{15} = {10, 9, 8, 7};
Recombine Surface{15};

// Extrusion in the third dimension
Extrude{0,0,zmax-zmin}{
Surface{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
Layers{nz};Recombine;
}

/*
// Definition of surfaces for boundary conditions
Physical Surface("inlet") = {326, 304, 62};
Physical Surface("outlet") = {208, 186, 164, 142, 120};
Physical Surface("top") = {322, 344, 234, 212};
Physical Surface("bottom") = {50, 72, 94, 116};
Physical Surface("cylinder") ={336, 296, 80, 260, 282};
Physical Surface("plate") ={370, 15 248, 278, 371, 172, };
Physical Surface("frontAndBackPlanes") = {};
*/
// Definition of a volume
Physical Volume("channel") = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

Mesh 3;
Save "square_cylinder.msh";









