8.1.6. 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:

8.1.6.1. 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:

8.1.6.2. Scalar function and operators#

Symbol

Mathematical operator / function

+

Scalar addition

-

Scalar subtraction

*

Scalar multiplication

/

Scalar division

pow(a,b)

Base scalar a raised to the power scalar b

sqrt()

Square-root of scalar

log()

Natural Logarithm

exp()

Base-e exponential

sin(), cos(), tan()

Trigonometric Functions

min(), max()

Minimum/Maximum value of the two

ceil(), floor()

Smallest/largest integer that is greater/smaller than the input

pi

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.

8.1.6.3. Functions that operate on vectors#

Note that the vector being used in the following functions must have 3 components.

Function

Mathematical function

subtract(C, A, B)

\(\vec{C} = \vec{A} - \vec{B}\)

cross(C, A, B)

\(\vec{C} = \vec{A} \times \vec{B}\) where \(\times\) is the vector cross product

dot(A, B)

returns \(\vec{A} \cdot \vec{B}\) where \(\cdot\) is the vector dot product

magnitude(A)

returns the length/magnitude of \(\vec{A}\)

8.1.6.4. 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.

8.1.6.4.1. 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

mut

Array[1]

Turbulent viscosity

mu

Array[1]

Laminar viscosity

solutionNavierStokes

Array[5]

Solution for the N-S equation in conservative form in non-inertial reference frame

residualNavierStokes

Array[5]

Residual for the N-S equation in conservative form in non-inertial reference frame

solutionTurbulence

Array[2/1]

Solution for the turbulence model. Number of component depends on underlying turbulence model

residualTurbulence

Array[2/1]

Residual for the turbulence model. Number of component depends on underlying turbulence model

kOmega

Array[2]

Effectively solutionTurbulence when using SST model

nuHat

Array[1]

Effectively solutionTurbulence when using SA model

solutionTransition

Array[2]

Solution for the transition model

residualTransition

Array[2]

Residual for the transition model

solutionHeatSolver

Array[1]

Solution for the heat equation

residualHeatSolver

Array[1]

Residual for the heat equation

coordinate

Array[3]

Nodal coordinates in earth system

primitiveVars

Array[5]

rho, u, v, w, p (density, 3 velocities and pressure)

8.1.6.4.2. 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

MachRef

Scalar

MachRef specified by the user in freestream

muRef

Scalar

muRef specified by the user in freestream

Tref

Scalar

Temperature specified by the user in freestream

t

Scalar

Physical time

physicalStep

Scalar

Physical time step, starting from 0

pseudoStep

Scalar

Pseudo time step within the physical time step, starting from 0

timeStepSize

Scalar

Physical time step size

alphaAngle

Scalar

alphaAngle specified by the user in freestream

betaAngle

Scalar

betaAngle specified by the user in freestream

pressureFreestream

Scalar

Freestream reference pressure. Has a constant value of 1.0 / 1.4

momentLengthX

Scalar

X component of momentLength specified by the user in geometry

momentLengthY

Scalar

Y component of momentLength specified by the user in geometry

momentLengthZ

Scalar

Z component of momentLength specified by the user in geometry

momentCenterX

Scalar

X component of momentCenter specified by the user in geometry

momentCenterY

Scalar

Y component of momentCenter specified by the user in geometry

momentCenterZ

Scalar

Z component of momentCenter specified by the user in geometry

8.1.6.4.3. 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 8.3.2.

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

bet_thrust

Scalar

BET Disk ID

Thrust force for the BET disk

bet_torque

Scalar

BET Disk ID

Torque for the BET disk

bet_omega

Scalar

BET Disk ID

Rotation speed for the BET disk

CD

Scalar

Patch name

Drag coefficient on the patch

CL

Scalar

Patch name

Lift coefficient on the patch

forceX

Scalar

Patch name

Total force on the patch in X direction

forceY

Scalar

Patch name

Total force on the patch in Y direction

forceZ

Scalar

Patch name

Total force on the patch in Z direction

momentX

Scalar

Patch name

Total moment with respect to momentCenter on the patch in X direction

momentY

Scalar

Patch name

Total moment with respect to momentCenter on the patch in Y direction

momentZ

Scalar

Patch name

Total moment with respect to momentCenter on the patch in Z direction

nodeNormals

Array[3]

Patch name

Normal vector of the patch. Its magnitude is the area associated with the node

theta

Scalar

Zone name

Rotation angle (in radians) of the volume zone

omega

Scalar

Zone name

Rotation speed of the volume zone

omegaDot

Scalar

Zone name

Rotation acceleration of the volume zone

wallFunctionMetric

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.

wallShearStress

Array[3]

Patch name

Wall viscous shear stress on the patch in X, Y and Z

yPlus

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.