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

improve comments (thanks to Takuya OSHIMA)

parent 28ab5d51
No related branches found
No related tags found
No related merge requests found
...@@ -6,22 +6,23 @@ ...@@ -6,22 +6,23 @@
* *
*********************************************************************/ *********************************************************************/
// As usual, we start by defining some variables, some points and some // As usual, we start by defining some variables:
// lines:
cm = 1e-02; cm = 1e-02;
e1 = 4.5 * cm; e2 = 6 * cm / 2; e3 = 5 * cm / 2;
h1 = 5 * cm; h2 = 10 * cm; h3 = 5 * cm; h4 = 2 * cm; h5 = 4.5 * cm;
R1 = 1 * cm; R2 = 1.5 * cm; r = 1 * cm;
Lc1 = 0.01;
Lc2 = 0.003;
e1 = 4.5*cm; e2 = 6*cm / 2; e3 = 5*cm / 2; // We can use all the usual mathematical functions (note the
// capitalized first letters), plus some useful functions like
h1 = 5*cm; h2 = 10*cm; h3 = 5*cm; h4 = 2*cm; h5 = 4.5*cm; // Hypot(a, b) := Sqrt(a^2 + b^2):
R1 = 1*cm; R2 = 1.5*cm; r = 1*cm; ccos = (-h5*R1 + e2 * Hypot(h5, Hypot(e2, R1))) / (h5^2 + e2^2);
ssin = Sqrt(1 - ccos^2);
ccos = ( -h5*R1 + e2 * Hypot(h5,Hypot(e2,R1)) ) / (h5^2 + e2^2); // Then we define some points and some lines using these variables:
ssin = Sqrt(1-ccos^2);
Lc1 = 0.01;
Lc2 = 0.003;
Point(1) = { -e1-e2, 0.0 , 0.0 , Lc1}; Point(1) = { -e1-e2, 0.0 , 0.0 , Lc1};
Point(2) = { -e1-e2, h1 , 0.0 , Lc1}; Point(2) = { -e1-e2, h1 , 0.0 , Lc1};
...@@ -93,21 +94,26 @@ Plane Surface(22) = {21}; ...@@ -93,21 +94,26 @@ Plane Surface(22) = {21};
Line Loop(23) = {11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10}; Line Loop(23) = {11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10};
Plane Surface(24) = {23,21}; Plane Surface(24) = {23,21};
// As a general rule, if a surface has N holes, it is defined by N+1
// line loops: the first loop defines the exterior boundary; the other
// loops define the boundaries of the holes.
// Finally, we can add some comments by embedding a post-processing // Finally, we can add some comments by embedding a post-processing
// view containing some strings, and change the color of some mesh // view containing some strings, and change the color of some mesh
// entities: // entities:
View "comments" { View "comments" {
// 10 pixels from the left and 15 pixels from the top of the graphic // Add a text string in window coordinates, 10 pixels from the left
// window: // and 10 pixels from the bottom:
T2(10,15,0){StrCat("File created on ", Today)}; T2(10, -10, 0){ "Copyright (C) My Company" };
// 10 pixels from the left and 10 pixels from the bottom of the // Add another text string in window coordinates, 10 pixels from the
// graphic window: // left and 15 pixels from the top, using the StrCat() function to
T2(10,-10,0){"Copyright (C) My Company"}; // concatenate a string with the current date:
T2(10, 15, 0){ StrCat("File created on ", Today) };
// in the model, at (X,Y,Z) = (0.0,0.11,0.0): // Add a text string in model coordinates at (X,Y,Z) = (0, 0.11, 0):
T3(0,0.11,0,0){"Hole"}; T3(0, 0.11, 0, 0){ "Hole" };
}; };
Color Grey50{ Surface{ 22 }; } Color Grey50{ Surface{ 22 }; }
......
...@@ -6,27 +6,28 @@ ...@@ -6,27 +6,28 @@
* *
*********************************************************************/ *********************************************************************/
// Again, we start be defining some characteristic lengths: // We start by defining some target mesh sizes:
lcar1 = .1; lcar1 = .1;
lcar2 = .0005; lcar2 = .0005;
lcar3 = .055; lcar3 = .055;
// If we wanted to change these lengths globally (without changing the // If we wanted to change these mesh sizes globally (without changing
// above definitions), we could give a global scaling factor for all // the above definitions), we could give a global scaling factor for
// characteristic lengths on the command line with the `-clscale' // all characteristic lengths on the command line with the `-clscale'
// option (or with `Mesh.CharacteristicLengthFactor' in an option // option (or with `Mesh.CharacteristicLengthFactor' in an option
// file). For example, with: // file). For example, with:
// //
// > gmsh t5.geo -clscale 1 // > gmsh t5.geo -clscale 1
// //
// this input file produces a mesh of approximately 3,000 nodes and // this input file produces a mesh of approximately 1,300 nodes and
// 15,000 tetrahedra. With // 11,000 tetrahedra. With
// //
// > gmsh t5.geo -clscale 0.2 // > gmsh t5.geo -clscale 0.2
// //
// the mesh counts approximately 600,000 nodes and 3.6 million // the mesh counts approximately 350,000 nodes and 2.1 million
// tetrahedra. // tetrahedra. You can check mesh statistics in the graphical user
// interface with the `Tools->Statistics' menu.
// We proceed by defining some elementary entities describing a // We proceed by defining some elementary entities describing a
// truncated cube: // truncated cube:
...@@ -125,6 +126,8 @@ For t In {1:5} ...@@ -125,6 +126,8 @@ For t In {1:5}
x += 0.166 ; x += 0.166 ;
z += 0.166 ; z += 0.166 ;
// We call the `CheeseHole' function:
Call CheeseHole ; Call CheeseHole ;
// We define a physical volume for each hole: // We define a physical volume for each hole:
...@@ -134,7 +137,7 @@ For t In {1:5} ...@@ -134,7 +137,7 @@ For t In {1:5}
// We also print some variables on the terminal (note that, since // We also print some variables on the terminal (note that, since
// all variables are treated internally as floating point numbers, // all variables are treated internally as floating point numbers,
// the format string should only contain valid floating point format // the format string should only contain valid floating point format
// specifiers): // specifiers like `%g', `%f', '%e', etc.):
Printf("Hole %g (center = {%g,%g,%g}, radius = %g) has number %g!", Printf("Hole %g (center = {%g,%g,%g}, radius = %g) has number %g!",
t, x, y, z, r, thehole) ; t, x, y, z, r, thehole) ;
...@@ -149,9 +152,10 @@ theloops[0] = newreg ; ...@@ -149,9 +152,10 @@ theloops[0] = newreg ;
Surface Loop(theloops[0]) = {35,31,29,37,33,23,39,25,27} ; Surface Loop(theloops[0]) = {35,31,29,37,33,23,39,25,27} ;
// The volume of the cube, without the 5 holes, is now defined by 6 // The volume of the cube, without the 5 holes, is now defined by 6
// surface loops (the exterior surface and the five interior loops). // surface loops: the first surface loop defines the exterior surface;
// To reference an array of variables, its identifier is followed by // the surface loops other than the first one define holes. (Again,
// '[]': // to reference an array of variables, its identifier is followed by
// square brackets):
Volume(186) = {theloops[]} ; Volume(186) = {theloops[]} ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment