
xmin=-0.05;
xmax=1.50;
r1=0.021;
r2=0.031;
r3=0.080;
r4=1.20;

teta1 = 10*3.14159/180.0;
teta2 = 12*3.14159/180.0;
teta3 = 25*3.14159/180.0;

r5 = r1+xmax*Tan(teta1);
r6 = r2+xmax*Tan(teta2);
r7 = r3+xmax*Tan(teta3);

Point(1) = {0.0,0.0,0.0,0.0045};

Point(2) = {0.0,r1,0.0,0.01};
Point(3) = {0.0,r2,0.0,0.01};
Point(4) = {0.0,r3,0.0,0.01};

Point(5) = {0.0,0.0,r1,0.01};
Point(6) = {0.0,0.0,r2,0.01};
Point(7) = {0.0,0.0,r3,0.01};

Point(8)  = {0.0,-r1,0.0,0.01};
Point(9)  = {0.0,-r2,0.0,0.01};
Point(10) = {0.0,-r3,0.0,0.01};

Point(11) = {0.0,0.0,-r1,0.01};
Point(12) = {0.0,0.0,-r2,0.01};
Point(13) = {0.0,0.0,-r3,0.01};

Point(14) = {xmin,0.00,0.00,0.1};

Point(15) = {xmin,r3,0.00,0.1};
Point(16) = {xmin,0.00,r3,0.1};
Point(17) = {xmin,-r3,0.00,0.1};
Point(18) = {xmin,0.00,-r3,0.1};

Point(19) = {xmin,r4,0.00,0.2};
Point(20) = {xmin,0.00,r4,0.2};
Point(21) = {xmin,-r4,0.00,0.2};
Point(22) = {xmin,0.00,-r4,0.2};

Point(23) = {xmax,0.00,0.00,0.06};

Point(24) = {xmax,r4,0.00,0.2};
Point(25) = {xmax,0.00,r4,0.2};
Point(26) = {xmax,-r4,0.00,0.2};
Point(27) = {xmax,0.00,-r4,0.2};


Point(32) = {xmax,r5,0,0.12};
Point(33) = {xmax,0.0,r5,0.12};
Point(34) = {xmax,-r5,0,0.12};
Point(35) = {xmax,0.0,-r5,0.12};

Point(36) = {xmax,0.0,0.0,0.12};

Point(37) = {xmax,r6,0,0.12};
Point(38) = {xmax,0.0,r6,0.12};
Point(39) = {xmax,-r6,0,0.12};
Point(40) = {xmax,0.0,-r6,0.12};

Point(41) = {xmax,r7,0,0.12};
Point(42) = {xmax,0.0,r7,0.12};
Point(43) = {xmax,-r7,0,0.12};
Point(44) = {xmax,0.0,-r7,0.12};

Circle(1) = {4,1,13};
Circle(2) = {13,1,10};
Circle(3) = {10,1,7};
Circle(4) = {7,1,4};

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

Circle(9) = {2,1,11};
Circle(10) = {11,1,8};
Circle(11) = {8,1,5};
Circle(12) = {5,1,2};

Circle(13) = {15,14,18};
Circle(14) = {18,14,17};
Circle(15) = {17,14,16};
Circle(16) = {16,14,15};
Circle(17) = {19,14,22};
Circle(18) = {22,14,21};
Circle(19) = {21,14,20};
Circle(20) = {20,14,19};

Line(21) = {15,4};
Line(22) = {16,7};
Line(23) = {17,10};
Line(24) = {18,13};

Circle(25) = {24,23,27};
Circle(26) = {27,23,26};
Circle(27) = {26,23,25};
Circle(28) = {25,23,24};

Line(29) = {24,19};
Line(30) = {20,25};
Line(31) = {21,26};
Line(32) = {22,27};


Line Loop(35) = {20,17,18,19};
Line Loop(36) = {16,13,14,15};
Plane Surface(37) = {35,36};
Line Loop(38) = {29,-20,30,28};
Ruled Surface(39) = {38};
Line Loop(40) = {30,-27,-31,19};
Ruled Surface(41) = {40};
Line Loop(42) = {26,-31,-18,32};
Ruled Surface(43) = {42};
Line Loop(44) = {25,-32,-17,-29};
Ruled Surface(45) = {44};
Line Loop(46) = {4,-21,-16,22};
Ruled Surface(47) = {46};
Line Loop(48) = {1,-24,-13,21};
Ruled Surface(49) = {48};
Line Loop(50) = {2,-23,-14,24};
Ruled Surface(51) = {50};
Line Loop(52) = {3,-22,-15,23};
Ruled Surface(53) = {52};

