SetFactory("OpenCASCADE");

ri=0.1115;
re=0.1575;
rcat=0.0248;
rgrafite=0.095;
rceramic=0.175;
ds=0.007;

rbox=0.20;
dbox=0.15;
inter=0.5;

//////////////////////

np=newp;
Point(np+ 1) = {0.0,   0.47000,   0.00000, 1.0};
Point(np+ 2) = {0.0,   0.46712,   0.03550, 1.0};
Point(np+ 3) = {0.0,   0.45854,   0.07007, 1.0};
Point(np+ 4) = {0.0,   0.44451,   0.10280, 1.0};
Point(np+ 5) = {0.0,   0.42537,   0.13284, 1.0};
Point(np+ 6) = {0.0,   0.40164,   0.15939, 1.0};
Point(np+ 7) = {0.0,   0.37393,   0.18177, 1.0};
Point(np+ 8) = {0.0,   0.34298,   0.19939, 1.0};
Point(np+ 9) = {0.0,   0.30958,   0.21178, 1.0};
Point(np+10) = {0.0,   0.27463,   0.21862, 1.0};
Point(np+11) = {0.0,   0.23903,   0.21973, 1.0};
Point(np+12) = {0.0,   0.20372,   0.21508, 1.0};
Point(np+13) = {0.0,   0.16962,   0.20479, 1.0};
Point(np+14) = {0.0,   0.13763,   0.18914, 1.0};
Point(np+15) = {0.0,   0.10859,   0.16853, 1.0};
Point(np+16) = {0.0,   0.08447,   0.15164, 1.0};
Point(np+17) = {0.0,   0.05778,   0.13920, 1.0};
Point(np+18) = {0.0,   0.02933,   0.13157, 1.0};
Point(np+19) = {0.0,   0.00000,   0.12901, 1.0};
Point(np+20) = {0.0,  -0.02933,   0.13157, 1.0};
Point(np+21) = {0.0,  -0.05778,   0.13920, 1.0};
Point(np+22) = {0.0,  -0.08447,   0.15164, 1.0};
Point(np+23) = {0.0,  -0.10859,   0.16853, 1.0};
Point(np+24) = {0.0,  -0.13763,   0.18914, 1.0};
Point(np+25) = {0.0,  -0.16962,   0.20479, 1.0};
Point(np+26) = {0.0,  -0.20372,   0.21508, 1.0};
Point(np+27) = {0.0,  -0.23903,   0.21973, 1.0};
Point(np+28) = {0.0,  -0.27463,   0.21862, 1.0};
Point(np+29) = {0.0,  -0.30958,   0.21178, 1.0};
Point(np+30) = {0.0,  -0.34298,   0.19939, 1.0};
Point(np+31) = {0.0,  -0.37393,   0.18177, 1.0};
Point(np+32) = {0.0,  -0.40164,   0.15939, 1.0};
Point(np+33) = {0.0,  -0.42537,   0.13284, 1.0};
Point(np+34) = {0.0,  -0.44451,   0.10280, 1.0};
Point(np+35) = {0.0,  -0.45854,   0.07007, 1.0};
Point(np+36) = {0.0,  -0.46712,   0.03550, 1.0};
Point(np+37) = {0.0,  -0.47000,   0.00000, 1.0};
Spline(1) = {
np+   1,np+   2,np+   3,np+   4,np+   5,np+   6,np+   7,np+   8,np+   9,
np+  10,np+  11,np+  12,np+  13,np+  14,np+  15,np+  16,np+  17,np+  18,
np+  19,np+  20,np+  21,np+  22,np+  23,np+  24,np+  25,np+  26,np+  27,
np+  28,np+  29,np+  30,np+  31,np+  32,np+  33,np+  34,np+  35,np+  36,
np+  37
};
Point(np+38) = {0.0,  -0.46712,  -0.03550, 1.0};
Point(np+39) = {0.0,  -0.45854,  -0.07007, 1.0};
Point(np+40) = {0.0,  -0.44451,  -0.10280, 1.0};
Point(np+41) = {0.0,  -0.42537,  -0.13284, 1.0};
Point(np+42) = {0.0,  -0.40164,  -0.15939, 1.0};
Point(np+43) = {0.0,  -0.37393,  -0.18177, 1.0};
Point(np+44) = {0.0,  -0.34298,  -0.19939, 1.0};
Point(np+45) = {0.0,  -0.30958,  -0.21178, 1.0};
Point(np+46) = {0.0,  -0.27463,  -0.21862, 1.0};
Point(np+47) = {0.0,  -0.23903,  -0.21973, 1.0};
Point(np+48) = {0.0,  -0.20372,  -0.21508, 1.0};
Point(np+49) = {0.0,  -0.16962,  -0.20479, 1.0};
Point(np+50) = {0.0,  -0.13763,  -0.18914, 1.0};
Point(np+51) = {0.0,  -0.10859,  -0.16853, 1.0};
Point(np+52) = {0.0,  -0.08447,  -0.15164, 1.0};
Point(np+53) = {0.0,  -0.05778,  -0.13920, 1.0};
Point(np+54) = {0.0,  -0.02933,  -0.13157, 1.0};
Point(np+55) = {0.0,   0.00000,  -0.12901, 1.0};
Point(np+56) = {0.0,   0.02933,  -0.13157, 1.0};
Point(np+57) = {0.0,   0.05778,  -0.13920, 1.0};
Point(np+58) = {0.0,   0.08447,  -0.15164, 1.0};
Point(np+59) = {0.0,   0.10859,  -0.16853, 1.0};
Point(np+60) = {0.0,   0.13763,  -0.18914, 1.0};
Point(np+61) = {0.0,   0.16962,  -0.20479, 1.0};
Point(np+62) = {0.0,   0.20372,  -0.21508, 1.0};
Point(np+63) = {0.0,   0.23903,  -0.21973, 1.0};
Point(np+64) = {0.0,   0.27463,  -0.21862, 1.0};
Point(np+65) = {0.0,   0.30958,  -0.21178, 1.0};
Point(np+66) = {0.0,   0.34298,  -0.19939, 1.0};
Point(np+67) = {0.0,   0.37393,  -0.18177, 1.0};
Point(np+68) = {0.0,   0.40164,  -0.15939, 1.0};
Point(np+69) = {0.0,   0.42537,  -0.13284, 1.0};
Point(np+70) = {0.0,   0.44451,  -0.10280, 1.0};
Point(np+71) = {0.0,   0.45854,  -0.07007, 1.0};
Point(np+72) = {0.0,   0.46712,  -0.03550, 1.0};
Point(np+73) = {0.0,   0.47000,   0.00000, 1.0};
Spline(2) = {
np+  37,np+  38,np+  39,np+  40,np+  41,np+  42,np+  43,np+  44,np+  45,
np+  46,np+  47,np+  48,np+  49,np+  50,np+  51,np+  52,np+  53,np+  54,
np+  55,np+  56,np+  57,np+  58,np+  59,np+  60,np+  61,np+  62,np+  63,
np+  64,np+  65,np+  66,np+  67,np+  68,np+  69,np+  70,np+  71,np+  72,
np+   1
};

