Include "ring2_ring.geo";

pt_rwrap = newp;
reg_rwrap = newreg;

Printf("pt %f reg %f",pt_rwrap,reg_rwrap);

Point(pt_rwrap) = {0, halfw+blthick+l_rwrap, blthick, lc};
Point(pt_rwrap+1) = {halfw+blthick+l_rwrap, halfw+blthick+l_rwrap, blthick, lc};
Point(pt_rwrap+2) = {halfw+blthick+l_rwrap, 0, blthick, lc};
Point(pt_rwrap+3) = {0, halfw+blthick+l_rwrap, blthick+h_rwrap, lc};
Point(pt_rwrap+4) = {halfw+blthick+l_rwrap, halfw+blthick+l_rwrap, blthick+h_rwrap, lc};
Point(pt_rwrap+5) = {halfw+blthick+l_rwrap, 0, blthick+h_rwrap, lc};
Point(pt_rwrap+6) = {0, 0, blthick+h_rwrap, lc};

Line(reg_rwrap) = {pt_rwrap,pt_rwrap+1};     //bottom
Line(reg_rwrap+1) = {pt_rwrap+1,pt_rwrap+2};
Line(reg_rwrap+2) = {pt_rwrap+3,pt_rwrap+4}; //top
Line(reg_rwrap+3) = {pt_rwrap+4,pt_rwrap+5};
Line(reg_rwrap+4) = {pt_rwrap,pt_rwrap+3};   //vertical
Line(reg_rwrap+5) = {pt_rwrap+1,pt_rwrap+4};
Line(reg_rwrap+6) = {pt_rwrap+2,pt_rwrap+5};

Line(reg_rwrap+7) = {10,pt_rwrap+2};
Line(reg_rwrap+8) = {9,pt_rwrap+1};
Line(reg_rwrap+9) = {8,pt_rwrap};
Line(reg_rwrap+10) = {13,pt_rwrap+5};
Line(reg_rwrap+11) = {12,19};
Line(reg_rwrap+12) = {11,18};
Line(reg_rwrap+13) = {pt_rwrap+6,pt_rwrap+5};
Line(reg_rwrap+14) = {pt_rwrap+6,pt_rwrap+3};
Line(reg_rwrap+15) = {pt_rwrap+6,14};

/*
GPNNR_length = nbnodes_ringh;
GPNNR_dx0 = dx0_rwrap;
GPNNR_dxN = lc;

Call GeomProgrNbNodesRatio;

Transfinite Line {66,67,68} = GPNNR_nbnodes Using Progression GPNNR_ratio;

*/
Line Loop(72) = {63,62,-66,29};
Plane Surface(73) = {72};
Line Loop(74) = {57,62,-59,-61};
Plane Surface(75) = {74};
Line Loop(76) = {56,61,-58,-60};
Plane Surface(77) = {76};
Line Loop(78) = {65,60,-68,-31};
Plane Surface(79) = {78};
Line Loop(80) = {68,-70,71,-26};
Plane Surface(81) = {80};
Line Loop(82) = {71,23,66,-69};
Plane Surface(83) = {82};
Line Loop(84) = {63,-57,-64,-27};
Plane Surface(85) = {84};
Line Loop(86) = {65,56,-64,30};
Plane Surface(87) = {86};
Line Loop(88) = {66,-59,-67,-24};
Plane Surface(89) = {88};
Line Loop(90) = {67,-58,-68,-25};
Plane Surface(91) = {90};
Line Loop(92) = {70,58,59,-69};
Plane Surface(93) = {92};

Transfinite Line {57,59,70,56,58,69} = nbnodes_ringh;
Transfinite Line {60,61,62} = nbnodes_ringv;
/*
GPNNR_length = l_rwrap;
GPNNR_dx0 = dx0_rwrap;
GPNNR_dxN = lc;

Call GeomProgrNbNodesRatio;

Transfinite Line {63,64,65,68,-71,66,67} = GPNNR_nbnodes Using Progression GPNNR_ratio;
*/
Transfinite Surface {75} = {17,16,19,20};
Transfinite Surface {77} = {16,15,18,19};
Transfinite Surface {79} = {15,8,11,18};
Transfinite Surface {81} = {14,21,18,11};
Transfinite Surface {83} = {20,21,14,13};
Transfinite Surface {73} = {17,20,13,10};
Transfinite Surface {85} = {17,16,9,10};
Transfinite Surface {87} = {16,15,8,9};
Transfinite Surface {91} = {11,12,19,18};
Transfinite Surface {89} = {12,13,20,19};
Transfinite Surface {93} = {21,20,19,18};

