/*
Daniele Trimarchi
University of Southampton
4/4/2011
=========================================================================================
Input file for gmsh: connection of hybrid grids: structured hexa with un-structured tetra

The four blocks are generated: the first two are extruded, and they do not create any
particular problem. In some sense, they are always structured in one direction. 
The next two blocks are fully unstructured. No problem with the connection of the tetra
blocks, but troubles arise when trying to connect hexa and tetra. 
*/

dx=1;
dy=1;
dz=0.1;
dZ1=1;
N=9;

Point(1) = {0, 0, 0};
Point(2) = {dx, 0, 0};
Point(3) = {dx, dy, 0};
Point(4) = {0, dy, 0};

Point(5) = {2*dx, 0, 0};
Point(6) = {2*dx, dy, 0};

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

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

Line Loop(10) = {2, -9, -8, -7};
Plane Surface(11) = {10};

Transfinite Line {2, 7, 8, 9} = N Using Progression 1;
Transfinite Surface {11};
Recombine Surface {11};

Extrude {0, 0, dz} {
  Surface{6, 11};
  Layers{ {5,10,5},{0.3,0.7,1}};
  Recombine;
}

//Second phase: Creation of other volumes

Extrude {0, 0, 1} {
  Point{7, 8, 26, 22, 12, 16};
}
Line(62) = {27, 27};
Line(63) = {27, 28};
Line(64) = {28, 29};
Line(65) = {29, 30};
Line(66) = {30, 31};
Line(67) = {31, 32};
Line(68) = {32, 27};
Line(69) = {28, 31};
Line Loop(70) = {56, -68, -61, 16};
Plane Surface(71) = {70};
Line Loop(72) = {56, 63, -57, -13};
Plane Surface(73) = {72};
Line Loop(74) = {57, 69, -60, -14};
Plane Surface(75) = {74};
Line Loop(76) = {61, -67, -60, 15};
Plane Surface(77) = {76};
Line Loop(78) = {60, -66, -59, -36};
Plane Surface(79) = {78};
Line Loop(80) = {59, -65, -58, -37};
Plane Surface(81) = {80};
Line Loop(82) = {58, -64, -57, -38};
Plane Surface(83) = {82};
Line Loop(84) = {64, 65, 66, -69};
Plane Surface(85) = {84};
Line Loop(86) = {63, 69, 67, 68};
Plane Surface(87) = {86};


Surface Loop(88) = {73, 71, 87, 77, 33, 75};
Volume(89) = {88};

//Until here all is fine, if the Frontal mesh algorithm is chosen
//...but how to procede to the connection between a structured tetra and unstructured block..?
//Surface Loop(90) = {85, 83, 81, 79, 75, 55};
//Volume(91) = {90};

Transfinite Line {58, 59, 60, 57, 69, 65, 66, 64} = N Using Progression 1;
Transfinite Surface {75};
Transfinite Surface {81};
Transfinite Surface {81};
Transfinite Surface {83};
Transfinite Surface {79};

Surface Loop(90) = {85, 83, 81, 79, 55, 75};
Volume(91) = {90};

Mesh.Algorithm3D=4;