/*

 file  : archivo con la geometria del bloque Y 
 author: Fernando Diego Carazo Rodriguez (buenaluna)
 date  : lun jul 26 23:34:11 ART 2010

*/

// Mesh.Smoothing= 0.05;

// longitud caracteristica
lc1= 0.025;
lc2= 0.025;

// puntos
// puntos sobre el molde   
Point(1) = {0.0      , 0.0 , 0.0 , lc1};
Point(2) = {0.024999 , 0.0 , 0.0 , lc1};
Point(3) = {0.025    , 0.0 , 0.0 , lc1};
Point(4) = {0.05     , 0.0 , 0.0 , lc1};
Point(5) = {0.050001 , 0.0 , 0.0 , lc1};
Point(6) = {0.115    , 0.0 , 0.0 , lc1};

//
Point( 7)= {0.0      , 0.02 , 0.0 , lc1};
Point( 8)= {0.024999 , 0.02 , 0.0 , lc2};
Point( 9)= {0.050001 , 0.02 , 0.0 , lc1};
Point(10)= {0.115    , 0.02 , 0.0 , lc1};

//
Point(11)= {0.0      , 0.065 , 0.0 , lc2};
Point(12)= {0.024999 , 0.065 , 0.0 , lc2};
Point(13)= {0.050001 , 0.065 , 0.0 , lc2};
Point(14)= {0.115    , 0.065 , 0.0 , lc2};

//
Point(15)= {0.0      , 0.16 , 0.0 , lc2};
Point(16)= {0.019999 , 0.16 , 0.0 , lc2};
Point(17)= {0.075001 , 0.16 , 0.0 , lc2};
Point(18)= {0.115    , 0.16 , 0.0 , lc2};

// agregados al final -- plano inferior molde
Point(25)= {0.024999 , 0.020001 , 0.0 , lc2};
Point(26)= {0.050001 , 0.020001 , 0.0 , lc2};
Point(27)= {0.025    , 0.02     , 0.0 , lc2};
Point(28)= {0.05     , 0.02     , 0.0 , lc2};

// puntos sobre la pieza -- contorno pieza
Point(19)= {0.025 , 0.020001 , 0.0 , lc2};
Point(20)= {0.05  , 0.020001 , 0.0 , lc1};
Point(21)= {0.05  , 0.065    , 0.0 , lc1};
Point(22)= {0.075 , 0.16     , 0.0 , lc1};
Point(23)= {0.02  , 0.16     , 0.0 , lc1};
Point(24)= {0.025 , 0.065    , 0.0 , lc2};

// agregados al final
Point(29)= {0.0   , 0.020001 , 0.0 , lc1};
Point(30)= {0.115 , 0.020001 , 0.0 , lc2};

// lineas
// plano inferior (suelo)
Line(1)= {1,2};
Line(2)= {2,3};
Line(3)= {3,4};
Line(4)= {4,5};
Line(5)= {5,6};

// plano lateral izquierdo (molde-ambiente)
Line(6)= {6 ,10};
Line(7)= {30,14};
Line(8)= {14,18};

// plano superior (molde-ambiente)
Line( 9)= {18,17};
Line(13)= {16,15};

// plano superior (pieza-ambiente)
Line(11)= {22,23};

// plano superior (gap-ambiente)
Line(10)= {17,22};
Line(12)= {23,16};

// plano lateral izquierdo (simetria - adiabatico)
Line(14)= {15,11};
Line(15)= {11,29};
Line(16)= { 7, 1};

// primer plano inferior molde (horizontal)
Line(17)= { 7, 8};
Line(18)= { 8,27};
Line(19)= {27,28};
Line(20)= {28, 9};
Line(21)= { 9,10};

// primer plano inferior pieza (horizontal)
Line(22)= {25,19};
Line(23)= {19,20};
Line(24)= {20,26};

// segundo plano inferior molde (horizontal)
Line(25)= {11,12};
Line(26)= {12,24};
Line(27)= {24,21};
Line(28)= {21,13};
Line(29)= {13,14};

// 1 - contacto (pieza-molde) (exterior - verticales - derechos)
Line(30)= { 9,26};
Line(31)= {26,13};
Line(32)= {13,17};

