/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// 3D Mesh for Wall-mounted Cube
//
// by Daniel
//
// First written: 
//  2008-11-15 (My Birthday)
// Last modified:
//  2008-11-15
//
// Description:
//    Near the cube, I am trying to use structured mesh,
//    But, away from the cube, I want to use unstructured mesh.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

lc1 = 0.1;
lc2 = 0.2;
lc3 = 0.2;
c = 1;
t = 1.5*c;
s = c+(t-c)/2;
x1 = c;
x2 = 10*c;
b = 5*c;
h = 2*c;


Point(1) = {-(t-c)/2, c,         -c/2, lc2};
Point(2) = {       0, c,         -c/2, lc1};
Point(3) = {       0, c,          c/2, lc1};
Point(4) = {-(t-c)/2, c,          c/2, lc2};
Point(5) = {-(t-c)/2, c+(t-c)/2, -c/2, lc2};
Point(6) = {       0, c+(t-c)/2, -c/2, lc2};
Point(7) = {       0, c+(t-c)/2,  c/2, lc2};
Point(8) = {-(t-c)/2, c+(t-c)/2,  c/2, lc2};

Line(1)  = {1,2};
Line(2)  = {2,3};
Line(3)  = {3,4};
Line(4)  = {4,1};
Line(5)  = {5,6};
Line(6)  = {6,7};
Line(7)  = {7,8};
Line(8)  = {8,5};
Line(9)  = {1,1+4};
Line(10) = {2,2+4};
Line(11) = {3,3+4};
Line(12) = {4,4+4};

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

Surface Loop(1) = {1,2,3,4,5,6};
Volume(1) = {1};

Extrude {0,-c,0} {Surface{1};}
Extrude {0,0,(t-c)/2} {Surface{5,25};}
Extrude {0,0,-(t-c)/2} {Surface{6,33};}
Extrude {c,0,0} {Surface{4,55,69,91,121};}
Extrude {(t-c)/2,0,0} {Surface{144,166,188,232,210};}
Extrude {0,0,c} {Surface{307};}



// Transfinite Line{14,16,349,358,226,217,174,178,4,2,124,234,204,129,130,156,
// 8,6,126,236,200,138,134,160,20,24,59,61,168,278,280,170,214,302,300,212,103,105,28,19} = 20 Using Progression 1;

// Transfinite Line{104,116,17,112,314,303,305,215,15,68,60,72,284,279,288,169,
// 80,86,1,85,310,301,239,193,240,257,266,147,3,41,36,42,
// 82,90,5,94,332,323,248,191,244,259,270,149,7,50,38,46,
// 81,83,9,10,192,324,237,127,11,12,37,39,125,235,258,148} = 10 Using Progression 1;
// -----> re-number it as following!

Transfinite Line{2,4,6,8,14,16,19,20,24,28,59,61,103,105,124,126,129,130,
134,138,156,160,168,170,174,178,200,204,212,214,217,226,234,236,278,280,
300,302,349,358} = 20 Using Progression 1;

Transfinite Line{-1,3,-5,7,9,10,11,12,-15,17,36,37,-38,-39,41,42,46,50,60,68,72,-80,
81,82,-83,85,86,90,94,-104,112,116,125,-127,147,148,-149,169,191,-192,-193,-215,235,
-237,239,240,244,248,257,258,-259,266,270,279,284,288,301,-303,305,310,314,323,
-324,332} = 20 Using Progression 1.01;


