
Include "CuboidCyl.par";

fine=0.01*xInt;
medium=0.05*xInt;
coarse=0.1*xInt;

//////////////////////////////////////////////////////////////////////
// Points
// Cylinder surface in domain
Point(0)={0,0,0,fine};
Point(1)={0,rCyl,0,fine};
Point(2)={0,0,rCyl,fine};
Point(3)={xInt,0,rCyl,medium};
Point(4)={xInt,rCyl,0,medium};
Point(5)={xInt,0,0,medium};
// Point(6)={xExt,0,rCyl,coarse};
// Point(7)={xExt,rCyl,0,coarse};
Point(8)={xExt,0,0,coarse};
// Quader containing the inner Domain:
Point(9)={0,yInt,0,medium};
Point(10)={xInt,yInt,0,medium};
Point(11)={0,yQuad,zInt,medium};
Point(12)={xQuad,yQuad,zInt,medium};
Point(13)={xQuad,0,zInt,medium};
Point(14)={xInt,0,zInt,medium};
Point(15)={xInt,yInt,zInt,medium};
Point(16)={0,yInt,zInt,medium};
Point(17)={0,0,zQuad,fine};
Point(18)={xQuad,0,zQuad,fine};
Point(19)={xQuad,yQuad,zQuad,fine};
Point(20)={0,yQuad,zQuad,fine};
// Quader containing the outer Domain:
Point(21)={0,yExt,0,coarse};
Point(22)={xExt,yExt,0,coarse};
Point(24)={xExt,0,zExt,coarse};
Point(25)={xExt,yExt,zExt,coarse};
Point(26)={0,yExt,zExt,coarse};
Point(28)={0,0,zExt,coarse};
Point(29)={0,0,zInt,medium};
//////////////////////////////////////////////////////////////////////
// Lines
// cylinder surface in inner domain
Circle(1)={1,0,2};
Line(2)={2,3};
Circle(3)={3,5,4};
Line(4)={1,4};

// cylinder surface in external domain (with infinity transformation)
Line(5)={3,5};
Line(6)={4,5};
Line(7)={5,8};

// quader containing the inner domain:
Line(8)={1,9};
Line(9)={9,10};
Line(10)={4,10};
Line(11)={17,20};
Line(12)={17,18};
Line(13)={18,19};
Line(14)={19,20};
Line(15)={11,20};
Line(16)={12,19};
Line(17)={13,18};
Line(18)={9,16};
Line(19)={10,15};
Line(20)={3,14};
Line(21)={11,16};
Line(22)={11,12};
Line(23)={12,13};
Line(24)={13,14};
Line(25)={14,15};
Line(26)={15,16};
Line(27)={2,17};

// additional lines for quader containing outer domain:
Line(28)={9,21};
Line(29)={21,22};
Line(30)={8,22};
Line(31)={21,26};
Line(32)={22,25};
Line(33)={8,24};
Line(34)={24,28};
Line(35)={24,25};
Line(36)={25,26};
Line(37)={26,28};
Line(38)={28,29};
Line(40)={11,29};
Line(41)={13,29};

//////////////////////////////////////////////////////////////////////
// Line Loops
Line Loop(1)={4,-3,-2,-1}; // cylinder inner domain
Line Loop(2)={-5,3,6}; // outer bound of cylinder
// Line Loops of inner domain volume:
Line Loop(3)={-8,1,27,11,-15,21,-18}; // min x quader surface inner domain
Line Loop(4)={-14,-16,-22,15}; // max y surface of magnetic core quader
Line Loop(5)={-17,-23,16,-13}; // max x surface of magnetic core quader
Line Loop(6)={13,14,-11,12}; // min z surface of magnetic core quader
Line Loop(7)={20,-24,17,-12,-27,2}; // min y quader surface inner domain
Line Loop(8)={-4,8,9,-10}; // min z quader surface inner domain
Line Loop(9)={10,19,-25,-20,3}; // max x quader surface inner domain
Line Loop(10)={18,-26,-19,-9}; // max y quader surface inner domain
Line Loop(11)={24,25,26,-21,22,23}; // max z quader surface inner domain
// Additional line loops of outer domain volume:
Line Loop(12)={28,29,-30,-7,-6,10,-9};
Line Loop(13)={33,34,38,-41,24,-20,5,7};
Line Loop(14)={30,32,-35,-33};
Line Loop(15)={-29,31,-36,-32};
Line Loop(16)={-28,18,-21,40,-38,-37,-31};
Line Loop(17)={22,23,41,-40};
Line Loop(18)={-34,35,36,37};

//////////////////////////////////////////////////////////////////////
// Surfaces
Ruled Surface(1)={1};
Plane Surface(2)={2};

For i In {3:18}
  Plane Surface(i) = {i};
EndFor
//////////////////////////////////////////////////////////////////////
// Volumes
Surface Loop(1)={1,3:11}; Volume(1) = {1};
Surface Loop(2)={2,-9,-10,-11,12:18}; Volume(2) = {2};

//////////////////////////////////////////////////////////////////////
// Physical Objects

// Surfaces:
Physical Surface(11) = {1,2};
Physical Surface(12) = {4,5,6,17,18};
// Volumes:
Physical Volume(1) = {1};
Physical Volume(2) = {2};
