//  Team7 benchmark
//  e.g. H. Tsuboi et al., J. Materials Processing Technology 108 (2001) 237-240

Include "Team7.inc" ;

// ------------- scale lengths -------------
pBox = wBox/4. ;
pPlate = wPlate/12.;
pHole = wHole/10.;
pInd = tInd / 2. ;

// ------------- basic elements ------------
// Box (vacuum)
Point(1)={-wPlate/2.-wBox/2., -wPlate/2.-wBox/2., -wBox/2., pBox};
Point(2)={ wPlate/2.+wBox/2., -wPlate/2.-wBox/2., -wBox/2., pBox};
Point(3)={ wPlate/2.+wBox/2.,  wPlate/2.+wBox/2., -wBox/2., pBox};
Point(4)={-wPlate/2.-wBox/2.,  wPlate/2.+wBox/2., -wBox/2., pBox};
Line(1) = {1,2};
Line(2) = {2,3};
Line(3) = {3,4};
Line(4) = {4,1};

// Plate
Point(5)={-wPlate/2., -wPlate/2., 0., pPlate};
Point(6)={ wPlate/2., -wPlate/2., 0., pPlate};
Point(7)={ wPlate/2.,  wPlate/2., 0., pPlate};
Point(8)={-wPlate/2.,  wPlate/2., 0., pPlate};
Line(5) = {5,6};
Line(6) = {6,7};
Line(7) = {7,8};
Line(8) = {8,5};

// Hole
xxh=-wPlate/2.+dHole;
Point(9)  = { xxh,       xxh,       0., pHole};
Point(10) = { xxh+wHole, xxh,       0., pHole};
Point(11) = { xxh+wHole, xxh+wHole, 0., pHole};
Point(12) = { xxh,       xxh+wHole, 0., pHole};
Line(9)  = {9,10};
Line(10) = {10,11};
Line(11) = {11,12};
Line(12) = {12,9};

// Inductor cross section
Point(13)  = { xInd-wInd/2.,      yInd-wInd/2.+rInd, zInd,      pInd};
Point(14)  = { xInd-wInd/2.,      yInd-wInd/2.+rInd, zInd+hInd, pInd};
Point(15)  = { xInd-wInd/2.-tInd, yInd-wInd/2.+rInd, zInd+hInd, pInd};
Point(16)  = { xInd-wInd/2.-tInd, yInd-wInd/2.+rInd, zInd,      pInd};
Line(13)   = {13,14};
Line(14)   = {14,15};
Line(15)   = {15,16};
Line(16)   = {16,13};

// ------------- surfaces ------------

Line Loop(50) = {1,2,3,4};     // box
Plane Surface(51) = {50};
Line Loop(52) = {5,6,7,8};     // plate outer
Line Loop(53) = {9,10,11,12};  // hole
Plane Surface(54) = {52,53};   // plate
Plane Surface(55) = {53};      // hole

Line Loop(56) = {13,14,15,16}; // inductor cross section
Plane Surface(57) = {56};

// ------------- volumes ------------

volAIR2[] = Extrude Surface {51, {0,0,wBox+tPlate+dzInd+hInd}} ;;
Delete { Volume{volAIR2[1]}; }

volPLATE[] = Extrude Surface {54, {0,0,tPlate}} ;;
volCRACK[] = Extrude Surface {55, {0,0,tPlate}} ;;

volCOIL_SW[] = Extrude { {0,0,1}, 
	{xInd-wInd/2.+rInd, yInd-wInd/2.+rInd, zInd}, Pi/2 } 
	{ Surface{57}; } ;
volCOIL_S[] = Extrude {wInd-2*rInd,0,0} 
	{ Surface{volCOIL_SW[0]}; } ;
volCOIL_SE[] = Extrude { {0,0,1}, 
        { xInd+wInd/2.-rInd, yInd-wInd/2.+rInd, zInd}, Pi/2 }
	{ Surface{volCOIL_S[0]}; } ;
