manpagez: man pages & more
info gmsh
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1.1 Floating point expressions

Floating point expressions (or, more simply, “expressions”) are denoted by the metasyntactic variable expression (remember the definition of the syntactic rules in 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 |
  GetValue("string", expression)

Such expressions are used in most of Gmsh's commands. The third and fourth cases in this definition permit to extract one item from a list (see below) and get the size of a list, respectively. The operators operator-unary-left, operator-unary-right, operator-binary, operator-ternary-left and operator-ternary-right are defined in Operators. For the definition of built-in-functions, see Built-in functions. The various real-options are listed in General options, Geometry options, Mesh options, Solver options, and Post-processing options.

The last case in the definition allows to ask the user for a value interactively. For example, inserting GetValue("Value of parameter alpha?", 5.76) in an input file will query the user for the value of a certain parameter alpha, assuming the default value is 5.76. If the option General.NoPopup is set (see section General options), no question is asked and the default value is automatically used.

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 Points). The last two cases permit to retrieve the indices of entities created through geometrical transformations and extrusions (see Transformations, and Extrusions).

To see the practical use of such expressions, have a look at the first couple of examples in 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] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.