Geometry.CopyMeshingMethod = 1 ;
Mesh.CharacteristicLengthMax = 0.25 ;

NX1  =  21 ; RX1 = 0.95 ; // in front of the cilinder
NX2  =  21 ; RX2 = 1.05 ; // around the cilinder
NX3  =  21 ; RX3 = 1.00 ; // middle of the cilinder
NX4  = 151 ; RX4 = 1.01 ; // behind the cilinder

NY1  =  9 ; RY1  = 1.00 ;
NY1b = 13 ; RY1b = 0.98 ;
NY2  = 31 ; RY2  = 1.05 ;

Z0 = -0.1 ; // plane
SB =  0.1 ; // dummy size  
R  =  1.0 ; // unity radius
F  =  1.0 ; // factor around the cilinder

X0 = -2.0 * R * 2 ;
X1 = -(1+F)* R ;
X2 = -1.0 * R;
X3 = -0.70710678 * R;
X4 = 0.70710678 * R;
X5 = 1.0 * R;
X6 = (1+F)* R;
X7 = 20.0 * R * 2;

Y0 = 0.0 ;
Y1 = 0.70710678 * R;
Y2 = 0.70710678 * R * (1+F);
Y3 = 2.1 * R * 2;
Y4 = 2.0 * R * 2;


Point( 0) = { 0, 0, Z0, SB};
Point( 1) = { X0, Y0, Z0, SB};
Point( 2) = { X1, Y0, Z0, SB};
Point( 3) = { X2, Y0, Z0, SB};
Point( 4) = { X5, Y0, Z0, SB};
Point( 5) = { X6, Y0, Z0, SB};
Point( 6) = { X7, Y0, Z0, SB};

Point( 7) = { X3, Y1, Z0, SB};
Point( 8) = { X4, Y1, Z0, SB};

Point( 9) = { X0, Y2, Z0, SB};
Point(10) = {-Y2, Y2, Z0, SB};
Point(11) = { Y2, Y2, Z0, SB};
Point(12) = { X7, Y2, Z0, SB};

Point(13) = { X0, Y3, Z0, SB};
Point(14) = {-Y2, Y3, Z0, SB};
Point(15) = { Y2, Y3, Z0, SB};
Point(16) = { X7, Y3, Z0, SB};

//
Point( 17) = { X0, -Y0, Z0, SB};
Point( 18) = { X1, -Y0, Z0, SB};
Point( 19) = { X2, -Y0, Z0, SB};
Point( 20) = { X5, -Y0, Z0, SB};
Point( 21) = { X6, -Y0, Z0, SB};
Point( 22) = { X7, -Y0, Z0, SB};

Point( 23) = { X3, -Y1, Z0, SB};
Point( 24) = { X4, -Y1, Z0, SB};

Point( 25) = { X0, -Y2, Z0, SB};
Point(26) = {-Y2, -Y2, Z0, SB};
Point(27) = { Y2, -Y2, Z0, SB};
Point(28) = { X7, -Y2, Z0, SB};

Point(29) = { X0, -Y4, Z0, SB};
Point(30) = {-Y2, -Y4, Z0, SB};
Point(31) = { Y2, -Y4, Z0, SB};
Point(32) = { X7, -Y4, Z0, SB};




Line(1) = {1,2}; Transfinite Line{1} = NX1 Using Progression RX1 ;
Line(2) = {2,3}; Transfinite Line{2} = NX2 Using Progression 1/RX2 ;
Circle(3)= {3,0,7}; Transfinite Line{3} = NY1 Using Progression RY1 ;
Circle(4)= {7,0,8}; Transfinite Line{4} = NX3 Using Progression RX3 ;
Circle(5)= {8,0,4}; Transfinite Line{5} = NY1b Using Progression 1/RY1b ;
Line(6) = {4,5}; Transfinite Line{6} = NX2 Using Progression RX2 ;
Line(7) = {5,6}; Transfinite Line{7} = NX4 Using Progression RX4 ;

