//gmsh t2.geo -3 -optimize -order 2
//ElmerGrid 14 2 t2.msh -autoclean

 	//geometry options
	h = 1;  k = 1/1 ;//0.1,h - height, k = scaling factor of r_tube
	d_kapton = 0.3*k;//0.03mm, d_kapton - width of dielectric on cathode surface, d_kapton < h
	r_wire = 0.03/2;//0.015*mm
	r_tube = 9.8/2*k;//4.9*mm
	Thickness = 0.03;//0.03*mm, Thickness of tube

	//mesh options
	dolgota = 20;//longitude,361
	zazor = 4;//longitude in gap(in main area) sector
	shirota = 120;//latitude of main area,320
	layers = 2;//latitude of cathode volume and gas gap volume between cathodes, or layers along radius vector in cathode volume and in gas gap volume between cathodes, v katode
	kateti = 4;//layers along Z axe in cathode volume 
	delta = 4;//layers along Z axe in gas gap between cathodes,zazor mejdu katodami

	//don't change
	x = 0; y = 0; z = -h/2;w = h/20;//h/20
	lc_wire = 0.01;
	lc_gas = 0.1;
	lc_tube = 0.01;
	n = 10;//number of points for one quater
	n = n*4 - 3;//number of points for hole tube

//////////////////////////////////////////////////////
//
//		OUTER TUBE WITH DIVISION
//
//////////////////////////////////////////////////////

	lc = lc_tube;
	hw = h - 2*w;
	r = r_tube;
	d = d_kapton;
	angle_alpha = Atan(hw/2/Pi/r);
	z_step = (hw - d_kapton/Cos(angle_alpha))/(n-1);
	angle = (2*Pi - 2*d/r)/(n-1);
	
	// division lines
	
	T_p_div_out_1=newp;
	For i In {0:n-1}
		Point(T_p_div_out_1 + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z + i*z_step  , lc_tube}; 		
	EndFor
	
	T_p_div_out_2=newp;
	For i In {0:n-1}
		Point(T_p_div_out_2 + i)= {x + r*Cos(i*angle), y + r*Sin(i*angle), z + i*z_step + d_kapton/Cos(angle_alpha) , lc_tube}; 
	EndFor
	// bot and top lines
	T_p_bot=newp;
	For i In {0:n-1}
		Point(T_p_bot + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z - w, lc_tube}; 
	EndFor

	T_p_top=newp;
	For i In {0:n-1}
		Point(T_p_top + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z + hw+w, lc_tube}; 
	EndFor
	
//////////////////////////////////////////////////////
//
//		INNER TUBE WITH DIVISION
//
//////////////////////////////////////////////////////
	hw = h - 2*w;
	r = r_tube - Thickness;
	d = d_kapton/r_tube*r;
	z_step = (hw - d_kapton/Cos(angle_alpha))/(n-1);
	angle = (2*Pi - 2*d/r)/(n-1);
	
	// division lines
	
	T_p_div_in_1=newp;
	For i In {0:n-1}
		Point(T_p_div_in_1 + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z + i*z_step  , lc_gas}; 		
	EndFor
	
	T_p_div_in_2=newp;
	For i In {0:n-1}
		Point(T_p_div_in_2 + i)= {x + r*Cos(i*angle), y + r*Sin(i*angle), z + i*z_step + d_kapton/Cos(angle_alpha) , lc_gas}; 
	EndFor
	// bot and top lines
	T_p_in_bot=newp;
	For i In {0:n-1}
		Point(T_p_in_bot + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z - w, lc_gas}; 
	EndFor

	T_p_in_top=newp;
	For i In {0:n-1}
		Point(T_p_in_top + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z + hw+w, lc_gas}; 
	EndFor

	lc = lc_wire;
	hw = h - 2*w;
	r = r_wire;
	d = d_kapton/r_tube*r;
	z_step = (hw - d_kapton/Cos(angle_alpha))/(n-1);
	angle = (2*Pi - 2*d/r)/(n-1);
	
	// division lines
	
	W_p_div_out_1=newp;
	For i In {0:n-1}
		Point(W_p_div_out_1 + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z + i*z_step  , lc_wire}; 		
	EndFor
	
	W_p_div_out_2=newp;
	For i In {0:n-1}
		Point(W_p_div_out_2 + i)= {x + r*Cos(i*angle), y + r*Sin(i*angle), z + i*z_step + d_kapton/Cos(angle_alpha) , lc_wire}; 
	EndFor
	// bot and top lines
	W_p_out_bot=newp;
	For i In {0:n-1}
		Point(W_p_out_bot + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z - w, lc_wire}; 
	EndFor

	W_p_out_top=newp;
	For i In {0:n-1}
		Point(W_p_out_top + i)= { x + r*Cos(i*angle), y + r*Sin(i*angle), z + hw+w, lc_wire}; 
	EndFor
	

	Point(445) = {x, y, z - w, lc_wire};
	Point(446) = {x, y, z + hw+w, lc_wire};
	Point(447) = {x, y, z - w + hw/3+w/3, lc_wire};
	Point(448) = {x, y, z - w + 2*hw/3+2*w/3, lc_wire};

