... | ... | @@ -20,7 +20,7 @@ In addition, GetDP defines two functions to access ONELAB parameters at run-time |
|
|
|
|
|
Finally, GetDP also defines a `SendToServer` option in its `PostOperation` object, to send post-processing results directly to the ONELAB database.
|
|
|
|
|
|
# Commands
|
|
|
# Commands
|
|
|
|
|
|
## DefineNumber and DefineString
|
|
|
|
... | ... | @@ -33,18 +33,18 @@ n = DefineNumber[ 3.14, Name "a number", <attributes...>]; |
|
|
```
|
|
|
first checks if a ONELAB parameter with name `"a number"` exists in the ONELAB database.
|
|
|
* If it does not, the parameter `"a number"` is added to the ONELAB database with value `3.14`, and the same value is also assigned to the local variable `n` in the namespace of Gmsh or GetDP.
|
|
|
* If it does, it is the value fetched from the ONELAB database that is assigned to the local variable `n`, and the value given in the argument of the command is ignored.
|
|
|
* If it does, it is the value fetched from the ONELAB database that is assigned to the local variable `n`, and the value given in the argument of the command is ignored.
|
|
|
|
|
|
This means that `3.14` can be interpreted as a default value for the local variable `n` (and for the ONELAB parameter `"a number"`): the first time the statement `n = DefineNumber[ 3.14, Name "a number"]` is parsed, the local variable `n` is assigned the default value `3.14`. All subsequent executions of a command like `n = DefineNumber[ 2.718, Name "a number"]` (either in the same file if it is parsed again or in another file) will ignore the argument value `2.718`, and assign to the local variable `n` the value of `"a number"` obtained from the ONELAB database. That value could be the original default value, or a value set in the meantime by the user via the graphical user interface, or a value set by another ONELAB client.
|
|
|
|
|
|
Sometimes the opposite behavior is useful. This is done by giving the ONELAB parameter the attribute `ReadOnly 1`, e.g. by means of the command
|
|
|
Sometimes the opposite behavior is useful. This is done by giving the ONELAB parameter the attribute `ReadOnly 1`, e.g. by means of the command
|
|
|
|
|
|
```cpp
|
|
|
n = DefineNumber[2.718, Name "a number", ReadOnly 1, <attributes...> ];
|
|
|
```
|
|
|
In this case, the parameter `"a number"` in the ONELAB database and the local variable `n` are both assigned the argument value, here `2.718`. All subsequent `n = DefineNumber[ xx , Name "a number"]` statements will have the same behavior, as long as the attribute `ReadOnly` of the parameter `"a number"` is not reverted to 0. Logically, `ReadOnly` parameters are not editable in the graphical user interface.
|
|
|
In this case, the parameter `"a number"` in the ONELAB database and the local variable `n` are both assigned the argument value, here `2.718`. All subsequent `n = DefineNumber[ xx , Name "a number"]` statements will have the same behavior, as long as the attribute `ReadOnly` of the parameter `"a number"` is not reverted to 0. Logically, `ReadOnly` parameters are not editable in the graphical user interface.
|
|
|
|
|
|
A `/` character in a parameter name results in the creation of a sub-tree in the hierarchical parameter tree displayed in the graphical user interface. See also below for all the optional attributes that can be specified in addition to the `Name` of the parameter.
|
|
|
A `/` character in a parameter name results in the creation of a sub-tree in the hierarchical parameter tree displayed in the graphical user interface. See also below for all the optional attributes that can be specified in addition to the `Name` of the parameter.
|
|
|
|
|
|
If no ONELAB server exists (e.g. if GetDP is run in stand-alone mode), the `DefineNumber` command simply assigns the default value `3.14` to the local variable `n`. An input file using `DefineNumber` to create an appealing graphical user interface using ONELAB can thus also be run as-is without ONELAB.
|
|
|
|
... | ... | @@ -91,8 +91,8 @@ EndIf |
|
|
|
|
|
`DefineConstant` can also be used to define several constants at once, mixing numbers and strings:
|
|
|
```cpp
|
|
|
DefineConstant [
|
|
|
n = {3.14, Name "a number", <attributes...>},
|
|
|
DefineConstant [
|
|
|
n = {3.14, Name "a number", <attributes...>},
|
|
|
s = {"hello", Name "a string", <attributes...>}
|
|
|
];
|
|
|
```
|
... | ... | @@ -110,7 +110,7 @@ Include "generic_model.pro" |
|
|
```
|
|
|
The user-visible ONELAB variable `"a flag changing the behavior of the model"` will never be defined, and for the user of the specific model, everything behaves as if `flag` is not a parameter.
|
|
|
|
|
|
Note that in addition to setting the values of the local variables in the input `.geo` and `.pro` files, both Gmsh and GetDP allow to pass local variable definitions on the command line, with the `-setnumber name value` and `-setstring name value` command line options.
|
|
|
Note that in addition to setting the values of the local variables in the input `.geo` and `.pro` files, both Gmsh and GetDP allow to pass local variable definitions on the command line, with the `-setnumber name value` and `-setstring name value` command line options.
|
|
|
|
|
|
### Examples
|
|
|
|
... | ... | @@ -136,7 +136,7 @@ Currently these basic functions do not allow setting optional ONELAB attributes. |
|
|
|
|
|
## SetNumberRunTime, SetNumberRunTimeWithChoices and GetNumberRunTime (GetDP only)
|
|
|
|
|
|
All the above commands (`DefineNumber`, `DefineString`, `DefineConstant`, `SetNumber`, `SetString`, `GetNumber` and `GetString`) are executed when the input data files for GetDP and Gmsh are parsed. For GetDP, this means that the queries in the database using these commands are done once, when the `.pro` file is analyzed.
|
|
|
All the above commands (`DefineNumber`, `DefineString`, `DefineConstant`, `SetNumber`, `SetString`, `GetNumber` and `GetString`) are executed when the input data files for GetDP and Gmsh are parsed. For GetDP, this means that the queries in the database using these commands are done once, when the `.pro` file is analyzed.
|
|
|
|
|
|
However, in some situations, one might want to exchange information with the ONELAB database while the computation is running, i.e. at ''run-time''. GetDP defines three built-in functions (at the same level as other GetDP functions like `X[]` or `Vector[]`) that allow to exchange numbers at run-time, while evaluating expressions:
|
|
|
|
... | ... | @@ -146,13 +146,13 @@ SetNumberRunTimeWithChoices[ 3.14 ]{"a number"} |
|
|
GetNumberRunTime[]{"a number"}
|
|
|
```
|
|
|
|
|
|
The first two set the value of the given parameter in the database, with the second appending the value to the "choices" list as well. The third gets the value of the given parameter. These three functions can be used in all the same places that other GetDP expressions can be used, e.g. in `Function` definitions, `Formulation` terms, inside the `Evaluate` operation in a `Resolution`, etc.
|
|
|
The first two set the value of the given parameter in the database, with the second appending the value to the "choices" list as well. The third gets the value of the given parameter. These three functions can be used in all the same places that other GetDP expressions can be used, e.g. in `Function` definitions, `Formulation` terms, inside the `Evaluate` operation in a `Resolution`, etc.
|
|
|
|
|
|
## SendToServer (GetDP only)
|
|
|
|
|
|
See the GetDP [documentation](http://getdp.info/doc/texinfo/getdp.html#Types-for-PostOperation) for more information.
|
|
|
See the GetDP [documentation](https://getdp.info/doc/texinfo/getdp.html#Types-for-PostOperation) for more information.
|
|
|
|
|
|
# Optional parameter attributes
|
|
|
# Optional parameter attributes
|
|
|
|
|
|
## Common attributes
|
|
|
|
... | ... | @@ -213,7 +213,7 @@ In addition, numbers can take the following specific attributes: |
|
|
|
|
|
* `Graph "string"`: Display the list of values stored in the `choices` attribute as a 2D graph. The `string` encodes for which coordinate (x or y) in the predefined graphs (top left, top right, ...) the values will be used. Each graph is encoded as 4 characters, corresponding to the use of the values as the x, y, x' and y' coordinates (x' and y' are used when two curves should be drawn on 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 use the values for the y coordinates on the top-left graph, displaying the curve with the continuous style; the `string` `"10000200"` will use the data for the x coordinates on the top-left graph and also use them as the y coordinates on the top-right graph.
|
|
|
|
|
|
* `NumberFormat "string"`: Display the value using the given `printf`-style formatting string, instead of the default "%g".
|
|
|
* `NumberFormat "string"`: Display the value using the given `printf`-style formatting string, instead of the default "%g".
|
|
|
|
|
|
## String attributes
|
|
|
|
... | ... | |