Line( 8) = {9,10}; Transfinite Line{8} = NX1 Using Progression RX1 ;
Circle(9)= {10,0,11};Transfinite Line{9} = NX3 Using Progression RX3 ;
Line(10) = {11,12}; Transfinite Line{10} = NX4 Using Progression RX4 ;

Line(11) = {13,14}; Transfinite Line{11} = NX1 Using Progression RX1 ;
Line(12) = {14,15}; Transfinite Line{12} = NX3 Using Progression RX3 ;
Line(13) = {15,16}; Transfinite Line{13} = NX4 Using Progression RX4 ;

Line(14) = {1,9}; Transfinite Line{14} = NY1 Using Progression RY1 ;
Line(15) = {9,13}; Transfinite Line{15} = NY2 Using Progression RY2 ;
Circle(16)= {2,0,10};Transfinite Line{16} = NY1 Using Progression RY1 ;
Line(17) = {10,14}; Transfinite Line{17} = NY2 Using Progression RY2 ;
Circle(18)= { 5,0,11}; Transfinite Line{18} = NY1b Using Progression RY1b ;
Line(19) = {11,15}; Transfinite Line{19} = NY2 Using Progression RY2 ;
Line(20) = {6,12}; Transfinite Line{20} = NY1b Using Progression RY1b ;
Line(21) = {12,16}; Transfinite Line{21} = NY2 Using Progression RY2 ;
Line(22) = {7,10}; Transfinite Line{22} = NX2 Using Progression RX2 ;
Line(23) = {8,11}; Transfinite Line{23} = NX2 Using Progression RX2 ;

//
Circle(24)= {3,0,23}; Transfinite Line{24} = NY1 Using Progression RY1 ;
Circle(25)= {23,0,24}; Transfinite Line{25} = NX3 Using Progression RX3 ;
Circle(26)= {24,0,4}; Transfinite Line{26} = NY1b Using Progression 1/RY1b ;
Line( 27) = {25,26}; Transfinite Line{27} = NX1 Using Progression RX1 ;
Circle(28)= {26,0,27};Transfinite Line{28} = NX3 Using Progression RX3 ;
Line(29) = {27,28}; Transfinite Line{29} = NX4 Using Progression RX4 ;

Line(30) = {29,30}; Transfinite Line{30} = NX1 Using Progression RX1 ;
Line(31) = {30,31}; Transfinite Line{31} = NX3 Using Progression RX3 ;
Line(32) = {31,32}; Transfinite Line{32} = NX4 Using Progression RX4 ;

Line(33) = {1,25}; Transfinite Line{33} = NY1 Using Progression RY1 ;
Line(34) = {25,29}; Transfinite Line{34} = NY2 Using Progression RY2 ;
Circle(35)= {2,0,26}; Transfinite Line{35} = NY1 Using Progression RY1 ;
Line(36) = {26,30}; Transfinite Line{36} = NY2 Using Progression RY2 ;
Circle(37)= { 5,0,27}; Transfinite Line{37} = NY1b Using Progression RY1b ;
Line(38) = {27,31}; Transfinite Line{38} = NY2 Using Progression RY2 ;
Line(39) = {6,28}; Transfinite Line{39} = NY1b Using Progression RY1b ;
Line(40) = {28,32}; Transfinite Line{40} = NY2 Using Progression RY2 ;
Line(41) = {23,26}; Transfinite Line{41} = NX2 Using Progression RX2 ;
Line(42) = {24,27}; Transfinite Line{42} = NX2 Using Progression RX2 ;


//
Line Loop(1) = {1,16,-8,-14};
Ruled Surface(1) = {1};
Transfinite Surface(1) = {1,2,10,9};

Line Loop(2) = {8,17,-11,-15};
Ruled Surface(2) = {2};
Transfinite Surface(2) = {9,10,14,13};

