/*********************************************************************
 *
 *  Gmsh tutorial 1
 *
 *  Variables, elementary entities (points, lines, surfaces), physical
 *  entities (points, lines, surfaces)
 *
 *********************************************************************/

// The simplest construction in Gmsh's scripting language is the
// `affectation'. The following command defines a new variable `lc':

lc = 1e-1;

// This variable can then be used in the definition of Gmsh's simplest
// `elementary entity', a `Point'. A Point is defined by a list of four numbers:
// three coordinates (X, Y and Z), and a characteristic length (lc) that sets
// the target element size at the point:




//1
Point(1) = {1.5, 1.5, 5, lc};
Point(2) = {2.5, 1.5, 5, lc};
Point(3) = {2.5, 2.5, 5, lc};
Point(4) = {1.5, 2.5, 5, lc};

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

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

my_new_vol1[]=Extrude {0, 0, -1} { Surface{1}; };
Printf("New volume '%g'", my_new_vol1[1]);


//2
Point(101) = {1, 1, 4, lc};
Point(102) = {3, 1, 4, lc};
Point(103) = {3, 3, 4, lc};
Point(104) = {1, 3, 4, lc};

Line(101) = {101,102} ;
Line(102) = {102,103} ;
Line(103) = {103,104} ;
Line(104) = {104,101} ;

Line Loop(101) = {101,102,103,104} ;
Plane Surface(101) = {101} ;

my_new_vol2[]=Extrude {0, 0, -3} { Surface{101}; };
Printf("New volume '%g'", my_new_vol2[1]);

//2
Point(201) = {0, 0, 1, lc};
Point(202) = {4, 0, 1, lc};
Point(203) = {4, 4, 1, lc};
Point(204) = {0, 4, 1, lc};

Line(201) = {201,202} ;
Line(202) = {202,203} ;
Line(203) = {203,204} ;
Line(204) = {204,201} ;

Line Loop(201) = {201,202,203,204} ;
Plane Surface(201) = {201} ;

my_new_vol3[]=Extrude {0, 0, -1} { Surface{201}; };
Printf("New volume '%g'", my_new_vol3[1]);

//4
Point(401) = {-5, -5, 10, lc};
Point(402) = {9, -5, 10, lc};
Point(403) = {9, 9, 10, lc};
Point(404) = {-5, 9, 10, lc};

Line(401) = {401,402} ;
Line(402) = {402,403} ;
Line(403) = {403,404} ;
Line(404) = {404,401} ;

Line Loop(401) = {401,402,403,404} ;
Plane Surface(401) = {401} ;

my_new_vol4[]=Extrude {0, 0, -15} { Surface{401}; };
Printf("New volume '%g'", my_new_vol4[1]);

Physical Surface("Top Surface 1") = {1} ;
Physical Surface("Bottom Surface 1") = {26} ;
Physical Surface("Side Surface 1") = {13,17,21,25} ;

Physical Surface("Top Surface 2") = {101} ;
Physical Surface("Bottom Surface 2") = {126} ;
Physical Surface("Side Surface 2") = {113,117,121,125} ;

Physical Surface("Top Surface 3") = {201} ;
Physical Surface("Bottom Surface 3") = {226} ;
Physical Surface("Side Surface 3") = {213,217,221,225} ;

Physical Surface("Top Surface 4") = {401} ;
Physical Surface("Bottom Surface 4") = {426} ;
Physical Surface("Side Surface 4") = {413,417,421,425} ;

Physical Volume ("The volume 1") = {my_new_vol1[1]};
Physical Volume ("The volume 2") = {my_new_vol2[1]};
Physical Volume ("The volume 3") = {my_new_vol3[1]};
Physical Volume ("The volume 4") = {my_new_vol4[1]};
// The distribution of the mesh element sizes is then obtained by interpolation
// of these characteristic lengths throughout the geometry. Another method to
// specify characteristic lengths is to use a background mesh (see `t7.geo' and
// `bgmesh.pos').

// We can then define some additional points as well as our first curve.  Curves
// are Gmsh's second type of elementery entities, and, amongst curves, straight
// lines are the simplest. A straight line is defined by a list of point
// numbers. In the commands below, for example, the line 1 starts at point 1 and
// ends at point 2:


