
lc = 8e-2;

DefineConstant[ f1 = {1, Min 1, Max 1000, Step 1,
                         Name "Parameters/1/4 conductor arc No of nodes"} ];
DefineConstant[ f2 = {30, Min 1, Max 1000, Step 1,
                         Name "Parameters/revolving NO of nodes"} ];
DefineConstant[ f3 = {10, Min 1, Max 1000, Step 1,
                         Name "Parameters/Insulation NO of nodes"} ];
//f1=3;
//f2=30;    

// creating insulation outer boundary (rectangle)

Point(1) = {-.004, .004, 0, lc};
Point(2) = {0.004, 0.004, 0, lc};
Point(3) = {0.004, -0.004, 0, lc};
Point(4) = {-0.004, -0.004, 0, lc};
Line(1) = {1,2} ;
Line(2) = {2,3} ;
Line(3) = {3,4} ;
Line(4) = {4,1} ;
Line Loop(1) = {1, 2, 3, 4};

// defining number of nodes for Insulation

Transfinite Line{1} = f3;
Transfinite Line{2} = f3;
Transfinite Line{3} = f3;
Transfinite Line{4} = f3;

// creating  superconductor cross section

Point(5) = {0, 0, 0, lc};
Point(6) = {0, 0.00035, 0, lc};
Point(7) = {0.00035, 0, 0, lc};
Point(8) = {0, -0.00035, 0, lc};
Point(9) = {-0.00035, 0, 0, lc};
Circle(5) = {6,5,7};
Circle(6) = {7,5,8};
Circle(7) = {8,5,9};
Circle(8) = {9,5,6};
Line Loop(2) = {5, 6, 7, 8};
Plane Surface(2) = {2};



Translate {0.002, 0, 0} { Duplicata{ Surface{2}; } }
Translate {-0.002, 0, 0} { Duplicata{ Surface{2}; } }
Translate {0, 0.002, 0} { Duplicata{ Surface{2}; } }
Translate {0, -0.002, 0} { Duplicata{ Surface{2}; } }
Translate {0.002, 0.002, 0} { Duplicata{ Surface{2}; } }
Translate {0.002, -0.002, 0} { Duplicata{ Surface{2}; } }
Translate {-0.002, -0.002, 0} { Duplicata{ Surface{2}; } }
Translate {-0.002, 0.002, 0} { Duplicata{ Surface{2}; } }


Line Loop(3) = {15, 16, 17, 18};
Line Loop(4) = {10, 11, 12, 13};
Line Loop(5) = {30, 31, 32, 33};
Line Loop(6) = {20, 21, 22, 23};
Line Loop(7) = {45, 46, 47, 48};
Line Loop(8) = {35, 36, 37, 38};
Line Loop(9) = {25, 26, 27, 28};
Line Loop(10) = {40, 41, 42, 43};


// defining number of nodes for conductor

Transfinite Line{5} = f1;
Transfinite Line{6} = f1;
Transfinite Line{7} = f1;
Transfinite Line{8} = f1;
Transfinite Line{15} = f1;
Transfinite Line{16} = f1;
Transfinite Line{17} = f1;
Transfinite Line{18} = f1;
Transfinite Line{10} = f1;
Transfinite Line{11} = f1;
Transfinite Line{12} = f1;
Transfinite Line{13} = f1;
Transfinite Line{20} = f1;
Transfinite Line{21} = f1;
Transfinite Line{22} = f1;
Transfinite Line{23} = f1;
Transfinite Line{30} = f1;
Transfinite Line{31} = f1;
Transfinite Line{32} = f1;
Transfinite Line{33} = f1;
Transfinite Line{45} = f1;
Transfinite Line{46} = f1;
Transfinite Line{47} = f1;
Transfinite Line{48} = f1;
Transfinite Line{35} = f1;
Transfinite Line{36} = f1;
Transfinite Line{37} = f1;
Transfinite Line{38} = f1;
Transfinite Line{25} = f1;
Transfinite Line{26} = f1;
Transfinite Line{27} = f1;
Transfinite Line{28} = f1;
Transfinite Line{40} = f1;
Transfinite Line{41} = f1;
Transfinite Line{42} = f1;
Transfinite Line{43} = f1;


// creating cross section of insulation

Plane Surface(1) = {1,2,3,4,5,6,7,8,9,10};



/// extrusion (creating volume from surfaces)

DefineConstant[ angle = {45, Min 0, Max 179, Step 0.1,
                         Name "Parameters/Revolving angle"} ];
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{2}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{9}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{14}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{19}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{24}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{29}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{34}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{39}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{44}; Layers{f2}; Recombine;
}
Extrude { {0,1,0} , {-0.1,0.004,0} , angle*Pi/180 } {
Surface{1}; Layers{f2}; Recombine;
}

// creating physical domains

Physical Surface(1000) = {1,9,14,19,24,29,34,39,44};         // starting surface (except pulse heat surface)
Physical Surface(2000) = {114,92,136,70,448,246,224,202,180,158}; // ending surface 
Physical Surface(3000) = {2}; // pulse heat surface
Physical Surface(4000) = {303,299,295,291}; // inside, bottom ,outside, top 

Physical Volume(1001) = {1,2,3,4,5,6,7,8,9}; // superconductor
Physical Volume(2001) = {10}; // insulation