//////////////////////////////////////////////////////
//
//		INNER and OUTER TUBE CONNECTION
//
//////////////////////////////////////////////////////

	l=newl;
	Spline(l) = {T_p_bot:T_p_bot + n/4};
	Spline(l+1) = {T_p_div_out_1:T_p_div_out_1 + n/4};
	Spline(l+2) = {T_p_div_out_2:T_p_div_out_2 + n/4};
	Spline(l+3) = {T_p_top:T_p_top + n/4};
	Line(l+4) = {T_p_bot + n-1,T_p_div_out_1 + n-1};
	Line(l+5) = {T_p_div_out_2,T_p_top};
	Line(l+6) = {T_p_div_out_2 + n-1,T_p_top + n-1};
	Line(l+7) = {T_p_bot,T_p_div_out_1};
	l=newl;

	Spline(l) = {T_p_in_bot:T_p_in_bot + n/4};
	Spline(l+1) = {T_p_div_in_1:T_p_div_in_1 + n/4};
	Spline(l+2) = {T_p_div_in_2:T_p_div_in_2 + n/4};
	Spline(l+3) = {T_p_in_top:T_p_in_top + n/4};
	Line(l+4) = {T_p_in_bot + n-1,T_p_div_in_1 + n-1};
	Line(l+5) = {T_p_div_in_2,T_p_in_top};
	Line(l+6) = {T_p_div_in_2 + n-1,T_p_in_top + n-1};
	Line(l+7) = {T_p_in_bot,T_p_div_in_1};//+
	
	Line(17) = {75, 223};
	Line(18) = {1, 149};
	Line(19) = {38, 186};
	Line(20) = {259, 111};
	Line(21) = {260, 112};
	Line(22) = {296, 148};
	Line(23) = {222, 74};
	Line(24) = {185, 37};
	Line(25) = {260, 296};
	Line(26) = {112, 148};
	Line(27) = {74, 37};
	Line(28) = {222, 185};
	Line(29) = {75, 111};
	Line(30) = {223, 259};
	Line(31) = {149, 186};
	Line(32) = {1, 38};
//////////////////////////////////////////////////////
//
//		WIRE
//
//////////////////////////////////////////////////////



	l=newl;
	Spline(l) = {W_p_out_bot:W_p_out_bot + n/4};
	Spline(l+1) = {W_p_div_out_1:W_p_div_out_1 + n/4};
	Spline(l+2) = {W_p_div_out_2:W_p_div_out_2 + n/4};
	Spline(l+3) = {W_p_out_top:W_p_out_top + n/4};
	Line(l+4) = {W_p_out_bot + n-1,W_p_div_out_1 + n-1};
	Line(l+5) = {W_p_div_out_2,W_p_out_top};
	Line(l+6) = {W_p_div_out_2 + n-1,W_p_out_top + n-1};
	Line(l+7) = {W_p_out_bot,W_p_div_out_1};

// linii glavnogo zazora	
	Line(41) = {333, 370};
	Line(42) = {297, 334};
	Line(43) = {407, 371};
	Line(44) = {444, 408};
	Line(45) = {444, 296};
	Line(46) = {370, 222};
	Line(47) = {333, 185};
	Line(48) = {260, 408};
	Line(49) = {223, 371};
	Line(50) = {149, 297};
	Line(51) = {186, 334};
	Line(52) = {259, 407};

	Line(53) = {370, 334};
	Line(54) = {333, 297};
	Line(55) = {222, 186};
	Line(56) = {149, 185};
	Line(57) = {74, 38};
	Line(58) = {1, 37};

//////////////////////////////////////////////////////
//
//		OUTER TUBE WITH DIVISION PART 2
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {T_p_bot + n/4:T_p_bot + n/2};
	Spline(l+1) = {T_p_div_out_1 + n/4:T_p_div_out_1 + n/2};
	Spline(l+2) = {T_p_div_out_2 + n/4:T_p_div_out_2 + n/2};
	Spline(l+3) = {T_p_top + n/4:T_p_top + n/2};
