Using the Expression Editor

Simcenter STAR-CCM+ provides an expression editor that simplifies the process of writing and checking the validity of expressions. In the editor, you select the relevant operators, functions, and variables (for example, existing reports and field functions) from a list of options.

For details on the expression syntax, see Expression Syntax.

Depending on the object that you define (see Context and Data Types), you can use an expression to set the object Definition, Value, or equivalent property:

To set a property using an expression, you can either:
  • Type the expression directly in the property field.
  • Set the property using the expression editor.

To use the expression editor:

  1. In the relevant property field, click (Custom Editor).
    For some objects (for example field functions), the expression editor appears immediately. For other objects (for example physics values), an intermediate dialog appears. In this case, click (Custom Editor) next to the relevant property in the intermediate dialog.
    The expression editor includes:
    • A text panel where you enter the expression.
    • A list of system functions that you can use in the expression. See System Functions.
    • A list of objects (reports, field functions, or parameters) that you can insert as variables. The types of objects that the expression can reference depend on the context of the expression. For example, expressions that define parameters cannot use field functions as variables (see Context and Data Types).

      A pencil icon appears next to the name of the object that you are defining.



  2. To see the definition of a variable, hover over it with the pointer.


  3. In the text panel, enter the expression using any combination of the following techniques:
    Typing the definition directly

    As you type, candidate objects that start with the text you entered appear in a pop-up list. The pop-up list includes both system function and variables. Auto-complete does not recognize special characters such as ~, $, &, /, and so on.

    To select from the pop-up list, either:
    • Use the <Up> or <Down> arrow keys and press <Enter>.
    • Double-click the desired entry.

    When you type the definition, you can use common editing techniques, such as copying and pasting.

    Inserting objects interactively
    To add a variable or system function, do one of the following:
    • Double-click the object.
    • Select the object and press the spacebar.
    • Right-click the object name and select Insert.

    When you insert a variable, this replaces any selected text in the expression text panel. When you insert a system function, any selected text becomes enclosed by the function. For example, if you have $$Velocity selected and you insert the system function mag($$u), mag($$Velocity) appears in the expression text panel. If there is no selection, the system function gets inserted at the cursor location with no argument, for example mag().

    General Rules and Tips
    • Space and line break between tokens are not significant, so you can use them to make the definition easier to read. If you indent on one line, subsequent lines are automatically indented.
    • Definitions are always entered in SI units, independent of the units that you use for input or display.
    • The expression text panel uses colors to help guide you through the editing process:

      • Green indicates a syntactically correct reference to an existing object.
      • Parentheses and square brackets appear in yellow to indicate the matching parenthesis.
      • Red indicates an incorrect entry. However, if a field function reference has red text (but no black text or red background) the color represents a syntactically correct reference to a field function that does not yet exist.
      • Notification of an error can also appear as an alert in the lower left corner of the expression editor.

      • If you click OK when the definition includes an error, error messages are displayed in the Output window.

        When errors occur, examine and debug the definition until it is accepted without any error notifications.

You can also create a user field function or a global parameter from within the expression editor.
  1. To create either of these objects, select a type from the associated drop-down list.




    A New Field Function or New Parameter dialog appears in which you define the object.