
/* Defining Geomtry Parameters */

air_b = 1e-1;  			// boundary for air
mag_r = 6e-3;   			// radius of cylinderical magnet
mag_h = 5e-3;  			// magnet height
gap_h = 10e-3;			// vertical distance between two magnets (in case of two rings)
p = 0.001;   			// characterisitcs length for the magnet
q = 0.005;   			//characterisitcs length for air

/* Creating first cylindrical magnet  */

Point(101) = {0.0, 0.0, 0.0, p};
Point(102) = {mag_r, 0, 0, p};
Point(103) = {0, mag_r, 0, p};
Point(104) = {-mag_r, 0, 0, p};
Point(105) = {0, -mag_r, 0, p};

Circle(1) = {102, 101, 103};
Circle(2) = {103, 101, 104};
Circle(3) = {104, 101, 105};
Circle(4) = {105, 101, 102};

Line Loop(5) = {1,2,3,4};
Plane Surface(6) = {5};

/* Creating second cylindrical magnet  */

Point(206) = {0.0, 0.0, gap_h, p};
Point(207) = {mag_r, 0, gap_h, p};
Point(208) = {0, mag_r, gap_h, p};
Point(209) = {-mag_r, 0, gap_h, p};
Point(210) = {0, -mag_r, gap_h, p};

Circle(21) = {207, 206, 208};
Circle(22) = {208, 206, 209};
Circle(23) = {209, 206, 210};
Circle(24) = {210, 206, 207};

Line Loop(25) = {21,22,23,24};
Plane Surface(26) = {25};

/* define the points for the air domain */

Point(301) = { air_b/2,  air_b/2,  air_b/2, q};
Point(302) = { air_b/2, -air_b/2,  air_b/2, q};
Point(303) = { air_b/2, -air_b/2, -air_b/2, q};
Point(304) = { air_b/2,  air_b/2, -air_b/2, q};
Point(305) = {-air_b/2,  air_b/2,  air_b/2, q};
Point(306) = {-air_b/2, -air_b/2,  air_b/2, q};
Point(307) = {-air_b/2, -air_b/2, -air_b/2, q};
Point(308) = {-air_b/2,  air_b/2, -air_b/2, q};

Line(49) = {305,301};
Line(50) = {301,304};
Line(51) = {304,308};
Line(52) = {308,305};
Line(53) = {305,306};
Line(54) = {306,307};
Line(55) = {307,303};
Line(56) = {303,302};
Line(57) = {302,306};
Line(58) = {302,301};
Line(59) = {307,308};
Line(60) = {303,304};

Line Loop(61) = {49,-58,57,-53};
Plane Surface(62) = {61};
Line Loop(63) = {50,-60,56,58};
Plane Surface(64) = {63};
Line Loop(65) = {60,51,-59,55};
Plane Surface(66) = {65};
Line Loop(67) = {59,52,53,54};
Plane Surface(68) = {67};
Line Loop(69) = {55,56,57,54};
Plane Surface(70) = {69};
Line Loop(71) = {51,52,49,50};  
Plane Surface(72) = {71};
Surface Loop(73) = {64,72,66,68,62,70};

/* Extrusion for two cylinders defined above */

out1[] = Extrude {0,0,mag_h} {Surface{6}; Layers{4}; };
out2[] = Extrude {0,0,mag_h} {Surface{26};Layers{4}; };

// *************************************************************** //
/* Here I have to define the volume of cube excluding the two cylinders  */


Volume(74) = {73};  

// Volumes

Physical Volume(600) = {out1[1]}; //magnet1 
Physical Volume(601) = {out2[1]}; //magnet2
Physical Volume(605) = {74, out1[1], out2[1]}; //air

// Surfaces

Physical Surface(1000) = {62, 64, 66, 68, 70, 72}; //system boundary