//////////////////////////////////////////////////////
//
//		INNER TUBE WITH DIVISION PART 2
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {T_p_in_bot + n/4:T_p_in_bot + n/2};
	Spline(l+1) = {T_p_div_in_1 + n/4:T_p_div_in_1 + n/2};
	Spline(l+2) = {T_p_div_in_2 + n/4:T_p_div_in_2 + n/2};
	Spline(l+3) = {T_p_in_top + n/4:T_p_in_top + n/2};
//////////////////////////////////////////////////////
//
//		WIRE WITH DIVISION PART 2
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {W_p_out_bot + n/4:W_p_out_bot + n/2};
	Spline(l+1) = {W_p_div_out_1 + n/4:W_p_div_out_1 + n/2};
	Spline(l+2) = {W_p_div_out_2 + n/4:W_p_div_out_2 + n/2};
	Spline(l+3) = {W_p_out_top + n/4:W_p_out_top + n/2};
//+
	
//////////////////////////////////////////////////////
//
//		OUTER TUBE WITH DIVISION PART 3
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {T_p_bot + n/2:T_p_bot + 3*n/4};
	Spline(l+1) = {T_p_div_out_1 + n/2:T_p_div_out_1 + 3*n/4};
	Spline(l+2) = {T_p_div_out_2 + n/2:T_p_div_out_2 + 3*n/4};
	Spline(l+3) = {T_p_top + n/2:T_p_top + 3*n/4};
//////////////////////////////////////////////////////
//
//		INNER TUBE WITH DIVISION PART 3
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {T_p_in_bot + n/2:T_p_in_bot + 3*n/4};
	Spline(l+1) = {T_p_div_in_1 + n/2:T_p_div_in_1 + 3*n/4};
	Spline(l+2) = {T_p_div_in_2 + n/2:T_p_div_in_2 + 3*n/4};
	Spline(l+3) = {T_p_in_top + n/2:T_p_in_top + 3*n/4};
//////////////////////////////////////////////////////
//
//		WIRE WITH DIVISION PART 3
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {W_p_out_bot + n/2:W_p_out_bot + 3*n/4};
	Spline(l+1) = {W_p_div_out_1 + n/2:W_p_div_out_1 + 3*n/4};
	Spline(l+2) = {W_p_div_out_2 + n/2:W_p_div_out_2 + 3*n/4};
	Spline(l+3) = {W_p_out_top + n/2:W_p_out_top + 3*n/4};
	//+
//////////////////////////////////////////////////////
//
//		OUTER TUBE WITH DIVISION PART 4
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {T_p_bot + 3*n/4:T_p_bot + n};
	Spline(l+1) = {T_p_div_out_1 + 3*n/4:T_p_div_out_1 + n};
	Spline(l+2) = {T_p_div_out_2 + 3*n/4:T_p_div_out_2 + n};
	Spline(l+3) = {T_p_top + 3*n/4:T_p_top + n};
//////////////////////////////////////////////////////
//
//		INNER TUBE WITH DIVISION PART 4
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {T_p_in_bot + 3*n/4:T_p_in_bot + n};
	Spline(l+1) = {T_p_div_in_1 + 3*n/4:T_p_div_in_1 + n};
	Spline(l+2) = {T_p_div_in_2 + 3*n/4:T_p_div_in_2 + n};
	Spline(l+3) = {T_p_in_top + 3*n/4:T_p_in_top + n};
//////////////////////////////////////////////////////
//
//		WIRE WITH DIVISION PART 4
//
//////////////////////////////////////////////////////
	l=newl;
	Spline(l) = {W_p_out_bot + 3*n/4:W_p_out_bot + n};
	Spline(l+1) = {W_p_div_out_1 + 3*n/4:W_p_div_out_1 + n};
	Spline(l+2) = {W_p_div_out_2 + 3*n/4:W_p_div_out_2 + n};
	Spline(l+3) = {W_p_out_top + 3*n/4:W_p_out_top + n};