//////////////////////

nl=newl;

Circle(nl  ) = {-0, -inter/2, 0, rcat, 0, 2*Pi};
Circle(nl+1) = {-0, -inter/2, 0, rgrafite, 0, 2*Pi};
Circle(nl+2) = {-0, -inter/2, 0, rceramic, 0, 2*Pi};

Rotate {{0, 1, 0}, {0, 0, 0}, Pi/2} {
  Curve{nl,nl+1,nl+2}; 
}

ll=newll;
ns=news;

Cone(1) = {-ds, -inter/2, -0, ds, 0, 0, ri, ri-ds, 2*Pi};
Delete {Volume{1}; }

Cone(1) = {-ds, -inter/2, -0, ds, 0, 0, re, re+ds, 2*Pi};
Delete {Volume{1};}
Delete {Surface{2}; Surface{3};}
Delete {Surface{5}; Surface{6};}

nl=newl;

Circle(nl  ) = {-0, inter/2, 0, rcat, 0, 2*Pi};
Circle(nl+1) = {-0, inter/2, 0, rgrafite, 0, 2*Pi};
Circle(nl+2) = {-0, inter/2, 0, rceramic, 0, 2*Pi};

Rotate {{0, 1, 0}, {0, 0, 0}, Pi/2} {
  Curve{nl,nl+1,nl+2}; 
}

ll=newll;
ns=news;

Cone(1) = {-ds, inter/2, -0, ds, 0, 0, ri, ri-ds, 2*Pi};
Delete {Volume{1}; }
Cone(1) = {-ds, inter/2, -0, ds, 0, 0, re, re+ds, 2*Pi};

Delete {Volume{1};}
Delete {Surface{10}; Surface{9};}
Delete {Surface{7}; Surface{6};}

Extrude {-0.25, 0, 0} {Curve{1}; Curve{2}; }

Curve Loop(15) = {23, 24};
Plane Surface(11) = {15};
Curve Loop(16) = {1, 2};
Curve Loop(17) = {5};
Curve Loop(18) = {14};
Plane Surface(12) = {16, 17, 18};

Field[1] = Ball;
Field[1].Radius = 2;
Field[1].VIn = 0.02;
Background Field = 1;

Curve Loop(19) = {5};
Curve Loop(20) = {9};
Plane Surface(13) = {19, 20};
Curve Loop(21) = {11};
Curve Loop(22) = {8};
Plane Surface(14) = {21, 22};
Curve Loop(23) = {6};
Curve Loop(24) = {4};
Plane Surface(15) = {23, 24};
Curve Loop(25) = {4};
Curve Loop(26) = {3};
Plane Surface(16) = {25, 26};
Curve Loop(27) = {3};
Plane Surface(17) = {27};
Curve Loop(28) = {14};
Curve Loop(29) = {18};
Plane Surface(18) = {28, 29};
Curve Loop(30) = {20};
Curve Loop(31) = {17};
Plane Surface(19) = {30, 31};
Curve Loop(32) = {15};
Curve Loop(33) = {13};
Plane Surface(20) = {32, 33};
Curve Loop(34) = {13};
Curve Loop(35) = {12};
Plane Surface(21) = {34, 35};
Curve Loop(36) = {12};
Plane Surface(22) = {36};
Surface Loop(5) = {9, 10, 11, 12, 13, 4, 14, 1, 15, 16, 17, 18, 8, 19, 5, 20, 21, 22};

Volume(1) = {5};
Fillet{1}{23, 24}{0.075}
//+
Delete {
  Volume{1}; 
}
