Difference between revisions of "ONELAB syntax for Gmsh and GetDP"

From ONELAB
Jump to: navigation, search
(Number attributes)
(Number attributes)
Line 71: Line 71:
 
* each predefined graph is encoded as 4 characters, corresponding to the use of the values in the x, y, x' and y' axes (x' and y' are used when two curves should be displayed in the same graph): possible character values are "0" (value not used), "1" (iso-values), "2" (continuous map), "3" (discrete map), "4" (numeric value).
 
* each predefined graph is encoded as 4 characters, corresponding to the use of the values in the x, y, x' and y' axes (x' and y' are used when two curves should be displayed in the same graph): possible character values are "0" (value not used), "1" (iso-values), "2" (continuous map), "3" (discrete map), "4" (numeric value).
 
* the first group of 4 characters controls the pre-defined top-left graph, the second group controls the top-right graph, etc.
 
* the first group of 4 characters controls the pre-defined top-left graph, the second group controls the top-right graph, etc.
 +
For example, the ''string'' "0200"  will display the values as a solid line of the top-left graph; the ''string'' "10000200" will use the data on the x-axis of the top-left graph, and draw a solid line in the top-right graph.
  
 
== String attributes ==
 
== String attributes ==

Revision as of 16:04, 3 November 2014

ONELAB parameters can be defined directly in the input files (.geo and .pro files) through the DefineConstant syntax: <syntaxhighlight lang="cpp" enclose="div"> DefineConstant[ x = {1, Name "My variable"} ]; DefineConstant[ x = {1, Name "My variable", Choices {0,1}} ]; DefineConstant[ x = {1, Name "My variable", Choices {0,3,5}} ]; DefineConstant[ x = {1, Name "My variable", Choices {0="Zero",3="Three", 5="Five"}} ]; DefineConstant[ x = {1, Name "My variable", Min 0, Max 50, Step 5} ] DefineConstant[ x = {1, Name "Variables/Input/My variable", Min 0, Max 50, Step 5} ]; </syntaxhighlight>

When the input file is analyzed, if the parameter has not been previously defined, it takes the value provided in DefineConstant and is sent to the ONELAB server. The "/" character in a variable name is interpreted as a path separator, and results in the creation of a sub-tree in the graphical user interface. If the input file is re-analyzed later, the value will be updated using the value from the server (unless it is labeled ReadOnly: see below). The same syntax can be used to define string parameters: <syntaxhighlight lang="cpp" enclose="div"> DefineConstant[ s = {"a", Name "My string variable"} ]; DefineConstant[ s = {"a", Name "My string variable", Choices {"a", "b", "c"} } ]; DefineConstant[ s = {"a", Name "My string variable", Kind "File"} ] DefineConstant[ s = {"a", Name "Variables/Input/My variable"} ]; </syntaxhighlight>

Note that when the code is run without the ONELAB server, the parameters simply take the default values provided by DefineConstant. An input file modified to create an appealing graphical user interface using ONELAB can thus also be run as-is without ONELAB.

Parameters can also be defined on-the-fly, with the DefineNumber and DefineString functions. In this case the affectation always takes place, and the value is either the value in the database (if it exists), or the default value: <syntaxhighlight lang="cpp" enclose="div"> x = DefineNumber[1, Name "My variable"]; s = DefineString["a", Name "My string variable" ]; </syntaxhighlight> These on-the-fly definitions are similar to the ones used in Python clients.

Common parameter attributes

Here's the list of attributes available for all ONELAB parameters:

Name string
The name of the parameter in the ONELAB database, in the form of a "/"-separated path. The Name attribute is mandatory to exchange the variable with the ONELAB server. If no name (and no other attribute) is given, the DefineConstant construct can be used to assign default values to local variables (which will not be sent to the ONELAB server).
ReadOnly 0|1
If ReadOnly is set, the value cannot be changed server-side, and the value provided in DefineConstant is always used
Highlight string
Color used to draw the widget in the graphical interface
Visible 0|1
Should the parameter be visible in the interface?
Closed 0|1
Should the subtree containing this variable be closed?
Help string
Help string for this parameter
AutoCheck 0|1
Allows to disable automatic "check" (rebuild of the interface) when the value is changed
GmshOption string
Treat the parameter as the name of a Gmsh option (e.g. Mesh.Algorithm). Can also be used to force a database reset (with ResetDatabase), or a full model reset (with Reset).
Label string
Alternative label used in the graphical user interface, replacing the part of "Name" located after the last "/"

Number attributes

In addition, numbers can take the following specific attributes:

Min number
Minimum value allowed when scrolling in the interface, and when looping on the parameter
Max number
Maximum value allowed when scrolling in the interface, and when looping on the parameter
Step number
Step value used when scrolling in the interface, and when looping on the parameter
Range {min, max, step}
Alternate syntax for Min, Max and Step
Choices{number, number, ...}
Possible choices for the parameter
Choices{number=string, number=string, ...}
Possible choices for the parameter, with string labels for each choice
ReadOnlyRange 0|1
Treat the range (or the choices, if they are provided) as read-only
Loop string
Loop over the parameter (the string indicates the loop imbrication level: currently "1", "2" or "3")
Graph string
Display the list of values stored in the choices attribute as a 2D graph. The string encodes on which axes (x or y) of the predefined graphs (top left, top right, ...) the values will be used. Currently the string is encoded by as follows:
  • each predefined graph is encoded as 4 characters, corresponding to the use of the values in the x, y, x' and y' axes (x' and y' are used when two curves should be displayed in the same graph): possible character values are "0" (value not used), "1" (iso-values), "2" (continuous map), "3" (discrete map), "4" (numeric value).
  • the first group of 4 characters controls the pre-defined top-left graph, the second group controls the top-right graph, etc.

For example, the string "0200" will display the values as a solid line of the top-left graph; the string "10000200" will use the data on the x-axis of the top-left graph, and draw a solid line in the top-right graph.

String attributes

String accepts the following specific attributes:

Kind string
Mutable kind of the string (currently: "file")
Choices {string, string, ...}
Possible choices for the parameter
MultipleSelection string
Allow multiple selection in choices. The string indicates the initial selection pattern, e.g. "1001111".
Macro string
If string is GmshMergeFile, the parameter is treated as a filename of a macro that will be merged when the parameter is clicked in the interface. If string is GmshParseString, the parameter is directly treated as a Gmsh macro that will be parsed when the parameter is clicked in the interface.