... | ... | @@ -2,12 +2,51 @@ GetDP uses three kinds of numeric variables: parser variables, run-time variable |
|
|
|
|
|
## Parser variables
|
|
|
|
|
|
Parser variables are created when the input `.pro` files are parsed, once at the beginning of a calculation. Such variables cannot be changed at run-time, during a calculation, i.e. during pre-processing (`Constraint` evaluations), processing (`Resolution` operations) or post-processing (`PostOperation` operations). Such variables are the most common in GetDP `.pro` files. They involve the least overhead at run-time, as their value is computed once, when the `.pro` file is read.
|
|
|
Parser variables are created when the input `.pro` files are parsed, once at the beginning of a calculation. Such variables cannot be changed at run-time during a calculation, i.e. during pre-processing (`Constraint` evaluations), processing (`Resolution` operations) or post-processing (`PostOperation` operations). Parser variables are the most common in GetDP `.pro` files. They involve the least overhead at run-time, as their value is computed once, when the `.pro` file is read. They can be defined (almost) anywhere in `.pro` files, i.e. outside or inside objects like `Function` or `Resolution`.
|
|
|
|
|
|
In the following example `a`, `b` and `c` are parser variables; they can be used inside lists like `d()` (which are also parser variables), or within functions like `e[]` (which will only be evaluated at run-time):
|
|
|
|
|
|
```cpp
|
|
|
a = 1;
|
|
|
b = Sin[2*Pi/4] - a;
|
|
|
Function{
|
|
|
c = (b < 1) ? -4e6 : 2.2e2;
|
|
|
d() = {a,b,c};
|
|
|
e[] = a + b + c;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Run-time variables
|
|
|
|
|
|
Run-time variables are created at run-time during pre-processing, processing or post-processing, through the run-time evaluation of expressions (like functions). Such variables can be used to handle dynamic cases that can not be predicted at parse time. Run-time variables begin with a dollar sign `$`. Their value can be set or retrieved in any expression, e.g. when a function is called, or in the `Evaluate`, `While`, `Test`, etc., operation in `Resolution`. Some run-time variables are read-only and are only modified by built-in GetDP algorithms or functions, like `$Time` or `$TimeStep`.
|
|
|
Run-time variables are created at run-time during pre-processing, processing or post-processing, through the run-time evaluation of expressions (like functions). Such variables can be used to handle dynamic cases that can not be predicted at parse time. Run-time variables begin with a dollar sign `$`. Their value can be set or retrieved in any expression, e.g. when a function is called in a `Formulation` term, or in the `Evaluate`, `While`, `Test`, etc., operations in a `Resolution`. They can be set in expression either with a simple affectation (`=`) or with the `SetVariable` function; their value can be retrieved either directly or using the `GetVariable` function. Both `SetVariable` and `GetVariable` allow to construct dynamic variable names, by appending suffixes dynamically depending on their extra arguments.
|
|
|
|
|
|
Some run-time variables are read-only and are only modified by built-in GetDP algorithms or functions, like `$Time` or `$TimeStep`.
|
|
|
|
|
|
In the following example the run-time variable `$a` is set to the value 2 in different ways; the run-time variables `$b_1`, `$b_2`, ... are dynamically created depending on the index of the quadrature point in a formulation term; and the run-time variable `$c` is set to `0.3`, `0.4` ... `1` using the `Evaluate` operation in a `Resolution`:
|
|
|
|
|
|
```cpp
|
|
|
Function{
|
|
|
f[] = ($a = 2);
|
|
|
g[] = (SetVariable[2]{$a});
|
|
|
}
|
|
|
Formulation{
|
|
|
...
|
|
|
Equation{
|
|
|
Integral{ [ SetVariable[{u}, QuadraturePointIndex[]]{$b} * Dof{d u} , {d u}]; ... }
|
|
|
}
|
|
|
}
|
|
|
Resolution{
|
|
|
...
|
|
|
Operation{
|
|
|
Evaluate[ $c = 0.3 ];
|
|
|
While[ $c < 0.9 ]{
|
|
|
Evaluate[ $c = $c + 0.1 ];
|
|
|
}
|
|
|
Print[{$c}, Format "$c = %g"];
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## ONELAB parameters
|
|
|
|
|
|
ONELAB parameters are exchanged with the ONELAB server, and can thus be exchanged with other ONELAB clients. ONELAB parameters can be created or accessed both at parse time (using the parser commands `DefineNumber`, `DefineConstant`, `GetNumber` and `SetNumber`) or at run-time (using the functions `GetNumberRunTime` and `SetNumberRunTime`). ONELAB parameters potentially involve the most overhead, as they can be exchanged through e.g. TCP-IP sockets over a network. |
|
|
ONELAB parameters are exchanged with the ONELAB server, and can thus be exchanged with other ONELAB clients. ONELAB parameters can be created or accessed both at parse time (using the parser commands `DefineNumber`, `DefineConstant`, `GetNumber` and `SetNumber`) or at run-time (using the functions `GetNumberRunTime` and `SetNumberRunTime`). ONELAB parameters potentially involve the most overhead, as they can be exchanged through e.g. TCP-IP sockets over a network. |
|
|
\ No newline at end of file |