//lines of main parts

	Line(95) = {417, 269};
	Line(96) = {269, 121};
	Line(97) = {47, 195};
	Line(98) = {195, 343};
	Line(99) = {306, 158};
	Line(100) = {158, 10};
	Line(101) = {84, 232};
	Line(102) = {232, 380};
	Line(103) = {121, 47};
	Line(104) = {47, 10};
	Line(105) = {10, 84};
	Line(106) = {269, 195};
	Line(107) = {195, 158};
	Line(108) = {158, 232};
	Line(109) = {417, 343};
	Line(110) = {343, 306};
	Line(111) = {306, 380};
	Line(112) = {278, 426};
	Line(113) = {130, 278};
	Line(114) = {56, 204};
	Line(115) = {19, 167};
	Line(116) = {204, 352};
	Line(117) = {167, 315};
	Line(118) = {93, 241};
	Line(119) = {241, 389};
	Line(120) = {130, 56};
	Line(121) = {56, 19};
	Line(122) = {19, 93};
	Line(123) = {278, 204};
	Line(124) = {204, 167};
	Line(125) = {167, 241};
	Line(126) = {426, 352};
	Line(127) = {352, 315};
	Line(128) = {315, 389};
	Line(129) = {435, 287};
	Line(130) = {287, 139};
	Line(131) = {65, 213};
	Line(132) = {28, 176};
	Line(133) = {361, 213};
	Line(134) = {324, 176};
	Line(135) = {102, 250};
	Line(136) = {250, 398};
	Line(137) = {139, 65};
	Line(138) = {65, 28};
	Line(139) = {28, 102};
	Line(140) = {287, 213};
	Line(141) = {213, 176};
	Line(142) = {176, 250};
	Line(143) = {435, 361};
	Line(144) = {361, 324};
	Line(145) = {324, 398};

	Line(210) = {446, 417};
	Line(201) = {446, 408};
	Line(202) = {446, 426};
	Line(203) = {446, 435};
	Line(204) = {446, 444};
	Line(205) = {389, 445};
	Line(206) = {445, 398};
	Line(207) = {445, 407};
	Line(208) = {445, 371};
	Line(209) = {445, 380};

	Line(231) = {446, 448};
	Line(232) = {448, 447};
	Line(233) = {447, 445};
	Line(234) = {448, 334};
	Line(235) = {297, 447};
	Line(236) = {447, 333};
	Line(237) = {448, 370};
	Line(238) = {448, 361};
	Line(239) = {324, 447};
	Line(240) = {448, 352};
	Line(241) = {315, 447};
	Line(242) = {448, 343};
	Line(243) = {306, 447};

	//GLAVNII zazor mejdu katetami katodov
	Line Loop(18) = {39, 45, -15, -46};
	Surface(18) = {18};
	Line Loop(19) = {41, 46, 28, -47};
	Surface(19) = {19};
	Line Loop(20) = {37, 47, -13, 52};
	Surface(20) = {20};
	Line Loop(21) = {51, -42, -50, 31};
	Surface(21) = {21};
	Line Loop(22) = {50, -40, -49, 16};
	Surface(22) = {22};
	Line Loop(23) = {44, -48, 25, -45};
	Surface(23) = {23};
	Line Loop(24) = {43, -49, 30, 52};
	Surface(24) = {24};
	Line Loop(28) = {15, 22, -7, -23};
	Surface(28) = {28};
	Line Loop(29) = {28, 24, -27, -23};
	Surface(29) = {29};
	Line Loop(30) = {13, 24, -5, -20};
	Surface(30) = {30};
	Line Loop(31) = {16, -18, -8, 17};
	Surface(31) = {31};
	Line Loop(32) = {31, -19, -32, 18};
	Surface(32) = {32};
	Line Loop(33) = {6, -21, -14, -19};
	Surface(33) = {33};
	Line Loop(34) = {25, 22, -26, -21};
	Surface(34) = {34};
	Line Loop(38) = {30, 20, -29, 17};
	Surface(38) = {38};
	Line Loop(39) = {48, -38, -51, 14};
	Surface(39) = {39};
	Line Loop(40) = {44, -38, -53, 39};
	Surface(40) = {40};
	Line Loop(41) = {41, 53, -42, -54};
	Surface(41) = {41};
	Line Loop(42) = {37, 54, -40, -43};
	Surface(42) = {42};
	Line Loop(43) = {25, -15, 55, 14};
	Surface(43) = {43};
	Line Loop(44) = {28, -56, 31, -55};
	Surface(44) = {44};
	Line Loop(45) = {13, -56, -16, 30};
	Surface(45) = {45};
	Line Loop(46) = {26, -7, 57, 6};
	Surface(46) = {46};
	Line Loop(47) = {27, -58, 32, -57};
	Surface(47) = {47};
	Line Loop(48) = {58, -5, -29, 8};
	Surface(48) = {48};
	Line Loop(49) = {46, 55, 51, -53};
	Surface(49) = {49};
	Line Loop(50) = {47, -56, 50, -54};
	Surface(50) = {50};
	Line Loop(51) = {23, 57, 19, -55};
	Surface(51) = {51};
	Line Loop(52) = {18, 56, 24, -58};
	Surface(52) = {52};
	
	Line Loop(53) = {2, 105, -1, 8};
	Surface(53) = {53};
	Line Loop(54) = {32, 3, 104, -2};
	Surface(54) = {54};
	Line Loop(55) = {3, -103, -4, -6};
	Surface(55) = {55};
	Line Loop(56) = {1, 101, -9, -17};
	Surface(56) = {56};
	Line Loop(57) = {9, -108, -10, -16};
	Surface(57) = {57};
	Line Loop(58) = {10, -107, -11, -31};
	Surface(58) = {58};
	Line Loop(59) = {11, -106, -12, -14};
	Surface(59) = {59};
	Line Loop(60) = {33, -111, -34, -40};
	Surface(60) = {60};
	Line Loop(61) = {34, -110, -35, -42};
	Surface(61) = {61};
	Line Loop(62) = {38, 36, 109, -35};
	Surface(62) = {62};
	Line Loop(63) = {9, 102, -33, -49};
	Surface(63) = {63};
	Line Loop(64) = {2, -100, -10, -18};
	Surface(64) = {64};
	Line Loop(65) = {97, -11, -19, 3};
	Surface(65) = {65};
	Line Loop(66) = {10, -99, -34, -50};
	Surface(66) = {66};
	Line Loop(67) = {98, -35, -51, 11};
	Surface(67) = {67};
	Line Loop(68) = {4, -96, -12, 21};
	Surface(68) = {68};
	Line Loop(69) = {36, 95, -12, 48};
	Surface(69) = {69};
	Line Loop(70) = {105, 101, -108, 100};
	Surface(70) = {70};
	Line Loop(71) = {99, 108, 102, -111};
	Surface(71) = {71};
	Line Loop(72) = {100, -104, 97, 107};
	Surface(72) = {72};
	Line Loop(73) = {98, 110, 99, -107};
	Surface(73) = {73};
	Line Loop(74) = {97, -106, 96, 103};
	Surface(74) = {74};
	Line Loop(75) = {95, 106, 98, -109};
	Surface(75) = {75};
	Line Loop(76) = {101, 63, -118, -59};
	Surface(76) = {76};
	Line Loop(77) = {63, 119, -67, -102};
	Surface(77) = {77};
	Line Loop(78) = {96, 62, 113, -66};
	Surface(78) = {78};
	Line Loop(79) = {95, 66, 112, -70};
	Surface(79) = {79};
	Line Loop(80) = {105, 59, -122, -60};
	Surface(80) = {80};
	Line Loop(81) = {61, 121, -60, -104};
	Surface(81) = {81};
	Line Loop(82) = {120, -61, -103, 62};
	Surface(82) = {82};
	Line Loop(83) = {125, -63, -108, 64};
	Surface(83) = {83};
	Line Loop(84) = {65, 124, -64, -107};
	Surface(84) = {84};
	Line Loop(85) = {123, -65, -106, 66};
	Surface(85) = {85};
	Line Loop(86) = {67, -128, -68, 111};
	Surface(86) = {86};
	Line Loop(87) = {127, -68, -110, 69};
	Surface(87) = {87};
	Line Loop(88) = {109, 69, -126, -70};
	Surface(88) = {88};
	Line Loop(89) = {60, 115, -64, 100};
	Surface(89) = {89};
	Line Loop(90) = {114, -65, -97, 61};
	Surface(90) = {90};
	Line Loop(91) = {64, 117, -68, 99};
	Surface(91) = {91};
	Line Loop(92) = {98, 69, -116, -65};
	Surface(92) = {92};
	Line Loop(93) = {122, 118, -125, -115};
	Surface(93) = {93};
	Line Loop(94) = {125, 119, -128, -117};
	Surface(94) = {94};
	Line Loop(95) = {114, 124, -115, -121};
	Surface(95) = {95};
	Line Loop(96) = {116, 127, -117, -124};
	Surface(96) = {96};
	Line Loop(97) = {113, 123, -114, -120};
	Surface(97) = {97};
	Line Loop(98) = {112, 126, -116, -123};
	Surface(98) = {98};
	Line Loop(99) = {118, 75, -135, -71};
	Surface(99) = {99};
	Line Loop(100) = {79, -136, -75, 119};
	Surface(100) = {100};
	Line Loop(101) = {113, 78, 130, -74};
	Surface(101) = {101};
	Line Loop(102) = {82, 129, -78, 112};
	Surface(102) = {102};
	Line Loop(103) = {122, 71, -139, -72};
	Surface(103) = {103};
	Line Loop(104) = {138, -72, -121, 73};
	Surface(104) = {104};
	Line Loop(105) = {137, -73, -120, 74};
	Surface(105) = {105};
	Line Loop(106) = {125, 75, -142, -76};
	Surface(106) = {106};
	Line Loop(107) = {141, -76, -124, 77};
	Surface(107) = {107};
	Line Loop(108) = {140, -77, -123, 78};
	Surface(108) = {108};
	Line Loop(109) = {79, -145, -80, 128};
	Surface(109) = {109};
	Line Loop(110) = {80, -144, -81, 127};
	Surface(110) = {110};
	Line Loop(111) = {126, 81, -143, -82};
	Surface(111) = {111};
	Line Loop(112) = {72, 132, -76, -115};
	Surface(112) = {112};
	Line Loop(113) = {131, -77, -114, 73};
	Surface(113) = {113};
	Line Loop(114) = {80, 134, -76, 117};
	Surface(114) = {114};
	Line Loop(115) = {81, 133, -77, 116};
	Surface(115) = {115};
	Line Loop(116) = {135, -142, -132, 139};
	Surface(116) = {116};
	Line Loop(117) = {145, -136, -142, -134};
	Surface(117) = {117};
	Line Loop(118) = {132, -141, -131, 138};
	Surface(118) = {118};
	Line Loop(119) = {133, 141, -134, -144};
	Surface(119) = {119};
	Line Loop(120) = {130, 137, 131, -140};
	Surface(120) = {120};
	Line Loop(121) = {129, 140, -133, -143};
	Surface(121) = {121};
	Line Loop(122) = {135, 87, 20, -83};
	Surface(122) = {122};
	Line Loop(123) = {136, 91, -52, -87};
	Surface(123) = {123};
	Line Loop(124) = {130, 86, -22, -90};
	Surface(124) = {124};
	Line Loop(125) = {129, 90, -45, -94};
	Surface(125) = {125};
	Line Loop(126) = {139, 83, 5, -84};
	Surface(126) = {126};
	Line Loop(127) = {138, 84, -27, -85};
	Surface(127) = {127};
	Line Loop(128) = {137, 85, 7, -86};
	Surface(128) = {128};
	Line Loop(129) = {87, 13, -88, 142};
	Surface(129) = {129};
	Line Loop(130) = {88, -28, -89, 141};
	Surface(130) = {130};
	Line Loop(131) = {89, 15, -90, 140};
	Surface(131) = {131};
	Line Loop(132) = {145, 91, 37, -92};
	Surface(132) = {132};
	Line Loop(133) = {92, 41, -93, 144};
	Surface(133) = {133};
	Line Loop(134) = {93, 39, -94, 143};
	Surface(134) = {134};
	Line Loop(135) = {132, 88, 24, -84};
	Surface(135) = {135};
	Line Loop(136) = {85, -23, -89, -131};
	Surface(136) = {136};
	Line Loop(137) = {88, -47, -92, 134};
	Surface(137) = {137};
	Line Loop(138) = {89, -46, -93, 133};
	Surface(138) = {138};
	

