[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes the general commands and options that can be used in Gmsh's ASCII text input files. By "general", we mean "not specifically related to one of the geometry, mesh, solver or post-processing modules". Commands peculiar to these modules will be introduced in 3. Geometry module, 4. Mesh module, 5. Solver module, and 6. Post-processing module, respectively.
Note that, if you are just beginning to use Gmsh, or just want to see what Gmsh is all about, you really don't need to read this chapter and the four next ones. Just have a quick look at 8. Running Gmsh, and go play with the graphical user interface, running the tutorials and demonstration files bundled in the distribution! Most of the commands and options described in the following chapters are available interactively in the GUI, so you don't need to worry about Gmsh's internals for creating your first geometries, meshes and post-processing plots. Once you master the tutorial (read the source files: they are heavily commented--see 7. Tutorial), you might want to come back here to learn more about the specific syntax of Gmsh's commands and esoteric options.
2.1 Expressions 2.2 Operators 2.3 Built-in functions 2.4 User-defined functions 2.5 Loops and conditionals 2.6 General commands 2.7 General options
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The two constant types used in Gmsh are real and string (there is no integer type). These types have the same meaning and syntax as in the C or C++ programming languages.
2.1.1 Floating point expressions 2.1.2 Character expressions 2.1.3 Color expressions
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Floating point expressions (or, more simply, "expressions") are denoted by the metasyntactic variable expression (remember the definition of the syntactic rules in 1.7 Syntactic rules used in this document), and are evaluated during the parsing of the data file:
expression: real | string | string [ expression ] | # string [ ] | ( expression ) | operator-unary-left expression | expression operator-unary-right | expression operator-binary expression | expression operator-ternary-left expression operator-ternary-right expression | built-in-function | real-option |
Such expressions are used in most of Gmsh's commands. The operators operator-unary-left, operator-unary-right, operator-binary, operator-ternary-left and operator-ternary-right are defined in 2.2 Operators. For the definition of built-in-functions, see 2.3 Built-in functions. The various real-options are listed in 2.7 General options, 3.2 Geometry options, 4.3 Mesh options, 5.1 Solver options, and 6.3 Post-processing options.
List of expressions are also widely used, and are defined as:
expression-list: expression-list-item <, expression-list-item> ... |
with
expression-list-item: expression | expression : expression | expression : expression : expression | string [ ] | string [ { expression-list } ] | Point { expression } | transform | extrude |
The second case in this last definition permits to create a list containing the range of numbers comprised between two expressions, with a unit incrementation step. The third case also permits to create a list containing the range of numbers comprised between two expressions, but with a positive or negative incrementation step equal to the third expression. The fourth case permits to reference an expression list. The fifth case permits to reference an expression sublist (whose elements are those corresponding to the indices provided by the expression-list). The sixth case permits to retrieve the coordinates of a given geometry point (see section 3.1.1 Points). The last two cases permit to retreive the indices of entities created through geometrical transformations adn extrusions (see 3.1.6 Transformations, and 3.1.5 Extrusions).
To see the practical use of such expressions, have a look at the first
couple of examples in 7. Tutorial. Note that, in order to lighten the
syntax, you can always omit the braces {}
enclosing an
expression-list if this expression-list only contains a single
item. Also note that a braced expression-list can be preceded by a
minus sign in order to change the sign of all the
expression-list-items.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Character expressions are defined as:
char-expression: "string" | StrPrefix ( char-expression ) | StrCat ( char-expression , char-expression ) | Sprintf ( char-expression , expression-list ) | char-option |
The second case in this definition permits to take the
prefix of a string (e.g. for removing the extension from a file name). The
third case permits to concatenate two character expressions, and the fourth
is an equivalent of the sprintf
C function (where
char-expression is a format string that can contain floating point
formatting characters: %e
, %g
, etc.). The last case permits to
use the value of a char-option as a char-expression. The
various char-options are listed in 2.7 General options,
3.2 Geometry options, 4.3 Mesh options, 5.1 Solver options, and
6.3 Post-processing options.
Character expressions are mostly used to specify non-numeric options and input/output file names. See 7.8 `t8.geo', for an interesting usage of char-expressions in an animation script.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Colors expressions are hybrids between fixed-length braced expression-lists and strings:
color-expression: string | { expression, expression, expression } | { expression, expression, expression, expression } | color-option |
The first case permits to use the X Windows names to refer to colors,
e.g., Red
, SpringGreen
, LavenderBlush3
, ...
(see `Common/Colors.h' in Gmsh's source tree for a complete list). The
second case permits to define colors by using three expressions to specify
their red, green and blue components (with values comprised between 0 and
255). The third case permits to define colors by using their red, green and
blue color components as well as their alpha channel. The last case permits
to use the value of a color-option as a color-expression. The
various color-options are listed in 2.7 General options,
3.2 Geometry options, 4.3 Mesh options, 5.1 Solver options, and
6.3 Post-processing options.
See 7.3 `t3.geo', for an example of the use of color expressions.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Gmsh's operators are similar to the corresponding operators in C and C++. Here is the list of the unary, binary and ternary operators currently implemented.
operator-unary-left:
-
!
operator-unary-right:
++
--
operator-binary:
^
*
/
%
+
-
==
!=
>
>=
<
<=
&&
||
||
is evaluated even if the first one is true).
operator-ternary-left:
?
:
The evaluation priorities are summarized below(2) (from stronger to
weaker, i.e. *
has a highest evaluation priority than +
).
Parentheses ()
may be used anywhere to change the order of
evaluation:
()
, []
, .
, #
^
!
, ++
, --
, -
(unary)
*
, /
, %
+
, -
<
, >
, <=
, >=
==
, !=
&&
||
?:
=
, +=
, -=
, *=
, /=
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A built-in function is composed of an identifier followed by a pair of parentheses containing an expression-list (the list of its arguments)(3). Here is the list of the built-in functions currently implemented:
build-in-function:
Acos ( expression )
Asin ( expression )
Atan ( expression )
Atan2 ( expression, expression )
Ceil ( expression )
Cos ( expression )
Cosh ( expression )
Exp ( expression )
Fabs ( expression )
Fmod ( expression, expression )
Floor ( expression )
Hypot ( expression, expression )
Log ( expression )
Log10 ( expression )
Modulo ( expression, expression )
Fmod( expression, expression )
.
Rand ( expression )
Sqrt ( expression )
Sin ( expression )
Sinh ( expression )
Tan ( expression )
Tanh ( expression )
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
User-defined functions take no arguments, and are evaluated as if a file
containing the function body was included at the location of the Call
statement.
Function string
Function
string
', and can contain any Gmsh command.
Return
Call string;
See 7.5 `t5.geo', for an example of a user-defined function.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Loops and conditionals are defined as follows, and can be imbricated:
For ( expression : expression )
For ( expression :
expression )
' and the matching EndFor
are executed.
For ( expression : expression : expression )
For ( expression : expression :
expression )
' and the matching EndFor
are executed.
For string In { expression : expression }
For string In {
expression : expression }
' and the matching EndFor
are
executed.
For string In { expression : expression : expression }
For string In { expression :
expression : expression }
' and the matching EndFor
are
executed.
EndFor
For
command.
If ( expression )
If ( expression )
' and the matching
Endif
is evaluated if expression is non-zero.
EndIf
If
command.
See 7.5 `t5.geo', for an example of For
and If
commands. Gmsh
does not provide any Else
(or similar) command at the time of this
writing.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following commands can be used anywhere in a Gmsh ASCII text input file:
string = expression;
Pi
MPI_Size
MPI_Rank
newp
newp
permits to know the highest number already attributed. This is
mostly useful when writing user-defined functions (see section 2.4 User-defined functions) or general geometric primitives, when one does not know a
priori which numbers are already attributed, and which ones are still
available.
newl
news
newv
newreg
newreg
returns the
maximum of newp
, newl
, news
, newv
and all
physical entity numbers(4).
string [ ] = { expression-list };
string[]
, or affects
expression-list to an existing expression list identifier.
string [ { expression-list } ] = { expression-list };
real-option = expression;
char-option = char-expression;
color-option = color-expression;
string | real-option += expression;
string | real-option -= expression;
string | real-option *= expression;
string | real-option /= expression;
string [ { expression-list } ] += { expression-list };
string [ { expression-list } ] -= { expression-list };
string [ { expression-list } ] *= { expression-list };
string [ { expression-list } ] /= { expression-list };
Exit;
Printf ( char-expression , expression-list );
Printf
is equivalent to the printf
C function:
char-expression is a format string that can contain formatting
characters (%f
, %e
, etc.). Note that all expressions
are evaluated as floating point values in Gmsh (see section 2.1 Expressions), so
that only valid floating point formatting characters make sense in
char-expression. See 7.5 `t5.geo', for an example of the use of
Printf
.
Merge char-expression;
Draw;
BoundingBox;
BoundingBox { expression, expression, expression, expression, expression, expression };
Delete All;
Print char-expression;
Print.Format
(see section 2.7 General options).
Sleep expression;
System char-expression;
Include char-expression;
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is the list of the general char-options, real-options and color-options (in that order--check the default values to see the actual types). Most of these options are accessible in the graphical user interface, but not all of them. When running Gmsh interactively, changing an option in the ASCII text input file will modify the option in the GUI in real time. This permits for example to resize the graphical window in a script, or to interact with animations in the script and in the GUI at the same time.
Gmsh's default behavior is to save some of these options in a per-user
"session resource" file (General.SessionFileName
) every time Gmsh
is shut down. This permits for example to automatically remember the size
and location of the windows or which fonts to use. Other options can be
saved in a per-user "option" file (General.OptionsFileName
),
automatically loaded by Gmsh every time it starts up, by using the
`Tools->Options->Save' menu.
General.DefaultFileName
"untitled.geo"
General.SessionFileName
General.Display
""
-
General.ErrorFileName
".gmsh-errors"
General.SessionFileName
General.GraphicsFont
"Helvetica"
General.SessionFileName
General.OptionsFileName
".gmsh-options"
General.SessionFileName
General.SessionFileName
".gmshrc"
-
General.Scheme
""
General.SessionFileName
General.TextEditor
"open -e %s"
General.OptionsFileName
General.TmpFileName
".gmsh-tmp"
General.SessionFileName
General.WebBrowser
"open %s"
General.OptionsFileName
General.AlphaBlending
1
General.OptionsFileName
General.ArrowHeadRadius
0.12
General.OptionsFileName
General.ArrowStemLength
0.56
General.OptionsFileName
General.ArrowStemRadius
0.02
General.OptionsFileName
General.Axes
0
General.OptionsFileName
General.Clip0
0
-
General.Clip0A
0
-
General.Clip0B
0
-
General.Clip0C
0
-
General.Clip0D
0
-
General.Clip1
0
-
General.Clip1A
0
-
General.Clip1B
0
-
General.Clip1C
0
-
General.Clip1D
0
-
General.Clip2
0
-
General.Clip2A
0
-
General.Clip2B
0
-
General.Clip2C
0
-
General.Clip2D
0
-
General.Clip3
0
-
General.Clip3A
0
-
General.Clip3B
0
-
General.Clip3C
0
-
General.Clip3D
0
-
General.Clip4
0
-
General.Clip4A
0
-
General.Clip4B
0
-
General.Clip4C
0
-
General.Clip4D
0
-
General.Clip5
0
-
General.Clip5A
0
-
General.Clip5B
0
-
General.Clip5C
0
-
General.Clip5D
0
-
General.ColorScheme
0
General.OptionsFileName
General.ConfirmOverwrite
1
General.SessionFileName
General.ContextPositionX
650
General.SessionFileName
General.ContextPositionY
150
General.SessionFileName
General.DoubleBuffer
1
General.OptionsFileName
General.FakeTransparency
0
General.OptionsFileName
General.FastRedraw
1
General.OptionsFileName
General.FontSize
12
General.SessionFileName
General.GraphicsFontSize
14
General.SessionFileName
General.GraphicsHeight
500
General.SessionFileName
General.GraphicsPositionX
20
General.SessionFileName
General.GraphicsPositionY
30
General.SessionFileName
General.GraphicsWidth
700
General.SessionFileName
General.InitialModule
0
General.OptionsFileName
General.Light0
1
General.OptionsFileName
General.Light0X
0.65
General.OptionsFileName
General.Light0Y
0.65
General.OptionsFileName
General.Light0Z
1
General.OptionsFileName
General.Light1
0
General.OptionsFileName
General.Light1X
0.5
General.OptionsFileName
General.Light1Y
0.3
General.OptionsFileName
General.Light1Z
1
General.OptionsFileName
General.Light2
0
General.OptionsFileName
General.Light2X
0.5
General.OptionsFileName
General.Light2Y
0.3
General.OptionsFileName
General.Light2Z
1
General.OptionsFileName
General.Light3
0
General.OptionsFileName
General.Light3X
0.5
General.OptionsFileName
General.Light3Y
0.3
General.OptionsFileName
General.Light3Z
1
General.OptionsFileName
General.Light4
0
General.OptionsFileName
General.Light4X
0.5
General.OptionsFileName
General.Light4Y
0.3
General.OptionsFileName
General.Light4Z
1
General.OptionsFileName
General.Light5
0
General.OptionsFileName
General.Light5X
0.5
General.OptionsFileName
General.Light5Y
0.3
General.OptionsFileName
General.Light5Z
1
General.OptionsFileName
General.LineWidth
1
General.OptionsFileName
General.MenuPositionX
800
General.SessionFileName
General.MenuPositionY
50
General.SessionFileName
General.MessagePositionX
650
General.SessionFileName
General.MessagePositionY
150
General.SessionFileName
General.MessageHeight
350
General.SessionFileName
General.MessageWidth
450
General.SessionFileName
General.OptionsPositionX
650
General.SessionFileName
General.OptionsPositionY
150
General.SessionFileName
General.Orthographic
1
General.OptionsFileName
General.PointSize
3
General.OptionsFileName
General.QuadricSubdivisions
8
General.OptionsFileName
General.RotationX
0
-
General.RotationY
0
-
General.RotationZ
0
-
General.RotationCenterGravity
1
General.OptionsFileName
General.RotationCenterX
0
-
General.RotationCenterY
0
-
General.RotationCenterZ
0
-
General.SaveOptions
0
General.SessionFileName
General.SaveSession
1
General.SessionFileName
General.ScaleX
1
-
General.ScaleY
1
-
General.ScaleZ
1
-
General.Shininess
0.4
General.OptionsFileName
General.SmallAxes
1
General.OptionsFileName
General.SmallAxesPositionX
-60
General.OptionsFileName
General.SmallAxesPositionY
-40
General.OptionsFileName
General.SolverPositionX
650
General.SessionFileName
General.SolverPositionY
150
General.SessionFileName
General.StatisticsPositionX
650
General.SessionFileName
General.StatisticsPositionY
150
General.SessionFileName
General.SystemMenuBar
1
General.SessionFileName
General.Terminal
0
General.OptionsFileName
General.Tooltips
1
General.OptionsFileName
General.Trackball
1
General.OptionsFileName
General.TrackballQuaternion0
0
-
General.TrackballQuaternion1
0
-
General.TrackballQuaternion2
0
-
General.TrackballQuaternion3
1
-
General.TranslationX
0
-
General.TranslationY
0
-
General.TranslationZ
0
-
General.VectorType
4
General.OptionsFileName
General.Verbosity
3
General.OptionsFileName
General.VisibilityMode
0
General.SessionFileName
General.VisibilityPositionX
650
General.SessionFileName
General.VisibilityPositionY
150
General.SessionFileName
General.ZoomFactor
1.1
General.OptionsFileName
General.Color.Background
{0,0,0}
General.OptionsFileName
General.Color.Foreground
{255,255,255}
General.OptionsFileName
General.Color.Text
{255,255,255}
General.OptionsFileName
General.Color.Axes
{255,255,0}
General.OptionsFileName
General.Color.SmallAxes
{255,255,255}
General.OptionsFileName
Print.EpsBackground
1
General.OptionsFileName
Print.EpsBestRoot
1
General.OptionsFileName
Print.EpsCompress
0
General.OptionsFileName
Print.EpsLineWidthFactor
0.5
General.OptionsFileName
Print.EpsOcclusionCulling
1
General.OptionsFileName
Print.EpsPointSizeFactor
1
General.OptionsFileName
Print.EpsPS3Shading
0
General.OptionsFileName
Print.EpsQuality
1
General.OptionsFileName
Print.Format
10
General.OptionsFileName
Print.GifDither
0
General.OptionsFileName
Print.GifInterlace
0
General.OptionsFileName
Print.GifSort
1
General.OptionsFileName
Print.GifTransparent
0
General.OptionsFileName
Print.JpegQuality
100
General.OptionsFileName
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |