Skip to content
Snippets Groups Projects
Commit a7b2a59d authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

improve various bits (thanks to Takuya OSHIMA)

parent cb743a29
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ Plane Surface(6) = {5} ; ...@@ -59,7 +59,7 @@ Plane Surface(6) = {5} ;
// triangles discretizing surface 6). This is achieved by the // triangles discretizing surface 6). This is achieved by the
// definition of `physical entities'. Physical entities will group // definition of `physical entities'. Physical entities will group
// elements belonging to several elementary entities by giving them a // elements belonging to several elementary entities by giving them a
// common number (a region number), and specifying their orientation. // common number (a region number).
// We can for example group the points 1 and 2 into the physical // We can for example group the points 1 and 2 into the physical
// entity 1: // entity 1:
......
...@@ -27,34 +27,38 @@ Translate {-0.05, 0, 0} { Point{3}; } ...@@ -27,34 +27,38 @@ Translate {-0.05, 0, 0} { Point{3}; }
// The resulting point can also be duplicated and translated by 0.1 // The resulting point can also be duplicated and translated by 0.1
// along the y axis: // along the y axis:
tmp[] = Translate {0, 0.1, 0} { Duplicata{ Point{3}; } } ; Translate {0, 0.1, 0} { Duplicata{ Point{3}; } }
// In this case, we assigned the result of the Translate command to a // This command created a new point with an automatically assigned
// list, so that we can retrieve the number of the newly created point // id. This id can be obtained using the graphical user interface by
// and use it to create new lines and a new surface: // hovering the mouse over it and looking at the bottom of the graphic
// window: in this case, the new point has id "6". Point 6 can then be
// used to create new entities, e.g.:
Line(7) = {3,tmp[0]}; Line(7) = {3, 6};
Line(8) = {tmp[0],5}; Line(8) = {6, 5};
Line Loop(10) = {5,-8,-7,3}; Line Loop(10) = {5,-8,-7,3};
Plane Surface(11) = {10}; Plane Surface(11) = {10};
// Of course, these transformation commands not only apply to points, // Using the graphical user interface to obtain the ids of newly
// but also to lines and surfaces. We can for example translate a copy // created entities can sometimes be cumbersome. It can then be
// of surface 6 by 0.12 units along the z axis and define some // advantageous to use the return value of the transformation commands
// additional lines and surfaces with: // directly. For example, the Translate command returns a list
// containing the ids of the translated entities. For example, we can
// translate copies of the two surfaces 6 and 11 to the right with the
// following command:
h = 0.12; my_new_surfs[] = Translate {0.12, 0, 0} { Duplicata{ Surface{6, 11}; } };
Translate {0, 0, h} { Duplicata{ Surface{6}; } }
Line(106) = {1,8}; // my_new_surfs[] (note the square brackets) denotes a list, which in
Line(107) = {2,12}; // this case contains the ids of the two new surfaces (check
Line(108) = {3,16}; // `Tools->Message console' to see the message):
Line(109) = {4,7};
Line Loop(110) = {1,107,-103,-106}; Plane Surface(111) = {110}; Printf("New surfaces '%g' and '%g'", my_new_surfs[0], my_new_surfs[1]);
Line Loop(112) = {2,107,104,-108}; Plane Surface(113) = {112};
Line Loop(114) = {3,109,-105,-108}; Plane Surface(115) = {114}; // In Gmsh lists use square brackets for their definition (mylist[] =
Line Loop(116) = {4,106,-102,-109}; Plane Surface(117) = {116}; // {1,2,3};) as well as to access their elements (myotherlist[] =
// {mylist[0], mylist[2]};). Note that list indexing starts at 0.
// Volumes are the fourth type of elementary entities in Gmsh. In the // Volumes are the fourth type of elementary entities in Gmsh. In the
// same way one defines line loops to build surfaces, one has to // same way one defines line loops to build surfaces, one has to
...@@ -62,20 +66,38 @@ Line Loop(116) = {4,106,-102,-109}; Plane Surface(117) = {116}; ...@@ -62,20 +66,38 @@ Line Loop(116) = {4,106,-102,-109}; Plane Surface(117) = {116};
// following volume does not have holes and thus consists of a single // following volume does not have holes and thus consists of a single
// surface loop: // surface loop:
Surface Loop(118) = {117,-6,111,-113,101,115}; Point(100) = {0., 0.3, 0.13, lc};
Volume(119) = {118}; Point(101) = {0.08, 0.3, 0.1, lc};
Point(102) = {0.08, 0.4, 0.1, lc};
Point(103) = {0., 0.4, 0.13, lc};
Line(110) = {4, 100}; Line(111) = {3, 101};
Line(112) = {6, 102}; Line(113) = {5, 103};
Line(114) = {103, 100}; Line(115) = {100, 101};
Line(116) = {101, 102}; Line(117) = {102, 103};
Line Loop(118) = {115, -111, 3, 110}; Plane Surface(119) = {118};
Line Loop(120) = {111, 116, -112, -7}; Plane Surface(121) = {120};
Line Loop(122) = {112, 117, -113, -8}; Plane Surface(123) = {122};
Line Loop(124) = {114, -110, 5, 113}; Plane Surface(125) = {124};
Line Loop(126) = {115, 116, 117, 114}; Plane Surface(127) = {126};
Surface Loop(128) = {127, 119, 121, 123, 125, 11};
Volume(129) = {128};
// Another way to define a volume is by extruding a surface. The // When a volume can be extruded from a surface, it is usually easier
// following command extrudes the surface 11 along the z axis and // to use the Extrude command directly instead of creating all the
// automatically creates a new volume: // points, lines and surfaces by hand. For example, the following
// command extrudes the surface 11 along the z axis and automatically
// creates a new volume (as well as all the needed points, lines and
// surfaces):
Extrude {0, 0, h} { Surface{11}; } Extrude {0, 0, 0.12} { Surface{my_new_surfs[1]}; }
// All these geometrical transformations automatically generate new // The following command permits to manually assign a characteristic
// elementary entities. The following command permits to manually // length to some of the new points:
// assign a characteristic length to some of the new points:
Characteristic Length {tmp[0], 2, 12, 3, 16, 6, 22} = lc * 4; Characteristic Length {103, 105, 109, 102, 28, 24, 6, 5} = lc * 3;
// Note that, if the transformation tools are handy to create complex // Note that, if the transformation tools are handy to create complex
// geometries, it is also sometimes useful to generate the `flat' // geometries, it is also sometimes useful to generate the `flat'
...@@ -91,4 +113,4 @@ Characteristic Length {tmp[0], 2, 12, 3, 16, 6, 22} = lc * 4; ...@@ -91,4 +113,4 @@ Characteristic Length {tmp[0], 2, 12, 3, 16, 6, 22} = lc * 4;
// with a common region number, we finally define a physical // with a common region number, we finally define a physical
// volume: // volume:
Physical Volume (1) = {119,120}; Physical Volume (1) = {129,130};
...@@ -37,13 +37,14 @@ Extrude { {0,1,0} , {-0.1,0,0.1} , -Pi/2 } { ...@@ -37,13 +37,14 @@ Extrude { {0,1,0} , {-0.1,0,0.1} , -Pi/2 } {
// {0,0.15,0.25}, Pi/2) can also be combined: // {0,0.15,0.25}, Pi/2) can also be combined:
out[] = Extrude { {-2*h,0,0}, {1,0,0} , {0,0.15,0.25} , Pi/2 } { out[] = Extrude { {-2*h,0,0}, {1,0,0} , {0,0.15,0.25} , Pi/2 } {
Surface{news-1}; Layers{10}; Recombine; Surface{144}; Layers{10}; Recombine;
}; };
// In this last extrusion command we retrieved the volume number // In this last extrusion command we retrieved the volume number
// programatically by saving the output of the command into a // programatically by using the return value (a list) of the Extrude
// list. This list will contain the "top" of the extruded surface (in // command. This list contains the "top" of the extruded surface (in
// out[0]) as well as the newly created volume (in out[1]). // out[0]), the newly created volume (in out[1]) and the ids of the
// lateral surfaces (in out[2], out[3], ...)
// We can then define a new physical volume to save all the tetrahedra // We can then define a new physical volume to save all the tetrahedra
// with a common region number (101): // with a common region number (101):
...@@ -69,9 +70,9 @@ Mesh.Color.Points = {255,0,0}; ...@@ -69,9 +70,9 @@ Mesh.Color.Points = {255,0,0};
Geometry.Color.Surfaces = Geometry.Color.Points; Geometry.Color.Surfaces = Geometry.Color.Points;
// You can click on the `?' button in the status bar of the graphic // You can use the `Help->Current options' menu to see the current
// window to see the current values of all options. To save all the // values of all options. To save all the options in a file, use
// options in a file, you can use the `File->Save as->Gmsh options' // `File->Save as->Gmsh options'. To associate the current options
// menu. To save the current options as the default options for all // with the current file use `File->Save Options->For Current
// future Gmsh sessions, you should use the `Tools->Options->Save as // File'. To save the current options for all future Gmsh sessions use
// defaults' button. // `File->Save Options->As default'.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment