From c4a770834bf6173130c441533b9926a981dca44f Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 29 Jan 2010 12:27:44 +0000 Subject: [PATCH] improve comments (thanks to Takuya OSHIMA) --- tutorial/t4.geo | 44 +++++++++++++++++++++++++------------------- tutorial/t5.geo | 28 ++++++++++++++++------------ 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/tutorial/t4.geo b/tutorial/t4.geo index 1e0b044c9c..66eacbb5d9 100644 --- a/tutorial/t4.geo +++ b/tutorial/t4.geo @@ -6,22 +6,23 @@ * *********************************************************************/ -// As usual, we start by defining some variables, some points and some -// lines: +// As usual, we start by defining some variables: 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; - -h1 = 5*cm; h2 = 10*cm; h3 = 5*cm; h4 = 2*cm; h5 = 4.5*cm; +// We can use all the usual mathematical functions (note the +// capitalized first letters), plus some useful functions like +// 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); -ssin = Sqrt(1-ccos^2); - -Lc1 = 0.01; -Lc2 = 0.003; +// Then we define some points and some lines using these variables: Point(1) = { -e1-e2, 0.0 , 0.0 , Lc1}; Point(2) = { -e1-e2, h1 , 0.0 , Lc1}; @@ -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}; 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 // view containing some strings, and change the color of some mesh // entities: View "comments" { - // 10 pixels from the left and 15 pixels from the top of the graphic - // window: - T2(10,15,0){StrCat("File created on ", Today)}; + // Add a text string in window coordinates, 10 pixels from the left + // and 10 pixels from the bottom: + T2(10, -10, 0){ "Copyright (C) My Company" }; - // 10 pixels from the left and 10 pixels from the bottom of the - // graphic window: - T2(10,-10,0){"Copyright (C) My Company"}; + // Add another text string in window coordinates, 10 pixels from the + // left and 15 pixels from the top, using the StrCat() function to + // 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): - T3(0,0.11,0,0){"Hole"}; + // Add a text string in model coordinates at (X,Y,Z) = (0, 0.11, 0): + T3(0, 0.11, 0, 0){ "Hole" }; }; Color Grey50{ Surface{ 22 }; } diff --git a/tutorial/t5.geo b/tutorial/t5.geo index 3177673e97..4f924457c6 100644 --- a/tutorial/t5.geo +++ b/tutorial/t5.geo @@ -6,27 +6,28 @@ * *********************************************************************/ -// Again, we start be defining some characteristic lengths: +// We start by defining some target mesh sizes: lcar1 = .1; lcar2 = .0005; lcar3 = .055; -// If we wanted to change these lengths globally (without changing the -// above definitions), we could give a global scaling factor for all -// characteristic lengths on the command line with the `-clscale' +// If we wanted to change these mesh sizes globally (without changing +// the above definitions), we could give a global scaling factor for +// all characteristic lengths on the command line with the `-clscale' // option (or with `Mesh.CharacteristicLengthFactor' in an option // file). For example, with: // // > gmsh t5.geo -clscale 1 // -// this input file produces a mesh of approximately 3,000 nodes and -// 15,000 tetrahedra. With +// this input file produces a mesh of approximately 1,300 nodes and +// 11,000 tetrahedra. With // // > gmsh t5.geo -clscale 0.2 // -// the mesh counts approximately 600,000 nodes and 3.6 million -// tetrahedra. +// the mesh counts approximately 350,000 nodes and 2.1 million +// 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 // truncated cube: @@ -125,6 +126,8 @@ For t In {1:5} x += 0.166 ; z += 0.166 ; + // We call the `CheeseHole' function: + Call CheeseHole ; // We define a physical volume for each hole: @@ -134,7 +137,7 @@ For t In {1:5} // We also print some variables on the terminal (note that, since // all variables are treated internally as floating point numbers, // 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!", t, x, y, z, r, thehole) ; @@ -149,9 +152,10 @@ theloops[0] = newreg ; 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 -// surface loops (the exterior surface and the five interior loops). -// To reference an array of variables, its identifier is followed by -// '[]': +// surface loops: the first surface loop defines the exterior surface; +// 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[]} ; -- GitLab