Transfinite Surface{117} = {54,58,18,9};
Transfinite Surface{231} = {58,104,95,18};
Transfinite Surface{319} = {104,140,131,95};
Transfinite Surface{34} = {9,18,14,10};
Transfinite Surface{363} = {95,131,80,126};
Transfinite Surface{73} = {10,14,34,38};
Transfinite Surface{179} = {14,80,84,34};
Transfinite Surface{289} = {80,126,130,84};
Transfinite Surface{87} = {39,40,2,1};
Transfinite Surface{209} = {40,94,59,2};
Transfinite Surface{311} = {94,136,105,59};
Transfinite Surface{1} = {1,2,3,4};
Transfinite Surface{131} = {2,59,60,3};
Transfinite Surface{241} = {59,105,106,60};
Transfinite Surface{43} = {4,3,19,20};
Transfinite Surface{157} = {3,60,74,19};
Transfinite Surface{267} = {60,106,120,74};
Transfinite Surface{95} = {48,44,6,5};
Transfinite Surface{201} = {44,90,68,6};
Transfinite Surface{333} = {90,146,114,68};
Transfinite Surface{2} = {5,6,7,8};
Transfinite Surface{139} = {6,68,64,7};
Transfinite Surface{249} = {68,114,110,64};
Transfinite Surface{51} = {8,7,28,24};
Transfinite Surface{165} = {7,64,78,28};
Transfinite Surface{275} = {64,110,124,78};
Transfinite Surface{47} = {24,8,4,20};
Transfinite Surface{3} = {8,5,1,4};
Transfinite Surface{99} = {5,48,39,1};
Transfinite Surface{77} = {20,4,10,38};
Transfinite Surface{21} = {4,1,9,10};
Transfinite Surface{113} = {1,39,54,9};
Transfinite Surface{55} = {28,7,3,19};
Transfinite Surface{4} = {7,6,2,3};
Transfinite Surface{91} = {6,44,40,2};
Transfinite Surface{69} = {19,3,14,34};
Transfinite Surface{29} = {3,2,18,14};
Transfinite Surface{121} = {2,40,58,18};
Transfinite Surface{166} = {78,64,60,74};
Transfinite Surface{144} = {64,68,59,60};
Transfinite Surface{210} = {68,90,94,59};
Transfinite Surface{188} = {74,60,80,84};
Transfinite Surface{351} = {60,59,95,80};
Transfinite Surface{232} = {59,94,104,95};
Transfinite Surface{276} = {124,110,106,120};
Transfinite Surface{254} = {110,114,105,106};
Transfinite Surface{342} = {114,146,136,105};
Transfinite Surface{298} = {120,106,126,130};
Transfinite Surface{359} = {106,105,131,126};
Transfinite Surface{320} = {105,136,140,131};
Transfinite Surface{100} = {48,44,40,39};
Transfinite Surface{205} = {44,90,94,40};
Transfinite Surface{337} = {90,146,136,94};
Transfinite Surface{122} = {39,40,58,54};
Transfinite Surface{227} = {40,94,104,58};
Transfinite Surface{315} = {94,136,140,104};
Transfinite Surface{6} = {5,6,2,1};
Transfinite Surface{143} = {6,68,59,2};
Transfinite Surface{253} = {68,114,105,59};
Transfinite Surface{33} = {1,2,18,9};
Transfinite Surface{219} = {2,59,95,18};
Transfinite Surface{307} = {59,105,131,95};
Transfinite Surface{5} = {8,7,3,4};
Transfinite Surface{135} = {7,64,60,3};
Transfinite Surface{245} = {64,110,106,60};
Transfinite Surface{25} = {4,3,14,10};
Transfinite Surface{175} = {3,60,80,14};
Transfinite Surface{285} = {60,106,126,80};
Transfinite Surface{56} = {24,28,19,20};
Transfinite Surface{161} = {28,78,74,19};
Transfinite Surface{271} = {78,124,120,74};
Transfinite Surface{78} = {20,19,34,38};
Transfinite Surface{183} = {19,74,84,34};
Transfinite Surface{293} = {74,120,130,84};

Transfinite Volume{1} = {1,2,3,4,5,6,7,8};
Transfinite Volume{2} = {1,2,3,4,9,18,14,10};
Transfinite Volume{3} = {3,4,20,19,7,8,24,28};
Transfinite Volume{4} = {3,4,20,19,14,10,38,34};
Transfinite Volume{5} = {40,39,1,2,44,48,5,6};
Transfinite Volume{6} = {58,54,9,18,40,39,1,2};
Transfinite Volume{7} = {59,2,3,60,68,6,7,64};
Transfinite Volume{8} = {60,3,19,74,64,7,28,78};
Transfinite Volume{9} = {80,14,34,84,60,3,19,74};
Transfinite Volume{10} = {94,40,2,59,90,44,6,68};
Transfinite Volume{11} = {104,58,18,95,94,40,2,59};
Transfinite Volume{12} = {105,59,60,106,114,68,64,110};
Transfinite Volume{13} = {106,60,74,120,110,64,78,124};
Transfinite Volume{14} = {126,80,84,130,106,60,74,120};
Transfinite Volume{15} = {140,104,95,131,136,94,59,105};
Transfinite Volume{16} = {136,94,59,105,146,90,68,114};
Transfinite Volume{17} = {131,95,80,126,105,59,60,106};

Recombine Surface {1:363};

Extrude {x2,0,0} {Surface{276,254,342,298,359,320};Recombine;}
Extrude {0,0,(b-t)/2} {Surface{56,78,161,183,271,293,380,446};Recombine;}
Extrude {0,0,-(b-t)/2} {Surface{100,122,205,227,337,315,424,490};Recombine;}
Extrude {0,h-t,0} {Surface{688,736,780,824,95,201,333,420,2,139,249,402,51,165,275,384,512,552,596,640};Recombine;}
Extrude {-x1,0,0} {Surface{860,692,706,948,99,113,1044,3,21,1132,47,77,1220,508,538};Recombine;}

