Include "units.geo";
Include "functions.geo";

scale = 4;
lc = 0.5 * m;

blthick = 0.3 * m;
wallcellthick = scale * 2 * mm;

// boxing ring

h = 1.2;
halfw = 3;
Point(1) = {0, halfw, 0, lc};
Point(2) = {halfw, halfw, 0, lc};
Point(3) = {halfw, 0, 0, lc};
Point(4) = {0, halfw, h, lc};
Point(5) = {halfw, halfw, h, lc};
Point(6) = {halfw, 0, h, lc};
Point(7) = {0, 0, h, lc};
Point(8) = {0, halfw+blthick, blthick, lc};
Point(9) = {halfw+blthick, halfw+blthick, blthick, lc};
Point(10) = {halfw+blthick, 0, blthick, lc};
Point(11) = {0, halfw+blthick, h+blthick, lc};
Point(12) = {halfw+blthick, halfw+blthick, h+blthick, lc};
Point(13) = {halfw+blthick, 0, h+blthick, lc};
Point(14) = {0, 0, h+blthick, lc};


Line(1) = {1,2};
Line(2) = {2,3};
Line(3) = {4,5};
Line(4) = {5,6};
Line(5) = {1,4};
Line(6) = {2,5};
Line(7) = {3,6};

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

Line(12) = {7,6};
Line(13) = {7,4};
Line Loop(14) = {12,-4,-3,-13};
Plane Surface(15) = {14};

Line(16) = {7,14};
Line(17) = {6,13};
Line(18) = {3,10};
Line(19) = {2,9};
Line(20) = {5,12};
Line(21) = {4,11};
Line(22) = {1,8};
Line(23) = {14,13};
Line(24) = {13,12};
Line(25) = {12,11};
Line(26) = {11,14};
Line(27) = {10,9};
Line(28) = {9,12};
Line(29) = {13,10};
Line(30) = {9,8};
Line(31) = {8,11};
Line Loop(32) = {24,25,26,23};
Plane Surface(33) = {32};
Line Loop(34) = {13,21,26,-16};
Plane Surface(35) = {34};
Line Loop(36) = {23,-17,-12,16};
Plane Surface(37) = {36};
Line Loop(38) = {4,17,24,-20};
Plane Surface(39) = {38};
Line Loop(40) = {3,20,25,-21};
Plane Surface(41) = {40};
Line Loop(42) = {22,31,-21,-5};
Plane Surface(43) = {42};
Line Loop(44) = {6,20,-28,-19};
Plane Surface(45) = {44};
Line Loop(46) = {30,-22,1,19};
Plane Surface(47) = {46};
Line Loop(48) = {30,31,-25,-28};
Plane Surface(49) = {48};
Line Loop(50) = {27,-19,2,18};
Plane Surface(51) = {50};
Line Loop(52) = {7,17,29,-18};
Plane Surface(53) = {52};
Line Loop(54) = {29,27,28,-24};
Plane Surface(55) = {54};
Transfinite Surface {37} = {13,14,7,6};
Transfinite Surface {53} = {10,13,6,3};
Transfinite Surface {45} = {2,9,12,5};
Transfinite Surface {51} = {9,2,3,10};
Transfinite Surface {55} = {9,12,13,10};
Transfinite Surface {47} = {9,8,1,2};
Transfinite Surface {43} = {8,11,4,1};
Transfinite Surface {41} = {4,11,12,5};
Transfinite Surface {35} = {4,7,14,11};
Transfinite Surface {33} = {14,13,12,11};

Transfinite Surface{15} = {4,5,6,7};
Transfinite Surface{9} = {2,3,6,5};
Transfinite Surface{11} = {1,2,5,4};
Transfinite Surface {49} = {12,9,8,11};
Transfinite Surface {39} = {6,13,12,5};

Printf("ring,");

// ring horizontal edges
GPNND_length = halfw;
GPNND_dx0 = 4 * wallcellthick;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;

  //wall
Transfinite Line {-1,2,4,-3,-13} = GPNND_nbnodes Using Progression GPNND_ratio;
  //other
Transfinite Line {-12,-24,-27,25,30,-23,26} = GPNND_nbnodes Using Progression GPNND_ratio;

nbnodes_ringh = GPNND_nbnodes;
l_rwrap = lc * (GPNND_nbnodes-1);
l_rwrap = 8;


// ring vertical edges
GBPNND_length = h;
GBPNND_dx0 = 4 * wallcellthick;
GBPNND_ratio = 1.3;

Call BumpProgrNbNodesBRatio;

  //wall
Transfinite Line {5,6,7} = GBPNND_nbnodes Using Bump GBPNND_bumpratio;
  //other
Transfinite Line {28,-29,31} = GBPNND_nbnodes Using Bump GBPNND_bumpratio;

nbnodes_ringv = GBPNND_nbnodes;
h_rwrap = lc * (GBPNND_nbnodes-1);
h_rwrap = 7;

// boundary layer
GPNND_length = blthick;
GPNND_dx0 = wallcellthick;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;
dx0_rwrap= GPNND_dxN;

Transfinite Line {16,17,18,19,20,21,22} = GPNND_nbnodes Using Progression GPNND_ratio;


//Recombine Surface {9,11,15,37,53,45,51,55,47,43,41,11,35,33,39,49};
Recombine Surface {9,11,37,53,45,51,55,47,43,41,11,35,39,49};


/*
//-------------------------------

//field width
GPNND_length = halfl_core;
GPNND_dx0 = wallcellthick;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;

Transfinite Line {-96,-97,-98,-99} = GPNND_nbnodes Using Progression GPNND_ratio;
  //propagation along x
Transfinite Line {112,113,125,124} = GPNND_nbnodes;

//field length
GPNND_length = halfw_core;
GPNND_dx0 = wallcellthick;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;

Transfinite Line {60,62,-61,-63} = GPNND_nbnodes Using Progression GPNND_ratio;
  //propagation along y
Transfinite Line {116,119} = GPNND_nbnodes;

Transfinite Line {66,67,68,69,128,129} = Floor(l_seat/GPNND_dxN);
*/
