// Gmsh project created on Sun Mar 24 20:50:03 2019
SetFactory("OpenCASCADE");
//+
NM1=0.05;
//+
NM2=0.05;
//+
Lz = DefineNumber[ 0.04, Name "Parameters/Lz" ];
//+
hcoil = DefineNumber[ 0.07, Name "Parameters/hcoil" ];
//+
wcoil = DefineNumber[ 0.01, Name "Parameters/wcoil" ];
//+
Point(1) = {0, 0, 0, NM2};
//+
Point(2) = {0.02, 0, Lz/2, NM2};
//+
Point(3) = {-0.02, 0, Lz/2, NM2};
//+
Point(4) = {-0.02, 0, -Lz/2, NM2};
//+
Point(5) = {0.02, 0, -Lz/2, NM2};
//+
Point(6) = {0.02+wcoil, 0, -Lz/2, NM2};
//+
Point(7) = {0.02, 0, -Lz/2-wcoil, NM2};
//+
Point(8) = {-0.02, 0, -Lz/2-wcoil, NM2};
//+
Point(9) = {-0.02-wcoil, 0, -Lz/2, NM2};
//+
Point(10) = {-0.02-wcoil, 0, Lz/2, NM2};
//+
Point(11) = {-0.02, 0, Lz/2+wcoil, NM2};
//+
Point(12) = {0.02, 0, Lz/2+wcoil, NM2};
//+
Point(13) = {0.02+wcoil, 0, Lz/2, NM2};
//+
Line(1) = {13, 2};
//+
Line(2) = {2, 12};
//+
Line(3) = {3, 11};
//+
Line(4) = {3, 10};
//+
Line(5) = {6, 5};
//+
Line(6) = {5, 7};
//+
Line(7) = {7, 8};
//+
Line(8) = {8, 4};
//+
Line(9) = {4, 9};
//+
Line(10) = {9, 10};
//+
Line(11) = {4, 5};
//+
Line(12) = {6, 13};
//+
Line(13) = {2, 5};
//+
Line(14) = {2, 3};
//+
Line(15) = {3, 4};
//+
Line(16) = {12, 11};
//+
Circle(17) = {13, 2, 12};
//+
Circle(18) = {11, 3, 10};
//+
Circle(19) = {9, 4, 8};
//+
Circle(20) = {6, 5, 7};
//+
Curve Loop(1) = {17, -2, -1};
//+
Plane Surface(1) = {1};
//+
Curve Loop(2) = {2, 16, -3, -14};
//+
Plane Surface(2) = {2};
//+
Curve Loop(3) = {3, 18, -4};
//+
Plane Surface(3) = {3};
//+
Curve Loop(4) = {15, 9, 10, -4};
//+
Plane Surface(4) = {4};
//+
Curve Loop(5) = {9, 19, 8};
//+
Plane Surface(5) = {5};
//+
Curve Loop(6) = {8, 11, 6, 7};
//+
Plane Surface(6) = {6};
//+
Curve Loop(7) = {6, -20, 5};
//+
Plane Surface(7) = {7};
//+
Curve Loop(8) = {5, -13, -1, -12};
//+
Plane Surface(8) = {8};
//+
Extrude {0, 0.07, 0} {
  Surface{2}; Surface{3}; Surface{4}; Surface{5}; Surface{6}; Surface{7}; Surface{8}; Surface{1}; 
}
//+
BooleanUnion{ Volume{1}; Delete; }{ Volume{2}; Volume{3}; Volume{4}; Volume{5}; Volume{6}; Volume{7}; Volume{8}; Delete; }
//+
Sphere(2) = {0, 0.04, -0.04, 0.4, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(3) = {0, 0.04, 0.06, 0.6, -Pi/2, Pi/2, 2*Pi};
//+
//BooleanFragments{ Volume{3}; Delete; }{ Volume{2}; Delete; }
//+
//BooleanFragments{ Volume{2}; Delete; }{ Volume{1}; Delete; }
//+
//Physical Volume("Luft",2000) = {4};
//+
//Physical Volume("Luft_grenze",3000) = {3};
//+
//Physical Volume("Coil",7000) = {1};
//+
Point(30) = {0.02, 0.07, 0.02, NM1};

//+
Point(31) = {-0.02, 0.07, 0.02, NM1};
//+
Point(32) = {-0.02, -0.05, 0.02, NM1};
//+
Point(33) = {0.02, -0.005, 0.02, NM1};
//+
Point(34) = {0.13, -0.05, 0.02, NM1};
//+
Point(35) = {0.13, 0.07, 0.02, NM1};
//+
Point(36) = {0.09, 0.07, 0.02, NM1};
//+
Point(37) = {0.09, -0.005, 0.02, NM1};
//+
Line(59) = {31, 32};
//+
Line(60) = {31, 30};
//+
Line(61) = {30, 33};
//+
Line(62) = {33, 37};
//+
Line(63) = {37, 36};
//+
Line(64) = {36, 35};
//+
Line(65) = {35, 34};
//+
Line(66) = {34, 32};
//+
Translate {0.11, 0, 0} {
  Duplicata { Volume{1}; }
}
//+
Curve Loop(59) = {60, 61, 62, 63, 64, 65, 66, -59};
//+
Plane Surface(59) = {59};
//+
Extrude {0, 0, -0.04} {
  Surface{59}; 
}
//+
Point(70) = {0.13, 0.073, 0.02, NM1};
//+
Point(71) = {-0.02, 0.073, 0.02, NM1};
//+
Point(72) = {-0.02, 0.113, 0.02, NM1};
//+
Point(73) = {0.13, 0.113, 0.02, NM1};
//+
Line(135) = {72, 71};
//+
Line(136) = {71, 70};
//+
Line(137) = {70, 73};
//+
Line(138) = {73, 72};
//+
Curve Loop(69) = {138, 135, 136, 137};
//+
Plane Surface(69) = {69};
//+
Extrude {0, 0, -0.04} {
  Surface{69}; 
}


//+
BooleanFragments{ Volume{3}; Delete; }{ Volume{2}; Delete; }
//+
BooleanFragments{ Volume{1}; Delete; }{ Volume{5}; Delete; }
//+
BooleanFragments{ Volume{4}; Delete; }{ Volume{5}; Delete; }
//+
BooleanFragments{ Volume{2}; Delete; }{ Volume{6}; Delete; }
//+
BooleanFragments{ Volume{8}; Delete; }{ Volume{1}; Delete; }
//+
BooleanFragments{ Volume{8}; Delete; }{ Volume{5}; Delete; }
//+
BooleanFragments{ Volume{8}; Delete; }{ Volume{4}; Delete; }
//+
Physical Volume("Coil1",7000) = {1};
//+
Physical Volume("Coil2",7001) = {4};
//+
Physical Volume("Leiter",1000) = {5};
//+
Physical Volume("Klotz",8000) = {6};
//+
Physical Volume("Luft",2000) = {8};
//+
Physical Volume("Luft_gr",3000) = {7};
//+
Physical Surface("surf_inf",9000) = {75};
//+
Physical Surface("skinM",4000) = {69, 71, 74, 72, 70, 73};