Line Loop(54) = {9,10,11,12};


Circle(56) = {3,1,12};
Circle(57) = {12,1,9};
Circle(58) = {9,1,6};
Circle(59) = {6,1,3};

Line Loop(60) = {56,57,58,59};
//Plane Surface(61) = {60,54};

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

Transfinite Line {30, 31, 32, 29} = 13 Using Progression 1;


Transfinite Line {30, 29, 31, 32} = 31 Using Progression 1;
Transfinite Line {27, 28, 25, 26} = 17 Using Progression 1;
Transfinite Line {19, 18, 17, 20} = 13 Using Progression 1;
//Transfinite Line {70, 71, 68, 69} = 5 Using Progression 1;
Transfinite Line {12, 11, 10, 9} = 7 Using Progression 1;

Transfinite Line {7, 8, 5, 6} = 7 Using Progression 1;
Transfinite Line {3, 4, 2, 1} = 12 Using Progression 1;


Transfinite Line {16, 13, 15, 14} = 4 Using Progression 1;

Line(93) = {5, 33};
Line(94) = {2, 32};
Line(95) = {11, 35};
Line(101) = {8, 34};


Line(102) = {35, 36};
Line(103) = {36, 33};
Line(104) = {34, 36};
Line(105) = {32, 36};

Line(106) = {36, 1};
Line(107) = {11, 1};
Line(108) = {5, 1};
Line(109) = {2, 1};
Line(110) = {8, 1};

Line Loop(111) = {107, -110, -10};
Plane Surface(112) = {111};
Line Loop(113) = {110, -108, -11};
Plane Surface(114) = {113};
Line Loop(115) = {108, -109, -12};
Plane Surface(116) = {115};
Line Loop(117) = {109, -107, -9};
Plane Surface(118) = {117};
Line Loop(119) = {95, 102, 106, -107};
Plane Surface(120) = {119};
Line Loop(121) = {106, -108, 93, -103};
Plane Surface(122) = {121};
Line Loop(123) = {94, 105, 106, -109};
Plane Surface(124) = {123};
Line Loop(125) = {-101, 110, -106, -104};
Plane Surface(126) = {125};


// Linee radiali sulla superficie del canale

Line(147) = {8, 9};
Line(148) = {11, 12};
Line(149) = {2, 3};
Line(150) = {5, 6};

// 4 superfici uscita canale
Line Loop(172) = {10, 147, -6, -148};
Plane Surface(173) = {172};
Line Loop(174) = {9, 148, -5, -149};
Plane Surface(175) = {174};
Line Loop(176) = {12, 149, -8, -150};
Plane Surface(177) = {176};
Line Loop(178) = {11, 150, -7, -147};
Plane Surface(179) = {178};

Coherence;

Line Loop(82) = {25, 26, 27, 28};
Plane Surface(128) = {82};

Surface Loop(129) = {45, 128, 43, 41, 39, 37, 53, 63, 49, 51, 47,116, 114, 112, 118,173,175,177,179};
Volume(130) = {129};

Surface {124} In Volume {130};
Surface {126} In Volume {130};
Surface {122} In Volume {130};
Surface {120} In Volume {130};
Show "*";

// linee direttrici
Line(131) = {6, 38};
Line(132) = {9, 39};
Line(133) = {12, 40};
Line(134) = {3, 37};
Line(135) = {7, 42};
Line(136) = {10, 43};
Line(137) = {13, 44};
Line(138) = {4, 41};


// linee radiali sup. aux su piano xmax
Line(139) = {33, 38};
Line(140) = {32, 37};
Line(141) = {35, 40};
Line(142) = {34, 39};
Line(143) = {38, 42};
Line(144) = {37, 41};
Line(145) = {40, 44};
Line(146) = {39, 43};

Transfinite Line {95, 94, -106, 101, 93} = 41 Using Progression 1.05;
Transfinite Line {131,132,133,134,135,136,137,138} = 41 Using Progression 1.05;

