Include "eddy4-data.geo";

lcglob = 40*mm;
lc = 10*mm;

Point(1) = {0, 0, 0, lc};

Point(2) = {-d/2, -a, 0, lc};
Point(3) = {0, -a, 0, lc};
Point(4) = {d/2, -a, 0, lc};
Point(5) = {d/2, a, 0, lc};
Point(6) = {0, a, 0, lc};
Point(7) = {-d/2, a, 0, lc};

Point(8) = {-d/2, -a-b, 0, lc};
Point(9) = {d/2, -a-b, 0, lc};
Point(10) = {d/2, a+b, 0, lc};
Point(11) = {-d/2, a+b, 0, lc};

Point(12) = {-rInt, 0, 0, lcglob};
Point(13) = {0, -rInt, 0, lcglob};
Point(14) = {rInt, 0, 0, lcglob};
Point(15) = {0, rInt, 0, lcglob};

Point(16) = {-rExt, 0, 0, lcglob};
Point(17) = {0, -rExt, 0, lcglob};
Point(18) = {rExt, 0, 0, lcglob};
Point(19) = {0, rExt, 0, lcglob};

Point(20) = {-rCore, 0, 0, lc};
Point(21) = {0, -rCore, 0, lc};
Point(22) = {rCore, 0, 0, lc};
Point(23) = {0, rCore, 0, lc};

Point(24) = {-e/2, -a, 0, lc};
Point(25) = {e/2, -a, 0, lc};
Point(26) = {-e/2, a, 0, lc};
Point(27) = {e/2, a, 0, lc};

Point(28) = {d/2, -aa, 0, lc};
Point(29) = {e/2, -aa, 0, lc};

Line(1) = {2,24};
Line(2) = {25,4};
Line(3) = {24,25};
Line(4) = {5,27};
Line(5) = {26,7};
Line(6) = {27,26};

Line(7) = {2,8};
Circle(8) = {8,6,9};
Line(9) = {9,4};

Line(10) = {5,10};
Circle(11) = {10,3,11};
Line(12) = {11,7};

Circle(13) = {12,1,13};
Circle(14) = {13,1,14};
Circle(15) = {14,1,15};
Circle(16) = {15,1,12};

Circle(17) = {16,1,17};
Circle(18) = {17,1,18};
Circle(19) = {18,1,19};
Circle(20) = {19,1,16};

Circle(21) = {20,1,21};
Circle(22) = {21,1,22};
Circle(23) = {22,1,23};
Circle(24) = {23,1,20};

Line(25) = {29,27};
Line(26) = {26,24};

Line(27) = {4,28};
Line(28) = {28,29};

// inductor 1
Line Loop(51) = {8,9,-2,-3,-1,7};
Plane Surface(52) = {51};

// inductor 2
Line Loop(53) = {-5,-6,-4,10,11,12};
Plane Surface(54) = {53};

// core
Line Loop(55) = {22,23,24,21};
Line Loop(56) = {8,9,27,28,25,-4,10,11,12,-5,26,-1,7};
Plane Surface(57) = {55,-56};

// air (intérieur)
Line Loop(58) = {14,15,16,13};
Plane Surface(59) = {58,-55};

// air à l'infini
Line Loop(60) = {18,19,20,17};
Plane Surface(61) = {60,-58};

// air gap
Line Loop(62) = {2,27,28,25,6,26,3};
Plane Surface(63) = {62};

Field[1] = Attractor;
Field[1].NodesList = {2,28,8,9,5,7,10,11};
Field[1].NNodesByEdge = 10;
Field[1].EdgesList = {1,28,4,5,8,11};

Field[2] = Threshold;
Field[2].IField = 1;
Field[2].LcMin = lc/5;
Field[2].LcMax = lcglob;
Field[2].DistMin = 8*mm;
Field[2].DistMax = 10*mm;

Field[3] = Attractor;
Field[3].NodesList = {1};

Field[4] = Threshold;
Field[4].IField = 3;
Field[4].LcMin = 2*lc;
Field[4].LcMax = lcglob;
Field[4].DistMin = (rCore+rInt)/2;
Field[4].DistMax = rInt;

Field[5] = Min;
Field[5].FieldsList = {2,4};

Background Field = 5;

Physical Surface(CORE) = { 57 };
Physical Surface(INDUCTOR1) = { 52 };
Physical Surface(INDUCTOR2) = { 54 };
Physical Surface(AIR) = { 59 };
Physical Surface(AIR_INF) = { 61 };
Physical Line(GAMMA_INF) = { 17, 18, 19, 20 };
Physical Surface(AIR_GAP) = { 63 };