//Recombine Surface {93}; //top
Recombine Surface {85,87}; //bottom
Recombine Surface {75,77,79,81,83,89,91,73}; 

pt_rwrap = newp;
reg_rwrap = newreg;

Printf("pt %f reg %f",pt_rwrap,reg_rwrap);

Point(newp) = {halfw+blthick+l_rwrap,0,0,lc};
Point(newp+1) = {halfw+blthick+l_rwrap,halfw+blthick+l_rwrap,0,lc};
Point(newp+2) = {0,halfw+blthick+l_rwrap,0,lc};
Line(94) = {3,22};
Line(95) = {22,24};
Line(96) = {24,2};
Line Loop(97) = {94,95,96,2};
Plane Surface(98) = {97};
Line(99) = {22,17};
Line(100) = {24,16};
Line Loop(101) = {94,99,-63,-18};
Plane Surface(102) = {101};
Line Loop(103) = {95,100,57,-99};
Plane Surface(104) = {103};
Line Loop(105) = {96,19,64,-100};
Plane Surface(106) = {105};
Line(107) = {24,27};
Line(108) = {27,1};
Line(109) = {15,27};
Line Loop(110) = {107,108,1,-96};
Plane Surface(111) = {110};
Line Loop(112) = {107,-109,56,-100};
Plane Surface(113) = {112};
Line Loop(114) = {108,22,65,109};
Plane Surface(115) = {114};
Transfinite Surface {98} = {22,24,2,3};
Transfinite Surface {102} = {22,17,10,3};
Transfinite Surface {104} = {22,24,16,17};
Transfinite Surface {111} = {2,24,27,1};
Transfinite Surface {113} = {24,27,15,16};
Transfinite Surface {115} = {1,8,15,27};

//horizontal
GPNNR_length = l_rwrap;
GPNNR_dx0 = dx0_rwrap;
GPNNR_dxN = lc;

Call GeomProgrNbNodesRatio;

Transfinite Line {63,64,65,68,-71,66,67,94,-96,-108} = GPNNR_nbnodes Using Progression GPNNR_ratio;

//bl
GPNND_length = blthick;
GPNND_dx0 = wallcellthick;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;

Transfinite Line {99,100,109} = GPNND_nbnodes Using Progression GPNND_ratio;
Transfinite Line {95,107} = nbnodes_ringh;


//Recombine Surface {98,11} //top bottom
Recombine Surface {102,104,106,113,115};

//FIELD extension
pt_rwrap = newp;
reg_rwrap = newreg;

halfw_core = 16.22 * m;
halfl_core = 8.15 * 3;
l_seat = 20.53 *m;

Point(pt_rwrap) = {halfw_core, 0, 0, lc};
Point(pt_rwrap+1) = {halfw_core, halfw+blthick+l_rwrap, 0, lc};
Point(pt_rwrap+2) = {halfw_core, 0, blthick, lc};
Point(pt_rwrap+3) = {halfw_core, halfw+blthick+l_rwrap, blthick, lc};
Point(pt_rwrap+4) = {halfw_core, 0, blthick+h_rwrap, lc};
Point(pt_rwrap+5) = {halfw_core, halfw+blthick+l_rwrap, blthick+h_rwrap, lc};

Point(pt_rwrap+6) = {halfw_core+l_seat, 0, 7, lc};
Point(pt_rwrap+7) = {halfw_core+l_seat, halfw+blthick+l_rwrap, 7, lc};
Point(pt_rwrap+8) = {halfw_core+l_seat, 0, blthick+7, lc};
Point(pt_rwrap+9) = {halfw_core+l_seat, halfw+blthick+l_rwrap, blthick+7, lc};
Point(pt_rwrap+10) = {halfw_core+l_seat, 0, blthick+h_rwrap+7, lc};
Point(pt_rwrap+11) = {halfw_core+l_seat, halfw+blthick+l_rwrap, blthick+h_rwrap+7, lc};

Point(pt_rwrap+12) = {0, halfl_core, 0, lc};
Point(pt_rwrap+13) = {halfw+blthick+l_rwrap, halfl_core, 0, lc};
Point(pt_rwrap+14) = {0, halfl_core, blthick, lc};
Point(pt_rwrap+15) = {halfw+blthick+l_rwrap, halfl_core, blthick, lc};
Point(pt_rwrap+16) = {0, halfl_core, blthick+h_rwrap, lc};
Point(pt_rwrap+17) = {halfw+blthick+l_rwrap, halfl_core, blthick+h_rwrap, lc};

