// longueur, rayon, paramètre de maille, angle de rotation (en degrés)
l = 2;
r = 1;
p = 0.1;
alpha = 45;

alpha = Cos(alpha*Pi/180);

Point(1) = {0,0,0,p};
Point(2) = {l,0,0,p};
Point(3) = {l,-r,0,p};
Point(4) = {0,-r,0,p};

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

n = 10;
h0 = 0.015;
r = 1.15;

one[0] = 1;
h[0] = h0;
sum=h0;
For i In {1:n-1}
	one[i]=1;
	h[i] = h[i-1]*r;
	sum=sum+h[i];
EndFor

layer[0]=h[0];
For i In {1:n-1}
	layer[i] = layer[i-1]+ h[i];
EndFor

For i In {0:n-1}
	layer[i] = layer[i]/sum;
EndFor

Extrude {0, sum, 0} { Line{2}; Layers{one[],layer[]};Recombine;}
Extrude {0, r/10, 0} { Line{3};Layers{5};Recombine;QuadTriAddVerts;} //interface

Line(11) = {1, 7};
Line(12) = {2, 8};
Line Loop(13) = {1, 12, -7, -11};
Plane Surface(14) = {13};
Recombine Surface{14};

Extrude {{1,0,0}, {0,0,0}, alpha} {Surface{6};Surface{10};Layers{10};Recombine;}

Color Black{ Surface{10};}
Color Black{ Surface{6};}
Color Black{ Surface{14};}
Color Black{ Surface{27};}
Color Black{ Surface{49};}
Color Black{ Surface{35};}
Color Black{ Surface{57};}

Line(59) = {2, 24};
Line(60) = {1, 28};
Line Loop(61) = {12, 48, -59};
Plane Surface(62) = {61};
Line Loop(63) = {11, 52, -60};
Plane Surface(64) = {63};
Line Loop(65) = {1, 59, 40, -60};
Plane Surface(66) = {65};


Point(100) = {0, -0.3, -0.125, 0.1};
Point{100} In Surface{64};

Point(101) = {0, -0.3, -0.175, 0.1};
Point(102) = {0, -0.3, -0.075, 0.1};
Point(103) = {0, -0.35, -0.125, 0.1};
Point(104) = {0, -0.25, -0.125, 0.1};
Point{101} In Surface{64};
Point{102} In Surface{64};
Point{103} In Surface{64};
Point{104} In Surface{64};

Circle(67) = {104, 100, 101};
Circle(68) = {101, 100, 103};
Circle(69) = {103, 100, 102};
Circle(70) = {102, 100, 104};
Line{67} In Surface{64};
Line{68} In Surface{64};
Line{69} In Surface{64};
Line{70} In Surface{64};

Surface Loop(71) = {64, 14, 66, 62, 53};
Volume(72) = {71};
Mesh.Algorithm3D = 4;