// 2 - contacto (pieza-molde) (exterior - verticales - izquierdos)
Line(33)= {16,12}; // antihorarios
Line(34)= {12,25};
Line(35)= {25, 8};

// 3 - contacto (pieza-molde) (interiores - verticales - derechos)
Line(36)= {20,21};
Line(37)= {21,22};
	 
// 4 - contacto (pieza-molde) (interiores - verticales - izquierdos)
Line(38)= {23,24}; // antihorarios
Line(39)= {24,19};

// agregado al final
Line(40)= {29,25}; // antihorarios
Line(41)= {26,30};
Line(42)= { 2, 8};
Line(43)= {27, 3};
Line(44)= { 4,28};
Line(45)= { 5,9};
Line(46)= {29, 7};
Line(47)= {10,30};
Line(48)= {19,27};
Line(49)= {28,20};

// ciclos de linas para defincion de superficies
// @ pieza, contacto pieza-molde y molde

// loops para el molde
/* 1 - @ molde */
Line Loop(1)= {1,42,-17,16}; 
/* 2 - @ molde */
Line Loop(2)= {2,-43,-18,-42}; 
/* 3 - @ molde */
Line Loop(3)= {3,44,-19,43}; 
/* 4 - @ molde */
Line Loop(4)= {4,45,-20,-44}; 
/* 5 - @ molde */
Line Loop(5)= {5,6,-21,-45}; 
/* 6 - @ molde */
Line Loop(6)= {17,-35,-40,46}; 
/* 7 - @ molde */
Line Loop(10)= {21,47,-41,-30}; 
/* 8 - @ molde */
Line Loop(11)= {40,-34,-25,15}; 
/* 9 - @ molde */
Line Loop(15)= {41,7,-29,-31}; 
/* 10 - @ molde */
Line Loop(16)= {25,-33,13,14}; 
/* 11 - @ molde */
Line Loop(20)= {29,8,9,-32}; 

// loops para los GAPS
/* 1 - @ gaps */
Line Loop(7)= {18,-48,-22,35}; 
/* 2 - @ gaps */
Line Loop(8)= {19,49,-23,48}; 
/* 3 - @ gaps */
Line Loop(9)= {20,30,-24,-49}; 
/* 4 - @ gaps */
Line Loop(12)= {22,-39,-26,34}; 
/* 5 - @ gaps */
Line Loop(14)= {24,31,-28,-36}; 
/* 6 - @ gaps */
Line Loop(17)= {26,-38,12,33}; 
/* 7 - @ gaps */
Line Loop(19)= {28,32,10,-37}; 

// loops para la PIEZA
/* 1 - @ pieza */
Line Loop(13)= {23,36,-27,39}; 
/* 2 - @ pieza */
Line Loop(18)= {27,37,11,38}; 

// definimos las superficies
// @ molde
Plane Surface(1) = { 1}; 
Plane Surface(2) = { 2}; 
Plane Surface(3) = { 3}; 
Plane Surface(4) = { 4}; 
Plane Surface(5) = { 5}; 
Plane Surface(6) = { 6}; 
Plane Surface(7) = {10}; 
Plane Surface(8) = {11}; 
Plane Surface(9) = {15}; 
Plane Surface(10)= {16}; 
Plane Surface(11)= {20}; 

// @ gaps
Plane Surface(12)= { 7}; 
Plane Surface(13)= { 8}; 
Plane Surface(14)= { 9}; 
Plane Surface(15)= {12}; 
Plane Surface(16)= {14}; 
Plane Surface(17)= {17}; 
Plane Surface(18)= {19}; 

// @ pieza
Plane Surface(19)= {13}; 
Plane Surface(20)= {18}; 

// definimos las lineas y superficies transfinitas 
// para llevar la malla de triangulos a cuadrilateros

// lineas paralelas con la misma progresion
// @ molde 
Transfinite Line{ 1,17}= 10 Using Progression 1;
Transfinite Line{ 2,18}=  1 Using Progression 1;
Transfinite Line{ 3,19}= 10 Using Progression 1;
Transfinite Line{ 4,20}=  1 Using Progression 1;
Transfinite Line{ 5,21}= 20 Using Progression 1;
Transfinite Line{17,40}= 10 Using Progression 1;
Transfinite Line{21,41}= 20 Using Progression 1;
Transfinite Line{40,25}= 10 Using Progression 1;
Transfinite Line{41,29}= 20 Using Progression 1;
Transfinite Line{25,13}= 10 Using Progression 1;
Transfinite Line{29, 9}= 20 Using Progression 1;

