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

*** empty log message ***

parent 33274809
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@
<H1>README 1/9</H1>
[<A HREF="#top">top</A>][prev][<A HREF="#file2">next</A>]
<PRE>
$Id: tutorial.html,v 1.2 2000-12-10 15:08:32 geuzaine Exp $
$Id: tutorial.html,v 1.3 2000-12-11 22:15:53 geuzaine Exp $
Here are the examples in the Gmsh tutorial. These examples are
commented (both C and C++-style comments can be used in Gmsh input
......@@ -560,7 +560,7 @@ Physical Surface(2) = {24};
*
* Gmsh tutorial 5
*
* Characteristic lengths, Functions, Loops
* Characteristic lengths, Arrays of variables, Functions, Loops
*
*********************************************************************/</FONT></I>
......@@ -660,13 +660,21 @@ Function CheeseHole
l7 = newreg; Line Loop(l7) = {c2,c7,c12}; Ruled Surface(newreg) = {l7};
l8 = newreg; Line Loop(l8) = {-c6,-c9,c2}; Ruled Surface(newreg) = {l8};
l9 = newreg; Surface Loop(l9) = {l8+1, l5+1, l1+1, l2+1, -(l3+1), -(l7+1), l6+1, l4+1};
thehole = newreg; Volume(thehole) = {l9};
<I><FONT COLOR="#B22222">// Arrays of variables can be manipulated in the same way as classical
</FONT></I><I><FONT COLOR="#B22222">// variables. Warning: accessing an uninitialized element in an array
</FONT></I><I><FONT COLOR="#B22222">// will produce an unpredictable result.
</FONT></I>
theloops[t] = newreg ;
Surface Loop(theloops[t]) = {l8+1, l5+1, l1+1, l2+1, -(l3+1), -(l7+1), l6+1, l4+1};
thehole = newreg ;
Volume(thehole) = theloops[t] ;
Return
x = 0; y = 0.75; z = 0; r = 0.09;
x = 0 ; y = 0.75 ; z = 0 ; r = 0.09 ;
<I><FONT COLOR="#B22222">// A For loop is used to generate five holes in the cube:
</FONT></I>
......@@ -679,27 +687,37 @@ For t In {1:5}
</FONT></I><I><FONT COLOR="#B22222">// defining a function, we could have define a file containing the
</FONT></I><I><FONT COLOR="#B22222">// same code, and used the Include command to include this file.
</FONT></I>
Call CheeseHole;
Call CheeseHole ;
<I><FONT COLOR="#B22222">// A physical volume is defined for each cheese hole
</FONT></I>
Physical Volume (t) = thehole ;
<I><FONT COLOR="#B22222">// The Printf function permits to print the value of variables on the
</FONT></I><I><FONT COLOR="#B22222">// terminal:
</FONT></I><I><FONT COLOR="#B22222">// terminal, in a way similar to the 'printf' C function:
</FONT></I>
Printf(&quot;The cheese hole has number %g!&quot;, thehole);
Printf(&quot;The cheese hole %g (center = {%g,%g,%g}, radius = %g) has number %g!&quot;,
t, x, y, z, r, thehole) ;
<I><FONT COLOR="#B22222">// Note: All Gmsh variables are treated internally as double precision
</FONT></I><I><FONT COLOR="#B22222">// numbers. The format string should thus only contain valid double
</FONT></I><I><FONT COLOR="#B22222">// precision number format specifiers (see the C or C++ language
</FONT></I><I><FONT COLOR="#B22222">// reference for more details).
</FONT></I>
EndFor
<I><FONT COLOR="#B22222">// This is the surface loop for the exterior surface of the cube:
</FONT></I>
Surface Loop(185) = {35,31,29,37,33,23,39,25,27};
theloops[0] = newreg ;
Surface Loop(theloops[0]) = {35,31,29,37,33,23,39,25,27} ;
<I><FONT COLOR="#B22222">// The volume of the cube, without the 5 cheese holes, is defined by 6
</FONT></I><I><FONT COLOR="#B22222">// surface loops (the exterior surface and the five interior loops):
</FONT></I><I><FONT COLOR="#B22222">// surface loops (the exterior surface and the five interior loops).
</FONT></I><I><FONT COLOR="#B22222">// To reference an array of variables, its identifier is followed by
</FONT></I><I><FONT COLOR="#B22222">// '[]':
</FONT></I>
Volume(186) = {185,184,155,126,97,68};
Volume(186) = {theloops[]} ;
<I><FONT COLOR="#B22222">// This physical volume assigns the region number 10 to the tetrahedra
</FONT></I><I><FONT COLOR="#B22222">// paving the cube (but not the holes, whose elements were tagged from
......@@ -1040,8 +1058,8 @@ General.Axes = 0 ;
</FONT></I>
PostProcessing.View[0].Name = &quot;This is a very stupid demonstration...&quot; ;
PostProcessing.View[0].IntervalsType = 2 ;
PostProcessing.View[0].Offset = {0,0,0.05} ;
PostProcessing.View[0].Raise = {0,0,0} ;
PostProcessing.View[0].Offset2 = 0.05 ;
PostProcessing.View[0].Raise2 = 0 ;
PostProcessing.View[0].Light = 1 ;
PostProcessing.View[1].Name = &quot;...of Gmsh's scripting capabilities&quot; ;
......@@ -1063,7 +1081,7 @@ For num In {1:255}
t = (PostProcessing.View[0].TimeStep &lt; PostProcessing.View[0].NbTimeStep-1) ? t+1 : 0 ;
PostProcessing.View[0].Raise += {0,0,0.001*t} ;
PostProcessing.View[0].Raise2 += 0.001*t ;
<I><FONT COLOR="#B22222">// It is possible to nest loops:
</FONT></I>
......@@ -1082,6 +1100,11 @@ For num In {1:255}
</FONT></I>
If (!(num % 20))
<I><FONT COLOR="#B22222">// The Sprintf function permits to create complex strings using
</FONT></I><I><FONT COLOR="#B22222">// variables (since all Gmsh variables are treated internally as
</FONT></I><I><FONT COLOR="#B22222">// double precision numbers, the format should only contain valid
</FONT></I><I><FONT COLOR="#B22222">// double precision number format specifiers):
</FONT></I>
Print Sprintf(&quot;t8-%g.gif&quot;, num); <I><FONT COLOR="#B22222">// print the scene in a gif file
</FONT></I>
EndIf
......
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