//////////////////////////////////////////////////////
//
//		WIRE VOLUME
//
//////////////////////////////////////////////////////



Line Loop(211) = {210, -36, -201};
Surface(212) = {211};
Line Loop(213) = {210, 70, -202};
Surface(214) = {213};
Line Loop(215) = {202, 82, -203};
Surface(216) = {215};
Line Loop(217) = {203, 94, -204};
Surface(218) = {217};
Line Loop(219) = {204, 44, -201};
Surface(220) = {219};
Line Loop(221) = {209, 67, 205};
Surface(222) = {221};
Line Loop(223) = {209, -33, -208};
Surface(224) = {223};
Line Loop(225) = {-205, 79, -206};
Surface(226) = {225};
Line Loop(227) = {206, 91, -207};
Surface(228) = {227};
Line Loop(229) = {208, -43, -207};
Surface(230) = {229};


Line Loop(244) = {231, 237, 39, -204};
Surface(245) = {244};
Line Loop(246) = {232, 236, 41, -237};
Surface(247) = {246};
Line Loop(248) = {233, 207, 37, -236};
Surface(249) = {248};
Line Loop(250) = {201, -38, -234, -231};
Surface(251) = {250};
Line Loop(252) = {232, -235, 42, -234};
Surface(253) = {252};
Line Loop(254) = {40, 235, 233, 208};
Surface(255) = {254};
Line Loop(256) = {242, -35, -234};
Surface(257) = {256};
Line Loop(258) = {-243, -34, 235};
Surface(259) = {258};
Line Loop(260) = {242, 69, -240};
Surface(261) = {260};
Line Loop(262) = {-243, 68, 241};
Surface(263) = {262};
Line Loop(264) = {240, 81, -238};
Surface(265) = {264};
Line Loop(266) = {-241, 80, 239};
Surface(267) = {266};
Line Loop(268) = {238, 93, -237};
Surface(269) = {268};
Line Loop(270) = {-239, 92, -236};
Surface(271) = {270};
Line Loop(272) = {210, 109, -242, -231};
Surface(273) = {272};
Line Loop(274) = {232, -243, -110, -242};
Surface(275) = {274};
Line Loop(276) = {233, 209, -111, 243};
Surface(277) = {276};
Line Loop(278) = {202, 126, -240, -231};
Surface(279) = {278};
Line Loop(280) = {232, -241, -127, -240};
Surface(281) = {280};
Line Loop(282) = {233, -205, -128, 241};
Surface(283) = {282};
Line Loop(284) = {203, 143, -238, -231};
Surface(285) = {284};
Line Loop(286) = {144, 239, -232, 238};
Surface(287) = {286};
Line Loop(288) = {145, -206, -233, -239};
Surface(289) = {288};
Line Loop(314) = {237, 53, -234};
Surface(315) = {314};
Line Loop(316) = {236, 54, 235};
Surface(317) = {316};