Point(pt_rwrap+18) = {halfw_core, halfl_core, 0, lc};
Point(pt_rwrap+19) = {halfw_core, halfl_core, blthick, lc};
Point(pt_rwrap+20) = {halfw_core, halfl_core, blthick+h_rwrap, lc};

Point(pt_rwrap+21) = {halfw_core+l_seat, halfl_core, 7, lc};
Point(pt_rwrap+22) = {halfw_core+l_seat, halfl_core, blthick+7, lc};
Point(pt_rwrap+23) = {halfw_core+l_seat, halfl_core, blthick+h_rwrap+7, lc};


Line(116) = {22,28};
Line(117) = {28,29};
Line(118) = {29,24};
Line(119) = {17,30};
Line(120) = {30,31};
Line(121) = {31,16};
Line(122) = {28,30};
Line(123) = {29,31};
Line Loop(124) = {116,117,118,-95};
Plane Surface(125) = {124};
Line Loop(126) = {119,120,121,57};
Plane Surface(127) = {126};
Line Loop(128) = {116,122,-119,-99};
Plane Surface(129) = {128};
Line Loop(130) = {117,123,-120,-122};
Plane Surface(131) = {130};
Line Loop(132) = {123,121,-100,-118};
Plane Surface(133) = {132};
Transfinite Surface {125} = {28,29,24,22};
Transfinite Surface {127} = {30,31,16,17};
Transfinite Surface {129} = {28,30,17,22};
Transfinite Surface {131} = {28,29,31,30};
Transfinite Surface {133} = {29,24,16,31};
Line(134) = {20,32};
Line(135) = {32,33};
Line(136) = {33,19};
Line(137) = {30,32};
Line(138) = {31,33};
Line Loop(139) = {134,135,136,59};
Plane Surface(140) = {139};
Line Loop(141) = {119,137,-134,-62};
Plane Surface(142) = {141};
Line Loop(143) = {120,138,-135,-137};
Plane Surface(144) = {143};
Line Loop(145) = {121,61,-136,-138};
Plane Surface(146) = {145};
Transfinite Surface {140} = {32,33,19,20};
Transfinite Surface {142} = {30,32,20,17};
Transfinite Surface {144} = {31,33,32,30};
Transfinite Surface {146} = {31,16,19,33};
Line(147) = {28,34};
Line(148) = {34,35};
Line(149) = {35,29};
Line(150) = {30,36};
Line(151) = {36,37};
Line(152) = {37,31};
Line(153) = {34,36};
Line(154) = {35,37};
Line Loop(155) = {147,148,149,-117};
Plane Surface(156) = {155};
Transfinite Surface {156} = {28,34,35,29};
Line Loop(157) = {150,151,152,-120};
Plane Surface(158) = {157};
Transfinite Surface {158} = {30,36,37,31};
Line Loop(159) = {147,153,-150,-122};
Plane Surface(160) = {159};
Line Loop(161) = {148,154,-151,-153};
Plane Surface(162) = {161};
Line Loop(163) = {149,123,-152,-154};
Plane Surface(164) = {163};
Line(165) = {32,38};
Line(166) = {38,39};
Line(167) = {39,33};
Line(168) = {36,38};
Line(169) = {37,39};
Line Loop(170) = {165,166,167,-135};
Plane Surface(171) = {170};
Line Loop(172) = {150,168,-165,-137};
Plane Surface(173) = {172};
Line Loop(174) = {151,169,-166,-168};
Plane Surface(175) = {174};
Line Loop(176) = {152,138,-167,-169};
Plane Surface(177) = {176};
Transfinite Surface {171} = {38,39,33,32};
Transfinite Surface {173} = {36,38,32,30};
Transfinite Surface {175} = {37,39,38,36};
Transfinite Surface {177} = {39,37,31,33};

//Recombine Surface {125,127,140,156,158,171};
Recombine Surface {129,131,133,142,144,146,147,160,162,164,173,175,177};