volCOIL_E[] = Extrude {0,wInd-2*rInd,0} 
	{ Surface{volCOIL_SE[0]}; } ;
volCOIL_NE[] = Extrude { {0,0,1}, 
        { xInd+wInd/2.-rInd, yInd+wInd/2.-rInd, zInd }, Pi/2 }
	{ Surface{volCOIL_E[0]}; } ;
volCOIL_N[] = Extrude {-wInd+2*rInd,0,0} 
	{ Surface{volCOIL_NE[0]}; } ;
volCOIL_NW[] = Extrude { {0,0,1}, 
        { xInd-wInd/2.+rInd, yInd+wInd/2.-rInd, zInd }, Pi/2 }
	{ Surface{volCOIL_N[0]}; } ;
volCOIL_W[] = Extrude {0,-wInd+2*rInd,0} 
	{ Surface{volCOIL_NW[0]}; } ;

// ------------- core ----------------
llCOREbase = newll;
Line Loop (llCOREbase) = {150,172,194,216,238,260,282,304};
surCOREbase = news;
Plane Surface(surCOREbase) = {llCOREbase};

llCOREtop = newll;
Line Loop (llCOREtop) = {151,173,195,217,239,261,283,305};
surCOREtop = news;
Plane Surface(surCOREtop) = {llCOREtop};

slCORE = newsl;
Surface Loop (slCORE) = {surCOREbase,surCOREtop,
	152,174,196,218,240,262,284,306};
volCORE = newv;
Volume(volCORE) = {slCORE};

// ------------- air  --------------------
slOuterBound = newsl;
Surface Loop (slOuterBound) = {51,66,70,74,78,79};
slPlateBound = newsl;
Surface Loop (slPlateBound) = {54,55,92,96,100,104,121,143};
slCoilBound = newsl;
Surface Loop (slCoilBound) = {surCOREbase,surCOREtop,
	 156,178,200,222,244,266,288,310,
	 160,182,204,226,248,270,292,314,
	 164,186,208,230,252,274,296,318};
volAIR = newv;
Volume(volAIR) = {slOuterBound,slPlateBound,slCoilBound};

// ----------- physical groups ----------------

// outer domain bound
Physical Surface(SURFACEGH0) = {51,66,70,74,78,79};
Physical Volume(AIR) = {volAIR};

Physical Volume(PLATE) = {volPLATE[1]};
Physical Volume(CRACK) = {volCRACK[1]};
Physical Volume(CORE) = {volCORE};
Physical Volume(COIL) = {volCOIL_SW[1],volCOIL_S[1],volCOIL_SE[1],volCOIL_E[1],
	 volCOIL_NE[1],volCOIL_N[1],volCOIL_NW[1],volCOIL_W[1]};

// coil subvolumes to define stranded inductor current density
Physical Volume(COIL_SW) = {volCOIL_SW[1]};
Physical Volume(COIL_S)  = {volCOIL_S[1]};
Physical Volume(COIL_SE) = {volCOIL_SE[1]};
Physical Volume(COIL_E)  = {volCOIL_E[1]};
Physical Volume(COIL_NE) = {volCOIL_NE[1]};
Physical Volume(COIL_N)  = {volCOIL_N[1]};
Physical Volume(COIL_NW) = {volCOIL_NW[1]};
Physical Volume(COIL_W)  = {volCOIL_W[1]};


// surface bounding plate and hole
Physical Surface(SKINPLATE) = {54,55,92,96,100,104,121,143};

// surface all around core
Physical Surface(SKINCORE) =  { surCOREbase,surCOREtop,
	152,174,196,218,240,262,284,306 };

// coil surface all around
Physical Surface(SKINCOIL) = {
	 156,178,200,222,244,266,288,310,
	 152,174,196,218,240,262,284,306,
	 160,182,204,226,248,270,292,314,
	 164,186,208,230,252,274,296,318};
// inner coil surface
Physical Surface(SKINCOIL2) = {152,174,196,218,240,262,284,306};

// cut at bottom core surface
Physical Surface(CUTCORE) = {surCOREbase};