Line Loop(3) = {2,3,22,-16};
Ruled Surface(3) = {3};
Transfinite Surface(3) = {2,3,7,10};
Line Loop(4) = {4,23,-9,-22};
Ruled Surface(4) = {4};
Transfinite Surface(4) = {7,8,11,10};
Line Loop(5) = {5,6,18,-23};
Ruled Surface(5) = {5};
Transfinite Surface(5) = {4,5,11,8};

Line Loop(6) = {9,19,-12,-17};
Ruled Surface(6) = {6};
Transfinite Surface(6) = {10,11,15,14};

Line Loop(7) = {7,20,-10,-18};
Ruled Surface(7) = {7};
Transfinite Surface(7) = {5,6,12,11};
Line Loop(8) = {10,21,-13,-19};
Ruled Surface(8) = {8};
Transfinite Surface(8) = {11,12,16,15};


//
Line Loop(9) = {27,-35,-1,33}; // ! instead of Line Loop(9) = {27,35,-1,-33};
Ruled Surface(9) = {9};
Transfinite Surface(9) = {2,1,25,26};

Line Loop(10) = {27,36,-30,-34}; // ! instead of Line Loop(10) = {27,-36,-30,34};
Ruled Surface(10) = {10};
Transfinite Surface(10) = {25,26,30,29};

Line Loop(11) = {2,24,41,-35}; // ! instead of Line Loop(11) = {2,-24,-41,35};
Ruled Surface(11) = {11};
Transfinite Surface(11) = {2,3,23,26};
Line Loop(12) = {25,42,-28,-41}; // ! instead of Line Loop(12) = {25,-42,-28,41};
Ruled Surface(12) = {12};
Transfinite Surface(12) = {23,24,27,26};
Line Loop(13) = {26,6,37,-42}; // ! instead of Line Loop(13) = {26,6,-37,-42};
Ruled Surface(13) = {13};
Transfinite Surface(13) = {4,5,27,24};

Line Loop(14) = {28,38,-31,-36}; // ! instead of Line Loop(14) = {28,-38,-31,36};
Ruled Surface(14) = {14};
Transfinite Surface(14) = {26,27,31,30};

Line Loop(15) = {7,39,-29,-37}; // ! instead of Line Loop(15) = {7,-39,-29,37};
Ruled Surface(15) = {15};
Transfinite Surface(15) = {5,6,28,27};
Line Loop(16) = {29,40,-32,-38}; // ! instead of Line Loop(16) = {29,-40,-32,38};
Ruled Surface(16) = {16};
Transfinite Surface(16) = {27,28,32,31};


Recombine Surface(1);
Recombine Surface(2);
Recombine Surface(3);
Recombine Surface(4);
Recombine Surface(5);
Recombine Surface(6);
Recombine Surface(7);
Recombine Surface(8);
Recombine Surface(9);
Recombine Surface(10);
Recombine Surface(11);
Recombine Surface(12);
Recombine Surface(13);
Recombine Surface(14);
Recombine Surface(15);
Recombine Surface(16);


//Extrude {0.0,0.0,4.2} { Surface{1,2,3,4,5,6,7,8}; Layers{1}; //Recombine;}
//Extrude {0.0,0.0,4.2} { Surface{24,29,34,38,42,46,50,54}; //Layers{1}; Recombine;}

//Physical Volume("Fluid") = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};

//Physical Surface("Wand") = {114,132,154,330,308,290,272,360,404,96,184,228};
//Physical Surface("In") = { 78,100,254,276};
//Physical Surface("Uit") = {202,224,378,400};
//Physical Surface("Onder") = {};
//Physical Surface("Boven") = {};
//Physical Surface("Voor") = {101,189,233,79,255,123,299,145,       321,167,343,277,365,409,387,211};
//Physical Surface("Achter")= {1,2,3,4,5,6,7,8,24,29,34,38,42,46,50,54};

