//Move the above to another file
Include "inductor_data.geo";
lc = 5*mm;

Point(1) = {0, 0, 0, lc};
Point(2) = {radius, 0, 0,lc };
Point(3) = {0, (radius), 0, lc};
Point(4) = {-radius, 0, 0, lc};
Point(5) = {0, -(radius), 0, lc};

Point(6) = {(radius+wirethickness), 0, 0, lc};
Point(7) = {0, (radius+wirethickness), 0, lc};
Point(8) = {-(radius+wirethickness), 0, 0, lc};
Point(9) = {0, -(radius+wirethickness), 0, lc};

Circle(1) = {2, 1, 3};
Circle(2) = {3, 1, 4};
Circle(3) = {4, 1, 5};
Circle(4) = {5, 1, 2};

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

Line Loop(5) = {1,2,3, 4};
Line Loop(6) = {5,6,7,8};
Plane Surface(7) = {6, 5};
Extrude {0, 0, height} {
  Surface{7};
}

Point(110) = {Rint, 0, 0, lc*10};
Point(111) = {0, (Rint), 0, lc*10};
Point(112) = {0, 0, (Rint), lc*10};
Point(113) = {0, -(Rint), 0, lc*10};

Circle(109) = {110, 1, 111};
Circle(110) = {111, 1, 112};
Circle(111) = {112, 1, 110};
// Circle(112) = {113, 1, 110};

Line Loop(112) = {111, 109, 110};
Ruled Surface(113) = {112};
Symmetry {1, 0, 0, 0} {
  Duplicata { Surface{113}; }
}
Symmetry {0, 1, 0, 0} {
  Duplicata { Surface{113, 114}; }
}
// Symmetry {0, 0, 1, 0} {
//   Duplicata { Surface{114, 113, 118, 122}; }
// }
Symmetry {0, 0, 1, 0} {
  Duplicata { Surface{114, 121, 117, 113}; }
}
Surface Loop(137) = {113, 117, 132, 136, 124, 128, 121, 114};
Surface Loop(138) = {41, 7, 21, 25, 29, 33, 50, 37, 49, 45};
Volume(139) = {137, 138};


Point(210) = {Rext, 0, 0, lc*15};
Point(211) = {0, (Rext), 0, lc*15};
Point(212) = {0, 0, (Rext), lc*15};
Point(213) = {0, -(Rext), 0, lc*15};

Circle(209) = {210, 1, 211};
Circle(210) = {211, 1, 212};
Circle(211) = {212, 1, 210};
// Circle(112) = {113, 1, 110};

Line Loop(212) = {211, 209, 210};
Ruled Surface(213) = {212};
Symmetry {1, 0, 0, 0} {
  Duplicata { Surface{213}; }
}
Symmetry {0, 1, 0, 0} {
  Duplicata { Surface{213, 214}; }
}
Symmetry {0, 0, 1, 0} {
  Duplicata { Surface{213, 214, 217, 221}; }
}
Surface Loop(237) = {217, 213, 224, 232, 236, 228, 214, 221};
Volume(238) = {137, 237};

Physical Volume(COIL) = {1};
Physical Volume(AIR) = {139};
Physical Volume(AIRINF) = {238};
Physical Surface(SURF_AIROUT) = {237};

//Create Current injection point
// Line(3331) = {2, 7};
// Line(3332) = {30, 12};
Line(3334) = {2, 6};
Line(3335) = {10, 30};
Line Loop(3336) = {35, -3335, -19, -3334};
Plane Surface(3337) = {3336};
Physical Surface(SURF_ELEC0) = {3337};
Physical Surface(SKINCOIL_) = {37,41,45,49};
Physical Surface(SKINCOIL) = {37,41,45,49,2,50,21,25,29,33};
Plane Surface(3338) = {5};
Physical Surface(CUTCOIL) =   {3338};