Line(178) = {27,40};
Line(179) = {40,41};
Line(180) = {41,24};
Line(181) = {15,42};
Line(182) = {42,43};
Line(183) = {43,16};
Line(184) = {40,42};
Line(185) = {41,43};
Line(186) = {18,44};
Line(187) = {44,45};
Line(188) = {45,19};
Line(189) = {42,44};
Line(190) = {43,45};
Line Loop(191) = {107,178,179,180};
Plane Surface(192) = {191};
Line Loop(193) = {181,182,183,-56};
Plane Surface(194) = {193};
Line Loop(195) = {109,178,184,-181};
Plane Surface(196) = {195};
Line Loop(197) = {184,182,-185,-179};
Plane Surface(198) = {197};
Line Loop(199) = {185,183,-100,-180};
Plane Surface(200) = {199};
Line Loop(201) = {187,188,-58,186};
Plane Surface(202) = {201};
Line Loop(203) = {60,186,-189,-181};
Plane Surface(204) = {203};
Line Loop(205) = {189,187,-190,-182};
Plane Surface(206) = {205};
Line Loop(207) = {190,188,-61,-183};
Plane Surface(208) = {207};
Line(209) = {41,46};
Line(210) = {46,29};
Line(211) = {43,47};
Line(212) = {47,31};
Line(213) = {45,48};
Line(214) = {48,33};
Line(215) = {46,47};
Line(216) = {47,48};
Line Loop(217) = {180,-118,-210,-209};
Plane Surface(218) = {217};
Line Loop(219) = {211,212,121,-183};
Plane Surface(220) = {219};
Line Loop(221) = {213,214,136,-188};
Plane Surface(222) = {221};
Line Loop(223) = {209,215,-211,-185};
Plane Surface(224) = {223};
Line Loop(225) = {211,216,-213,-190};
Plane Surface(226) = {225};
Line Loop(227) = {210,123,-212,-215};
Plane Surface(228) = {227};
Line Loop(229) = {212,138,-214,-216};
Plane Surface(230) = {229};
Line(231) = {46,49};
Line(232) = {49,35};
Line(233) = {47,50};
Line(234) = {50,37};
Line(235) = {48,51};
Line(236) = {51,39};
Line(237) = {49,50};
Line(238) = {50,51};
Line Loop(239) = {231,232,149,-210};
Plane Surface(240) = {239};
Line Loop(241) = {233,234,152,-212};
Plane Surface(242) = {241};
Line Loop(243) = {235,236,167,-214};
Plane Surface(244) = {243};
Line Loop(245) = {231,237,-233,-215};
Plane Surface(246) = {245};
Line Loop(247) = {232,154,-234,-237};
Plane Surface(248) = {247};
Line Loop(249) = {234,169,-236,-238};
Plane Surface(250) = {249};
Transfinite Surface {192} = {27,40,41,24};
Transfinite Surface {194} = {15,42,43,16};
Transfinite Surface {202} = {18,44,45,19};
Transfinite Surface {196} = {27,40,42,15};
Transfinite Surface {204} = {15,42,44,18};
Transfinite Surface {198} = {40,41,43,42};
Transfinite Surface {206} = {42,43,45,44};
Transfinite Surface {200} = {41,24,16,43};
Transfinite Surface {208} = {43,16,19,45};
Transfinite Surface {218} = {41,46,29,24};
Transfinite Surface {220} = {43,47,31,16};
Transfinite Surface {222} = {45,48,33,19};
Transfinite Surface {224} = {41,46,47,43};
Transfinite Surface {226} = {43,47,48,45};
Transfinite Surface {228} = {46,29,31,47};
Transfinite Surface {230} = {47,31,33,48};
Transfinite Surface {240} = {46,49,35,29};
Transfinite Surface {242} = {47,50,37,31};
Transfinite Surface {244} = {48,51,39,33};
Transfinite Surface {248} = {49,35,37,50};
Transfinite Surface {250} = {50,37,39,51};
Line Loop(251) = {233,238,-235,-216};
Plane Surface(252) = {251};
Transfinite Surface {252} = {47,50,51,48};
Transfinite Surface {246} = {46,49,50,47};

//Recombine Surface {192,194,202,218,220,222,240,242,244};
Recombine Surface {196,198,200,204,206,208,224,226,228,230,246,248,250,252};


//horizontal
Transfinite Line {117,148,120,151,135,166,179,182,187} = nbnodes_ringh;

Transfinite Line {116,119,134,118,121,136,209,211,213} = Floor(4.92/lc);

Transfinite Line {147,150,165,149,152,167,231,233,235} = Floor(21.7/lc);

Transfinite Line {178,181,186,180,183,188,210,212,214,232,234,236} = Floor(13.15/lc);


//bl
GPNND_length = blthick;
GPNND_dx0 = wallcellthick;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;

Transfinite Line {122,123,153,154,184,185,215,237} = GPNND_nbnodes Using Progression GPNND_ratio;
Transfinite Line {137,168,169,138,189,190,216,238} = nbnodes_ringv;

Line Loop(261) = {67,-61,-64,28};
Plane Surface(262) = {261};
Transfinite Surface {262} = {12,19,16,9};
Recombine Surface {262};

Transfinite Surface {162} = {35,34,36,37};
Transfinite Surface {164} = {29,35,37,31};
Transfinite Surface {160} = {34,28,30,36};
