User Defined Expressions#
Note
This is currently a beta feature and may be subject to change during the lifetime of the release.
User Defined Expressions are a powerful tool to interact with solver variables in order to expand the realm of what can be achieved. The major use of user defined expression falls into the following catagories:
Guidance on how to write User Defined Expressions#
The expression follows syntax that is very similar to the C language. Although it should be mentioned that, for safety reasons, not all C language features are supported. Statements are separated by semicolon. Examples are available here and here in our tutorials.
The following operators and functions are allowed to define an expression:
Scalar function and operators#
Symbol |
Mathematical operator / function |
---|---|
|
Scalar addition |
|
Scalar subtraction |
|
Scalar multiplication |
|
Scalar division |
|
Base scalar |
|
Square-root of scalar |
|
Natural Logarithm |
|
Base-e exponential |
|
Trigonometric Functions |
|
Minimum/Maximum value of the two |
|
Smallest/largest integer that is greater/smaller than the input |
|
Constant pi = 3.14158… |
Caution
Please note that in all instances of User Defined Expressions integer divisions (i.e. "18/12"
) will discard the fraction part (which results in 1
in this case) consistent with the C language. Please consider explicitly using at least one float number in division (i.e. "18.0/12"
) if such behavior is not desired.
Functions that operate on vectors#
Note that the vector being used in the following functions must have 3 components.
Function |
Mathematical function |
---|---|
|
\(\vec{C} = \vec{A} - \vec{B}\) |
|
\(\vec{C} = \vec{A} \times \vec{B}\) where \(\times\) is the vector cross product |
|
returns \(\vec{A} \cdot \vec{B}\) where \(\cdot\) is the vector dot product |
|
returns the length/magnitude of \(\vec{A}\) |
Solver variables#
In an expression, users can use solution variables as well as custom variables. There are three categories of solver variables:
Variables that are defined on all grid nodes and is not bound to a specific “source” (like zone or patch).
Variables that are unique to the entire grid/simulation and are not bound to a specific “source” (like zone or patch). Unlike the first category, values of these variables are not related to particular grid nodes.
Variables that are associated with a certain “source”. For example the
CL
has to be associated with a surface patch;theta
has to be associated with certain volume zone(s). See examples in user defined post processing and user defined dynamics.
Note
All variables are non-dimensional. More information on nondimensionalization in Flow360 can be found at Nondimensional Inputs and Nondimensional Outputs.
Variables that are defined on all grid nodes#
For the variables that are defined on all grid nodes, the following solver variables can be used. These variables are listed as arrays since their values depends on the grid nodes.
Name |
Type[component] |
Note |
---|---|---|
|
Array[1] |
Turbulent viscosity |
|
Array[1] |
Laminar viscosity |
|
Array[5] |
Solution for the N-S equation in conservative form in non-inertial reference frame |
|
Array[5] |
Residual for the N-S equation in conservative form in non-inertial reference frame |
|
Array[2/1] |
Solution for the turbulence model. Number of component depends on underlying turbulence model |
|
Array[2/1] |
Residual for the turbulence model. Number of component depends on underlying turbulence model |
|
Array[2] |
Effectively |
|
Array[1] |
Effectively |
|
Array[2] |
Solution for the transition model |
|
Array[2] |
Residual for the transition model |
|
Array[1] |
Solution for the heat equation |
|
Array[1] |
Residual for the heat equation |
|
Array[3] |
Nodal coordinates in earth system |
|
Array[5] |
rho, u, v, w, p (density, 3 velocities and pressure) |
Simulation wide variables#
For this second category, the following solver variables can be used. These variables are listed as scalars since they have a unique value across the entire grid/simulation.
Name |
Type[component] |
Note |
---|---|---|
|
Scalar |
|
|
Scalar |
|
|
Scalar |
|
|
Scalar |
Physical time |
|
Scalar |
Physical time step, starting from 0 |
|
Scalar |
Pseudo time step within the physical time step, starting from 0 |
|
Scalar |
Physical time step size |
|
Scalar |
|
|
Scalar |
|
|
Scalar |
Freestream reference pressure. Has a constant value of 1.0 / 1.4 |
|
Scalar |
X component of |
|
Scalar |
Y component of |
|
Scalar |
Z component of |
|
Scalar |
X component of |
|
Scalar |
Y component of |
|
Scalar |
Z component of |
Zone or patch associated variables#
For variables that are associated with a certain zone or patch, the following solver variables can be used. For bet_thrust
, bet_torque
and bet_omega
user can add the index of the bet disk into the variable name such as bet_0_thrust
which indicates the thrust of the first bet disk.
Note
The forces (forceX/Y/Z
) and moments (momentX/Y/Z
) should be distinguished from the force/moment coefficients (e.g. CL
, CMy
). The forces and moments are the numerators of the force/moment coefficients as shown in Table 54.
All variables that are also listed in universal variables have the same definitions here. Some variables will not be available if the corresponding feature is not enabled. For example solutionTransition
is not available if the case does not use transition model.
Name |
Type[component] |
Source type |
Note |
---|---|---|---|
|
Scalar |
BET Disk ID |
Thrust force for the BET disk |
|
Scalar |
BET Disk ID |
Torque for the BET disk |
|
Scalar |
BET Disk ID |
Rotation speed for the BET disk |
|
Scalar |
Patch name |
Drag coefficient on the patch |
|
Scalar |
Patch name |
Lift coefficient on the patch |
|
Scalar |
Patch name |
Total force on the patch in X direction |
|
Scalar |
Patch name |
Total force on the patch in Y direction |
|
Scalar |
Patch name |
Total force on the patch in Z direction |
|
Scalar |
Patch name |
Total moment with respect to |
|
Scalar |
Patch name |
Total moment with respect to |
|
Scalar |
Patch name |
Total moment with respect to |
|
Array[3] |
Patch name |
Normal vector of the patch. Its magnitude is the area associated with the node |
|
Scalar |
Zone name |
Rotation angle (in radians) of the volume zone |
|
Scalar |
Zone name |
Rotation speed of the volume zone |
|
Scalar |
Zone name |
Rotation acceleration of the volume zone |
|
Array[1] |
Patch name |
(beta feature) : This metric is a local indicator of the quality of the wall model. A value less than 1.25 indicates a good estimation of the wall shear stress. Between 1.25 and 10 indicates lower confidence, and values greater than 10 are not reliable for wall shear stress estimation. |
|
Array[3] |
Patch name |
Wall viscous shear stress on the patch in X, Y and Z |
|
Array[1] |
Patch name |
Non-dimensional wall distance, \(y^+\) on the patch |
- Explanation on the source type:
BET Disk ID: this is the index/position of the BET disk as they appear in the case JSON. Starting from 0.
Patch name: name of the patch defined in the mesh file.
Zone name: name of the volume zone defined in the mesh file.