Surface Loop(290) = {62, 212, 273, 257, 251};
Volume(291) = {290};
Surface Loop(292) = {61, 275, 253, 257, 259};
Volume(293) = {292};
Surface Loop(294) = {60, 277, 255, 224, 259};
Volume(295) = {294};
Surface Loop(296) = {273, 279, 88, 214, 261};
Volume(297) = {296};
Surface Loop(298) = {275, 281, 87, 261, 263};
Volume(299) = {298};
Surface Loop(300) = {277, 283, 222, 263, 86};
Volume(301) = {300};
Surface Loop(302) = {279, 285, 216, 265, 111};
Volume(303) = {302};
Surface Loop(304) = {281, 287, 265, 267, 110};
Volume(305) = {304};
Surface Loop(306) = {283, 289, 226, 267, 109};
Volume(307) = {306};
Surface Loop(308) = {285, 245, 134, 218, 269};
Volume(309) = {308};
Surface Loop(310) = {287, 247, 133, 269, 271};
Volume(311) = {310};
Surface Loop(312) = {289, 249, 132, 228, 271};
Volume(313) = {312};
Surface Loop(318) = {220, 245, 251, 40, 315};
Volume(319) = {318};
Surface Loop(320) = {41, 253, 247, 315, 317};
Volume(321) = {320};
Surface Loop(322) = {317, 42, 230, 255, 249};
Volume(323) = {322};

	Physical Volume(1) = {291:323};

