// Gmsh project created on Tue Feb 27 10:44:30 2018 //https://www.cfd-online.com/Forums/electromagnetics/199366-gmsh-mesh-generator-error.html#post683796 //parameters //mesh size factor //lc1=coils mesh size, lcs=sphere mesh size, l = exrution layers Geometry.Tolerance = 1e-5 ; lc1 = 1; lcs = 1; l = 3; //coils dimensions //r=inner radius, R=outer radius, h=thickness,d=distance r = 1; R = 1; h = 1; d = 2; //sphere dimensions //k=centerpoint, skale=sphere size compared to coils (must be > 1), r_s = sphere radius k = (d/2)+h; skale = 2; r_s = Sqrt((k^2 + R^2)) * skale; //primery coils //points for primary coil Point(1) = {0, 0, 0, lc1}; Point(2) = {r, 0, 0, lc1}; Point(3) = {-r, 0, 0, lc1}; Point(4) = {0, r, 0, lc1}; Point(5) = {0, -r, 0, lc1}; Point(6) = {0, -R, 0, lc1}; Point(7) = {0, R, 0, lc1}; Point(8) = {R, 0, 0, lc1}; Point(9) = {-R, 0, 0, lc1}; //edges of primary coil Circle(1) = {3, 1, 4}; Circle(2) = {4, 1, 2}; Circle(3) = {2, 1, 5}; Circle(4) = {5, 1, 3}; Circle(5) = {9, 1, 7}; Circle(6) = {7, 1, 8}; Circle(7) = {8, 1, 6}; Circle(8) = {6, 1, 9}; //extrude of primary coil Extrude {0, 0, h} { Line{5, 6, 7, 8, 1, 2, 3, 4};Layers{l}; } //adding top and bottom surfaces to primary coil Line Loop(41) = {9, 13, 17, 21}; Line Loop(42) = {25, 29, 33, 37}; Plane Surface(43) = {41, 42}; Line Loop(44) = {8, 5, 6, 7}; Line Loop(45) = {4, 1, 2, 3}; Plane Surface(46) = {44, 45}; //addind physical group to surfaces of primary coil Physical Surface(47) = {43}; Physical Surface(48) = {46}; Physical Surface(49) = {28, 32, 36, 40}; Physical Surface(50) = {20, 24, 12, 16}; //adding volume to primary coil Surface Loop(51) = {36, 46, 24, 12, 16, 20, 43, 40, 28, 32}; Volume(52) = {51}; Physical Volume(53) = {52}; //secondary coil //points of secondary coil Point(28) = {0, 0, h+d, lc1}; Point(29) = {r, 0, h+d, lc1}; Point(30) = {-r, 0, h+d, lc1}; Point(31) = {0, r, h+d, lc1}; Point(32) = {0, -r, h+d, lc1}; Point(33) = {0, -R, h+d, lc1}; Point(34) = {0, R, h+d, lc1}; Point(35) = {R, 0, h+d, lc1}; Point(36) = {-R, 0, h+d, lc1}; //edges of secondary coil Circle(54) = {31, 28, 29}; Circle(55) = {29, 28, 32}; Circle(56) = {32, 28, 30}; Circle(57) = {30, 28, 31}; Circle(58) = {34, 28, 35}; Circle(59) = {35, 28, 33}; Circle(60) = {33, 28, 36}; Circle(61) = {36, 28, 34}; //extruding secondary coil Coherence; Extrude {0, 0, h} { Line{58, 59, 60, 61, 57, 54, 55, 56};Layers{l}; } //adding top and bottom surfaces to secondary coil Line Loop(94) = {62, 66, 70, 74}; Line Loop(95) = {82, 86, 90, 78}; Plane Surface(96) = {94, 95}; Line Loop(97) = {61, 58, 59, 60}; Line Loop(98) = {57, 54, 55, 56}; Plane Surface(99) = {97, 98}; //adding physical groups to surfaces of secondary coil Physical Surface(100) = {96}; Physical Surface(101) = {99}; Physical Surface(102) = {81, 85, 93, 89}; Physical Surface(103) = {73, 77, 65, 69}; //adding volume to secondary coil Surface Loop(104) = {73, 99, 77, 65, 69, 96, 81, 85, 89, 93}; Volume(105) = {104}; Physical Volume(106) = {105}; //creating sphere //aloitetaan pisteilla //center point Point(55) = {0, 0, k, lcs}; //top and bottom point Point(56) = {0, 0, k + r_s, lcs}; Point(57) = {0, 0, k - r_s, lcs}; //x direction Point(58) = {r_s, 0, k, lcs}; Point(59) = {-r_s, 0, k, lcs}; //y direction Point(60) = {0, r_s, k, lcs}; Point(61) = {0, -r_s, k, lcs}; //creating edges of sphere Circle(107) = {61, 55, 56}; Circle(108) = {56, 55, 60}; Circle(109) = {60, 55, 57}; Circle(110) = {57, 55, 61}; Circle(111) = {60, 55, 58}; Circle(112) = {58, 55, 61}; Circle(113) = {61, 55, 59}; Circle(114) = {59, 55, 60}; Circle(115) = {56, 55, 58}; Circle(116) = {58, 55, 57}; Circle(117) = {57, 55, 59}; Circle(118) = {59, 55, 56}; //adding surfaces to sphere Line Loop(119) = {108, 111, -115}; Ruled Surface(120) = {119}; Line Loop(121) = {115, 112, 107}; Ruled Surface(122) = {121}; Line Loop(123) = {107, -118, -113}; Ruled Surface(124) = {123}; Line Loop(125) = {118, 108, -114}; Ruled Surface(126) = {125}; Line Loop(127) = {116, -109, 111}; Ruled Surface(128) = {127}; Line Loop(129) = {109, 117, 114}; Ruled Surface(130) = {129}; Line Loop(131) = {117, -113, -110}; Ruled Surface(132) = {131}; Line Loop(133) = {110, -112, 116}; Ruled Surface(134) = {133}; //adding volume to sphere Surface Loop(135) = {132, 130, 128, 134, 122, 120, 126, 124}; Volume(136) = {51, 104, 135}; //adding physical groups to sphere Physical Surface(137) = {122, 124, 126, 120, 128, 130, 132, 134}; Physical Volume(138) = {136};