Line {102} In Surface {128};
Line {103} In Surface {128};
Line {104} In Surface {128};
Line {105} In Surface {128};

Line {139} In Surface {128};
Line {140} In Surface {128};
Line {141} In Surface {128};
Line {142} In Surface {128};
Line {143} In Surface {128};
Line {144} In Surface {128};
Line {145} In Surface {128};
Line {146} In Surface {128};


NPR1 = 11;
Transfinite Line {102, 105, 104, 103} = NPR1 Using Progression 1.00;
NPR2 = 4;
Transfinite Line {139,140,141,142} = NPR2 Using Progression 1.0;
NPR3 = 11;
Transfinite Line {143,144,145,146} = NPR3 Using Progression 1.0;

Transfinite Line {107, 110, 108, 109} = NPR1 Using Progression 1.00;
Transfinite Line {102, 103, 105, 104} = NPR1 Using Progression 1.00;

Transfinite Line {19, 18, 17, 20} = 17 Using Progression 1;
Transfinite Line {31, 30, 29, 32} = 25 Using Progression 1;

Transfinite Surface {124} = {32, 23, 2, 1};
Transfinite Surface {126} = {34, 23, 8, 1};
Transfinite Surface {122} = {33, 23, 5, 1};
Transfinite Surface {120} = {35, 23, 11, 1};

Transfinite Surface {41} = {20, 25, 26, 21};
Transfinite Surface {39} = {20, 25, 24, 19};
Transfinite Surface {45} = {19, 24, 27, 22};
Transfinite Surface {43} = {27, 22, 21, 26};

Transfinite Line {147,148,149,150} = NPR2 Using Progression 1;


// Superfici aux da canale motore
Line Loop(151) = {101, 142, -132, -147};
Plane Surface(152) = {151};
Line Loop(153) = {131, -139, -93, 150};
Plane Surface(154) = {153};
Line Loop(155) = {94, 140, -134, -149};
Plane Surface(156) = {155};

Line Loop(157) = {95, 141, -133, -148};
Plane Surface(158) = {157};
Transfinite Surface {152} = {8, 9, 39, 34};
Transfinite Surface {154} = {5, 6, 38, 33};
Transfinite Surface {156} = {2, 3, 37, 32};
Transfinite Surface {158} = {11, 12, 40, 35};

// Linee radiali da raggio esterno a raggio box motore
Line(159) = {9, 10};
Line(160) = {6, 7};
Line(161) = {3, 4};
Line(162) = {12, 13};

Transfinite Line {159,160,161,162} = NPR3 Using Progression 1.0;

// Superfici aux parte esterna motore

Line Loop(163) = {159, 136, -146, -132};
Plane Surface(164) = {163};
Line Loop(165) = {160, 135, -143, -131};
Plane Surface(166) = {165};
Line Loop(167) = {161, 138, -144, -134};
Plane Surface(168) = {167};
Line Loop(169) = {162, 137, -145, -133};
Plane Surface(170) = {169};
Transfinite Surface {164} = {9, 10, 43, 39};
Transfinite Surface {166} = {6, 7, 42, 38};
Transfinite Surface {168} = {3, 4, 41, 37};
Transfinite Surface {170} = {12, 13, 44, 40};

//Physical group con le superfici aux
Physical Surface(171) = {168, 170, 158, 120, 164, 126, 152, 166, 154, 122, 156, 124};

Transfinite Surface {173} = {8, 9, 12, 11};
Transfinite Surface {175} = {11, 12, 3, 2};
Transfinite Surface {177} = {2, 3, 6, 5};
Transfinite Surface {179} = {5, 6, 9, 8};

Surface {158} In Volume {130};
Surface {154} In Volume {130};
Surface {152} In Volume {130};
Surface {156} In Volume {130};

Surface {164} In Volume {130};          //  <--- IF YOU UNCOMMENT THIS 3D MESH CRASHES !!!
//Surface {166} In Volume {130};          //  <--- IF YOU UNCOMMENT THIS 3D MESH CRASHES !!!
//Surface {168} In Volume {130};          //  <--- IF YOU UNCOMMENT THIS 3D MESH CRASHES !!!
//Surface {170} In Volume {130};          //  <--- IF YOU UNCOMMENT THIS 3D MESH CRASHES !!!