//////////////////////////////////////////////////////
//
//		GAS VOLUME
//
//////////////////////////////////////////////////////

	Surface Loop(16) = {24, 45, 20, 42, 50, 22};
	Volume(16) = {16};
	Surface Loop(17) = {49, 50, 19, 21, 44, 41};
	Volume(17) = {17};
	Surface Loop(18) = {23, 39, 18, 49, 43, 40};
	Volume(18) = {18};
	Surface Loop(19) = {134, 121, 131, 125, 138, 18};
	Volume(19) = {19};
	Surface Loop(20) = {119, 138, 137, 130, 19, 133};
	Volume(20) = {20};
	Surface Loop(21) = {117, 129, 123, 137, 20, 132};
	Volume(21) = {21};
	Surface Loop(22) = {117, 114, 100, 106, 109, 94};
	Volume(22) = {22};
	Surface Loop(23) = {107, 119, 96, 110, 115, 114};
	Volume(23) = {23};
	Surface Loop(24) = {121, 115, 102, 108, 98, 111};
	Volume(24) = {24};
	Surface Loop(25) = {98, 79, 92, 85, 75, 88};
	Volume(25) = {25};
	Surface Loop(26) = {96, 91, 92, 84, 73, 87};
	Volume(26) = {26};
	Surface Loop(27) = {94, 83, 71, 77, 91, 86};
	Volume(27) = {27};
	Surface Loop(28) = {71, 60, 57, 63, 66, 22};
	Volume(28) = {28};
	Surface Loop(29) = {73, 58, 21, 61, 67, 66};
	Volume(29) = {29};
	Surface Loop(30) = {75, 69, 67, 59, 39, 62};
	Volume(30) = {30};
	Surface Loop(31) = {38, 48, 45, 31, 52, 30};
	Volume(31) = {31};
	Surface Loop(32) = {47, 32, 29, 52, 51, 44};
	Volume(32) = {32};
	Surface Loop(33) = {33, 46, 34, 43, 28, 51};
	Volume(33) = {33};
	Surface Loop(34) = {58, 32, 54, 65, 64, 72};
	Volume(34) = {34};
	Surface Loop(35) = {72, 81, 84, 90, 89, 95};
	Volume(35) = {35};
	Surface Loop(36) = {95, 104, 107, 113, 112, 118};
	Volume(36) = {36};
	Surface Loop(37) = {118, 130, 127, 136, 135, 29};
	Volume(37) = {37};

	Physical Volume(2) = {16:37};