// @ gaps
Transfinite Line{18,22} =  1 Using Progression 1;
Transfinite Line{19,23} = 10 Using Progression 1;
Transfinite Line{20,24} =  1 Using Progression 1;
Transfinite Line{22,26} =  1 Using Progression 1;
Transfinite Line{24,28} =  1 Using Progression 1;
Transfinite Line{26,12} =  1 Using Progression 1;
Transfinite Line{28,10} =  1 Using Progression 1;

// @ pieza
Transfinite Line{23,27} = 10 Using Progression 1;
Transfinite Line{27,11} = 10 Using Progression 1;

// @ molde - gap (parte inclinada verticales)
Transfinite Line{14,33} = 40 Using Progression 1;
Transfinite Line{32,8}  = 40 Using Progression 1;

// @ pieza - gap (parte inclinada verticales)
Transfinite Line{33,38} = 40 Using Progression 1;
Transfinite Line{37,32} = 40 Using Progression 1;

// definimos las superficies transfinitas
// @ molde 
Transfinite Surface{ 1}= {1,2,8,7};
Transfinite Surface{ 2}= {2,3,27,8};
Transfinite Surface{ 3}= {3,4,28,27};
Transfinite Surface{ 4}= {4,5,9,28};
Transfinite Surface{ 5}= {5,6,10,9};
Transfinite Surface{ 6}= {7,8,25,29};
Transfinite Surface{ 7}= {9,10,30,26};
Transfinite Surface{ 8}= {29,25,12,11};
Transfinite Surface{ 9}= {26,30,14,13};
Transfinite Surface{10}= {11,12,16,15};
Transfinite Surface{11}= {13,14,18,17};

// @ gaps 
Transfinite Surface{12}= {8,27,19,25};
Transfinite Surface{13}= {27,28,20,19};
Transfinite Surface{14}= {28,9,26,20};
Transfinite Surface{15}= {20,26,13,21};
Transfinite Surface{16}= {21,13,17,22};
Transfinite Surface{17}= {23,16,12,24};
Transfinite Surface{18}= {12,24,25,19};

// @ pieza
Transfinite Surface{19}= {19,20,21,24};
Transfinite Surface{20}= {21,24,23,22};

// recombinamos las superficies @ mallar con rectangulos
// @ molde
Recombine Surface { 1}; 
Recombine Surface { 2}; 
Recombine Surface { 3}; 
Recombine Surface { 4}; 
Recombine Surface { 5}; 
Recombine Surface { 6}; 
Recombine Surface { 7}; 
Recombine Surface { 8}; 
Recombine Surface { 9}; 
Recombine Surface {10}; 
Recombine Surface {11}; 

// @ gaps
Recombine Surface {12};
Recombine Surface {13};
Recombine Surface {14};
Recombine Surface {15};
Recombine Surface {16};
Recombine Surface {17};
Recombine Surface {18};

// @ pieza
Recombine Surface {19};
Recombine Surface {20};

// definimos las entidades fisicas
/*
 pieza= 1
 molde= 2
 ContactoPiezaMolde   = 3
 ContactoMoldeAmbiente= 4
 ContactoPiezaAmbiente= 5 
 ContactoPiezaSuelo   = 6
*/

pieza= 1;
molde= 2;
ContactoPiezaMolde   = 3;
ContactoMoldeAmbiente= 4;
ContactoPiezaAmbiente= 5; 
ContactoPiezaSuelo   = 6;

// superficies == pieza y molde
Physical Surface(pieza)= {19,20};
Physical Surface(ContactoPiezaMolde)= {12,13,14,15,16,17,18};
Physical Surface(molde)= {1,2,3,4,5,6,7,8,9,10,11};

// contactos 
Physical Line(ContactoMoldeAmbiente)= {6,47,7,8,9,10,11,12,13};
//Physical Line(ContactoPiezaAmbiente)= {7}; 


