/* Drawing a magnet */
Include "shift.geo";
/* Defining some parameters */

MagX = 10;	/* Magnet1 Dimensions */
MagY = 8;

MagPX = 0;	/* Center Magnet1 Position */
MagPY = 0;
MagPZ = 0;


Mag2X = MagX;	/* Magnet2 Dimensions */
Mag2Y = MagY;

Mag2PX = 0;		/* Try don't overlap magnets */
Mag2PY = 10;
Mag2PZ = 0;


NumDiv = 30;	/* Number of Divisions */
NumDiv2 = 10;	/* Number of Divisions */

AirX = MagX*4;	/* Air Zone Dimensions */
AirY = MagY*8;  /* Greater than Magnet */

CML = MagX/NumDiv;		/* Computation of Charasteristic Mesh Length */
CML2 = MagX/NumDiv2;		/* Computation of Charasteristic Mesh Length */

/* Points */
/* Magnet 1 */
Point(1)={MagX/2+MagPX+shx,MagY/2+MagPY+shy,0+MagPZ,CML};
Point(2)={MagX/2+MagPX+shx,-MagY/2+MagPY+shy,0+MagPZ,CML};
Point(3)={-MagX/2+MagPX,-MagY/2+MagPY,0+MagPZ,CML};
Point(4)={-MagX/2+MagPX,MagY/2+MagPY,0+MagPZ,CML};

/* Magnet 2 */
Point(5)={Mag2X/2+Mag2PX,Mag2Y/2+Mag2PY,0+Mag2PZ,CML};
Point(6)={Mag2X/2+Mag2PX,-Mag2Y/2+Mag2PY,0+Mag2PZ,CML};
Point(7)={-Mag2X/2+Mag2PX,-Mag2Y/2+Mag2PY,0+Mag2PZ,CML};
Point(8)={-Mag2X/2+Mag2PX,Mag2Y/2+Mag2PY,0+Mag2PZ,CML};


/* AirZone Points */
Point(10)={AirX/2,AirY/2,0,CML2};
Point(20)={AirX/2,-AirY/2,0,CML2};
Point(30)={-AirX/2,-AirY/2,0,CML2};
Point(40)={-AirX/2,AirY/2,0,CML2};


/* Lines */
/* Magnet1 */
Line(12)={1,2};
Line(23)={2,3};
Line(34)={3,4};
Line(41)={4,1};

/* Magnet2 */
Line(56)={5,6};
Line(67)={6,7};
Line(78)={7,8};
Line(85)={8,5};


/* Air */
Line(1020)={10,20};
Line(2030)={20,30};
Line(3040)={30,40};
Line(4010)={40,10};

/* Surfaces */
/* Magnet1 */
Line Loop(100)={12,23,34,41};
Plane Surface(100)={100};
Physical Surface(100)={100};

/* Magnet2 */
Line Loop(110)={56,67,78,85};
Plane Surface(110)={110};
Physical Surface(110)={110};


/* Air */
Line Loop(200)={1020,2030,3040,4010};
Plane Surface(200)={200,100,110};	/* Air - Magnet1 - Magnet2 */
Physical Surface(200)={200};