//////////////////////////////////////////////////////
//
//		KATOD #1 VOLUME
//
//////////////////////////////////////////////////////
	
	Surface Loop(38) = {33, 65, 68, 55, 59, 74};
	Volume(38) = {38};
	Surface Loop(39) = {74, 78, 82, 85, 90, 97};
	Volume(39) = {39};
	Surface Loop(40) = {97, 105, 101, 108, 113, 120};
	Volume(40) = {40};
	Surface Loop(41) = {120, 128, 124, 131, 136, 28};
	Volume(41) = {41};
	Physical Volume(3) = {38:41};
	
//////////////////////////////////////////////////////
//
//		KATOD #2 VOLUME
//
//////////////////////////////////////////////////////

	
	Surface Loop(42) = {30, 122, 126, 129, 135, 116};
	Volume(42) = {42};
	Surface Loop(43) = {116, 103, 99, 106, 112, 93};
	Volume(43) = {43};
	Surface Loop(44) = {93, 80, 76, 83, 89, 70};
	Volume(44) = {44};
	Surface Loop(45) = {70, 53, 56, 57, 64, 31};
	Volume(45) = {45};
	Physical Volume(4) = {42:45};



/*Delete {
  Line{188, 189, 195, 196, 182, 181, 174, 175, 176, 177, 157, 153, 149, 161, 198, 199, 200, 193, 192, 191, 184, 185, 146, 
  	186, 165, 170, 162, 166, 167, 163, 164, 171, 169, 168, 147, 156, 155, 154, 190, 151, 150, 152, 180, 187, 194, 197, 158, 160, 159, 148, 173, 172, 179, 178, 183};
}
Delete {
  Point{447:594};
}*/


////////////////////////////////////////////////////////////
//
// 		PHYSICAL SURFACES
//
////////////////////////////////////////////////////////////

	// Surfaces to which voltages will be applied
	
	Physical Surface(5) = {42, 41, 40, 220, 212, 218, 216, 214, 134, 133, 132, 62, 61, 60, 88, 87, 86, 230, 224, 228, 109, 222, 110, 111, 226};
	Physical Surface(6) = {33, 55, 59, 68, 65, 82, 85, 90, 78, 105, 101, 113, 108, 131, 124, 136, 128, 28};
	Physical Surface(7) = {30, 135, 129, 126, 122, 103, 99, 112, 106, 83, 76, 89, 80, 64, 56, 57, 53, 31};
	
	// Surfaces for periodic boundary conditions

	Physical Surface(8) = {69, 23, 125, 102, 79, 34};
	Physical Surface(9) = {38, 24, 123, 100, 77, 63};

	Transfinite Line {201:210,234:243} = 4 Using Progression 1;

//division lines
Transfinite Line {84, 85, 86, 83, 94, 93, 92, 91, 74, 82, 73, 72, 81, 80, 71, 79, 62,
 70, 60, 61, 59, 69, 68, 4, 3, 2, 1, 36, 35, 34, 33, 67} = dolgota Using Progression 1;

//kateti
Transfinite Line {139, 142, 145, 137, 140, 143, 126, 128, 123, 125, 120, 122, 103, 106, 109, 105, 108, 111,
5, 7, 6, 8, 13, 16, 40, 37, 38, 14, 15, 39,231,233} = kateti Using Progression 1;
//zazor mejdu katodami na poverhnosti
Transfinite Line {121, 124, 127, 138, 141, 144, 104, 107, 110, 32, 31, 42, 27, 28, 41,232} = delta Using Progression 1;
//zazor osnovnoi dolgota
Transfinite Line {44, 25, 26, 53, 54, 55, 56, 57, 58, 43, 30, 29} = zazor Using Progression 1;
//tolwina katoda
Transfinite Line {17, 18, 20, 19, 24, 23, 22, 21, 101, 100, 97, 96, 118, 115, 114, 113, 130, 131, 132, 135} = layers Using Progression 1;
//tolwina gaza
Transfinite Line {49, 50, 51, 48, 45, 46, 47, 52, 102, 99, 98, 95, 119, 117, 116, 112, 129, 133, 134, 136} = shirota Using Progression 1;


	
	//Recombine Surface {126:128,103:105,80:82,53:55,116:121,132:134,109:111,86:88,60:62,40:48,93:98,70:75,28:32,18:22};
	//Transfinite Surface{126:128,103:105,80:82,53:55,116:121,132:134,109:111,86:88,60:62,40:48,93:98,70:75,28:32,18:22};
	//Recombine Surface "*";
	//Transfinite Volume "*";
	//Recombine Volume "*";
	//Mesh.Prisms=1;

Transfinite Line {78, 77, 76, 75, 66, 65, 64, 63, 12, 10, 11, 9, 87, 90, 88, 89} = dolgota	 Using Progression 1;
Transfinite Surface "*";
Transfinite Volume "*";
