D = 1;
R = 0.5;

xmin = 0;
xmax = 20;

ymin = 0;
ymax = 8;

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(6) = {4+R, 4-R, -1, lc};
Point(7) = {4+R, 4+R, -1, lc};
Point(8) = {4-R, 4+R, -1, lc};
Point(9) = {4-R, 4-R, -1, lc};

Point(10) = {4-R, 0, -1, lc};
Point(11) = {4+R, 0, -1, lc};
Point(12) = {20, 4-R, -1, lc};
Point(13) = {20, 4+R, -1, lc};
Point(14) = {4+R, 8, -1, lc};
Point(15) = {4-R, 8, -1, lc};
Point(16) = {0, 4+R, -1, lc};
Point(17) = {0, 4-R, -1, lc};

/*
Point(18) = {4.25, 3.75, -1, lc};
Point(19) = {4.25, 4.25, -1, lc};
Point(20) = {3.75, 4.25, -1, lc};
Point(21) = {3.75, 3.75, -1, lc};
*/

// COORECTION
Point(18) = {4.3, 3.7, -1, lc};
Point(19) = {4.3, 4.3, -1, lc};
Point(20) = {3.7, 4.3, -1, lc};
Point(21) = {3.7, 3.7, -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) = {17, 9};
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};

Line(25) = {8, 20};
Line(26) = {7, 19};
Line(27) = {6, 18};
Line(28) = {9, 21};
Line(29) = {20, 21};
Line(30) = {20, 19};
Line(31) = {19, 18};
Line(32) = {18, 21};


// 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};

/*
Line Loop(9) = {30,-26,2,25};
Plane Surface(9) = {9};

Line Loop(10) = {1,26,31,-27};
Plane Surface(10) = {10};

Line Loop(11) = {-32,-27,-4,28};
Plane Surface(11) = {11};

Line Loop(12) = {-3,25,29,-28};
Plane Surface(12) = {12};

// ADDITION
Line Loop(13) = {31,32,-29,30};
Plane Surface(13) = {13};
*/

/*
// Definition of number of nodes on lines
Transfinite Line{-5, 17, 24, 13} = 60 Using Progression 1.13;
Transfinite Line{6, 4, 2, 12, 32, 30} = 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, 29, 31} = 50;
Transfinite Line{-14, 23, 22, 10} = 60 Using Progression 1.13;
*/



// CORRECTION
// Definition of number of nodes on lines
Transfinite Line{-5, -17, 24, 13} = 60 Using Progression 1.05;
//Transfinite Line{6, 4, 2, 12, 32, 30} = 50 ;
Transfinite Line{6, 4, 2, 12} = 50 ;
Transfinite Line{7, 20, 21, -11} = 120 Using Progression 1.03;
Transfinite Line{16, 18, 19, -8} = 60 Using Progression 1.05;
//Transfinite Line{15, 3, 1, 9, 29, 31} = 50;
Transfinite Line{15, 3, 1, 9} = 50;
Transfinite Line{-14, 23, 22, 10} = 60 Using Progression 1.05;
//Transfinite Line{25, 26, 27, 28} = 30 Using Progression 1.03;


// 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};

/*
Transfinite Surface{9} = {20,19,7,8};
Recombine Surface{9};

Transfinite Surface{10} = {18,6,7,19};
Recombine Surface{10};

Transfinite Surface{11} = {21,9,6,18};
Recombine Surface{11};

Transfinite Surface{12} = {21,9,8,20};
Recombine Surface{12};

Transfinite Surface{13} = {21,20,19,18};
Recombine Surface{13};
*/


// 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") = {185,207,53};
Physical Surface("outlet") = {133,111,89};
Physical Surface("top") = {181,159,137};
Physical Surface("bottom") = {41,63,85};
Physical Surface("cylinder") = {199,71,119,151};
//Physical Surface("plate") = {199,71,119,151};
Physical Surface("frontAndBackPlanes") = {93,49,54,67,76,6,45,8,7,120,5,4,3,2,1,208,186,173,164,163,89,142,141,133,115};

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

Mesh 3;
Save "fsiFluid.msh";









